заповнення таблиці

22 вересня 2020
MORENKO OLEKSII

Таблиця кодів не оптимізовано - доопрацювати (MFC)

// TablicaKodovDlg.h : header file
//
#pragma once
#define PI 3.1415926535897932384626433832795
#define mtime 20
// CTablicaKodovDlg dialog
class CTablicaKodovDlg : public CDialog
{
// Construction
public:
CTablicaKodovDlg(CWnd* pParent = nullptr); // standard constructor
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_TABLICAKODOV_DIALOG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
private:
COLORREF cf, ck, c[25];
HFONT hold, hNew, hbk;
HPEN hPenOxy, hOldPen, pen;
HBRUSH m, oldm, brush;
CPen d, oldd;
CBitmap pic;
CRect rc, w, kw[30];
CString ms, t, z;
int Matrix[50][50];
int x1, y1, x2, y2, x3, y3, x4, y4;
int RH, RW, k, i, j, p, x, y, cx, cy, dx, dy;
bool fg;
};
// ---------------------------------------------------------------------------------------
// TablicaKodovDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TablicaKodov.h"
#include "TablicaKodovDlg.h"
#include "afxdialogex.h"
#include <cwchar>
#include <iostream>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTablicaKodovDlg dialog
CTablicaKodovDlg::CTablicaKodovDlg(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_TABLICAKODOV_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTablicaKodovDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
SetWindowTextW(L"Таблиця кодів");
}
BEGIN_MESSAGE_MAP(CTablicaKodovDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
// CTablicaKodovDlg message handlers
BOOL CTablicaKodovDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE;  // return TRUE  unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
void CTablicaKodovDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CClientDC dc(this);
GetClientRect(&rc);
dc.FillSolidRect(&rc, RGB(255, 255, 255));
hbk = (HFONT)::GetStockObject(SYSTEM_FONT);
hNew = CreateFont(44, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, L"Penta");
t = "Таблиця кодів ASCII";
hold = (HFONT)SelectObject(dc, hNew);
SetTextColor(dc, RGB(255, 0, 0));
dc.TextOutW(25, 15, t, t.GetLength());
x1 = rc.left + 10; y1 = rc.top + 75;
x2 = rc.right - 10; y2 = rc.bottom - 25;
dx = (x2 - x1) / 12; dy = (y2 - y1) / 16;
dc.MoveTo(x1, y1);
dc.LineTo(x2, y1);
dc.LineTo(x2, y2);
dc.LineTo(x1, y2);
dc.LineTo(x1, y1);
for (int i = 0; i < 13; i++)
{
dc.MoveTo(x1 + i * dx, y1);
dc.LineTo(x1 + i * dx, y2);
}
for (int i = 0; i < 16; i++)
{
dc.MoveTo(x1, y1 + i * dy);
dc.LineTo(x2, y1 + i * dy);
}
hNew = CreateFont(28, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, L"Times New Roman");
hold = (HFONT)SelectObject(dc, hNew);
int kod = 32;
wchar_t buff;
for (int i = 0; i < 16; i++)
{
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
t += wchar_t(kod);
dc.TextOutW(x1 + 30, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod);
dc.TextOutW(x1 + 90, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
t += wchar_t(kod + 16);
dc.TextOutW(x1 + 160, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod + 16);
dc.TextOutW(x1 + 220, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
t += wchar_t(kod + 32);
dc.TextOutW(x1 + 300, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod + 32);
dc.TextOutW(x1 + 360, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
t += wchar_t(kod + 48);
dc.TextOutW(x1 + 430, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod + 48);
dc.TextOutW(x1 + 490, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
t += wchar_t(kod + 64);
dc.TextOutW(x1 + 570, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod + 64);
dc.TextOutW(x1 + 630, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(0, 0, 128));
t.Empty();
if (kod + 80 != 127) t += wchar_t(kod + 80);  else t = "";
dc.TextOutW(x1 + 700, y1 + 15 + i * dy, t, t.GetLength());
SetTextColor(dc, RGB(128, 0, 0));
t.Empty();
t.Format(L"%i", kod + 80);
dc.TextOutW(x1 + 760, y1 + 15 + i * dy, t, t.GetLength());
kod++;
}
hold = (HFONT)SelectObject(dc, hbk);
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CTablicaKodovDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
Якщо ви помітили помилку чи неточність, виділіть фрагмент тексту та натисніть Ctrl+Enter.

 

Умови використання матеріалів сайту

Використання матеріалів можливе лише за умови активного гіперпосилання на UaModna ( див. Правила* ). Для генерації коду посилання натисніть на кнопку

Думки, позиції, уподобання та заклики, опубліковані на нашому сайті, є власністю авторів і можуть не співпадати з поглядами редакції uamodna.com

Краса та практичність: які матеріали використовують для оббивки м’яких меблів
Від того, наскільки вона буде практичною та міцною, залежатиме тривалість її «життя» та привабливого вигляду меблів, тож це варто враховувати, вибираючи диван чи крісло.
Читати більше
Чи можна займатися спортом під час місячних і як це впливає на організм
Останнім часом ставлення до особливостей жіночого організму змінилося на більш помірковане. Водночас оновились рекомендації щодо занять спортом під час місячних. Сьогодні ми розповімо про них.
Читати більше