ProgramDlg.h
// ProgramDlg.h : header file
//
#pragma once
#define mtime 298
#define PI 3.1415926535897932384626433832795
// CProgramDlg dialog
class CProgramDlg : public CDialog
{
// Construction
public:
CProgramDlg(CWnd* pParent = nullptr); // standard constructor
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_PROGRAM_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();
private:
COLORREF cf, 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;
DECLARE_MESSAGE_MAP()
};
ProgramDlg.cpp
// ProgramDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Program.h"
#include "ProgramDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CProgramDlg dialog
CProgramDlg::CProgramDlg(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_PROGRAM_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProgramDlg::DoDataExchange(CDataExchange* pDX)
{
fg = true;
SetWindowTextW(L"Program");
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CProgramDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
// CProgramDlg message handlers
BOOL CProgramDlg::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 CProgramDlg::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);
RH = abs(rc.left - rc.right);
RW = abs(rc.top - rc.bottom);
cx = RH / 2;
cy = RW / 2;
// TODO
int bx, ex, by, ey;
int maxX = rc.right;
int minX = rc.left;
int maxY = rc.bottom;
int minY = rc.top;
cf = RGB(255, 255, 255);
dc.FillSolidRect(&rc, cf);
x1 = minX + 70; y1 = minY + 35;
x2 = maxX - 50; y2 = maxY - 30;
pen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
brush = CreateSolidBrush(cf);
SelectObject(dc, pen);
SelectObject(dc, brush);
//dc.Rectangle(x1, y1, x2, y2);
//DeleteObject(pen);
//DeleteObject(brush);
bx = minX + 110; by = minY + 60;
ex = maxX - 120; ey = maxY - 65;
dx = dy = 30;
for (k = 0; k < 300; k++)
{
x = bx+k; y = by + 300;
dc.MoveTo(x, y);
dc.LineTo(x + 350, y - 250);
x1 = x = x + 350; y1 = y = y - 250;
dc.LineTo(x + 250, y + 200);
x = x + 250; y = y + 200;
dc.LineTo(x - 200, y);
x = x - 200; y = y;
dc.LineTo(x - 50, y + 50);
x2 = x = x - 50; y2 = y = y + 50;
dc.LineTo(x - 350, y);
x = x - 350; y = y;
dc.LineTo(x, y + 50);
x = x; y = y + 50;
dc.LineTo(x + 500, y);
x = x + 500; y = y;
dc.LineTo(x + 100, y - 100);
dc.MoveTo(x1, y1);
dc.LineTo(x2, y2);
x = x2, y = y2;
dc.MoveTo(x + 50, y);
x = x + 80; y = y;
dc.Ellipse(x - 15, y - 15, x + 15, y + 15);
x = x + 40; y = y;
dc.Ellipse(x - 15, y - 15, x + 15, y + 15);
Sleep(15);
dc.FillSolidRect(&rc, cf);
x3 = bx + k; y3 = by + 300;
}
x = x3; y = y3;
dc.MoveTo(x, y);
dc.LineTo(x + 350, y - 250);
x1 = x = x + 350; y1 = y = y - 250;
dc.LineTo(x + 250, y + 200);
x = x + 250; y = y + 200;
dc.LineTo(x - 200, y);
x = x - 200; y = y;
dc.LineTo(x - 50, y + 50);
x2 = x = x - 50; y2 = y = y + 50;
dc.LineTo(x - 350, y);
x = x - 350; y = y;
dc.LineTo(x, y + 50);
x = x; y = y + 50;
dc.LineTo(x + 500, y);
x = x + 500; y = y;
dc.LineTo(x + 100, y - 100);
dc.MoveTo(x1, y1);
dc.LineTo(x2, y2);
x = x2, y = y2;
dc.MoveTo(x + 50, y);
x = x + 80; y = y;
dc.Ellipse(x - 15, y - 15, x + 15, y + 15);
x = x + 40; y = y;
dc.Ellipse(x - 15, y - 15, x + 15, y + 15);
DeleteObject(pen);
DeleteObject(brush);
SelectObject(dc, hOldPen);
DeleteObject(hPenOxy);
DeleteObject(hNew);
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CProgramDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
Якщо ви помітили помилку чи неточність, виділіть фрагмент тексту та натисніть Ctrl+Enter.