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:
CWnd* WndPtr;
HWND hwdesc;
HDC hdesc;
HDC hdc;
HDC hdct;
CPoint ps;
CString ms, t, z, PORADA[120];
CRect rc, kw[15], w;
CBitmap pic;
HBITMAP hbmn;
BITMAP bm;
HBITMAP hbm;
BITMAPINFO bmi;
int nweiDst, nheiDst;
COLORREF cf, ck, c[15];
DWORD* arb;
HPEN hPenOxy, hOldPen, pen;
HBRUSH m, oldm, brush;
CPen d, oldd;
HFONT hold, hNew, hbk;
int x1, y1, x2, y2, x3, y3, x4, y4;
int RH, RW, k, i, j, p, x, y, cx, cy, dx, dy;
int counter;
int pfix, jfix;
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);
dc.FillSolidRect(&rc, RGB(255, 255, 255));
RH = abs(rc.left - rc.right);
RW = abs(rc.top - rc.bottom);
dx = 570;
dy = 200;
x=x1 = rc.left + 300;
y=y1 = rc.top + 500;
cf = 0x00000000;
hPenOxy = CreatePen(PS_SOLID, 3, cf);
hOldPen = (HPEN)SelectObject(dc, hPenOxy);
for (int k = 0; k < 1000; k++)
{
x1 = rc.left + 300;
y1 = rc.top + 500 -k;
dc.MoveTo(x1, y1);
dc.LineTo(x1, y1 - 100);
x1 = x1; y1 = y1 - 100;
dc.LineTo(x1 + 30, y1 - 40);
x1 = x1 + 30; y1 = y1 - 40;
dc.LineTo(x1, y1 - 100);
x1 = x1; y1 = y1 - 100;
dc.LineTo(x1 + 30, y1 - 120);
x1 = x1 + 30; y1 = y1 - 120;
dc.LineTo(x1 + 30, y1 + 120);
x1 = x1 + 30; y1 = y1 + 120;
dc.LineTo(x1, y1 + 100);
x1 = x1; y1 = y1 + 100;
dc.LineTo(x1 + 30, y1 + 40);
x1 = x1 + 30; y1 = y1 + 40;
dc.LineTo(x1, y1 + 100);
x1 = x1; y1 = y1 + 100;
dc.LineTo(x1 - 20, y1);
x1 = x1 - 20; y1 = y1;
dc.LineTo(x1 - 10, y1 - 10);
x1 = x1 - 10; y1 = y1 - 10;
dc.LineTo(x1 - 60, y1);
x1 = x1 - 60; y1 = y1;
dc.LineTo(x1 - 10, y1 + 10);
x1 = x1 - 10; y1 = y1 + 10;
dc.LineTo(x1 - 20, y1);
dc.MoveTo(x1 + 10, y1 - 10);
x1 = x1 + 10; y1 = y1 - 10;
dc.LineTo(x1, y1 - 130);
x1 = x1; y1 = y1 - 130;
dc.MoveTo(x1 + 60, y1);
x1 = x1 + 60; y1 = y1;
dc.LineTo(x1, y1 + 130);
x1 = x1; y1 = y1 + 130;
dc.MoveTo(x1 - 30, y1 + 10);
x1 = x1 - 30; y1 = y1 + 10;
dc.LineTo(x1, y1 - 140);
x1 = x1; y1 = y1 - 140;
dc.MoveTo(x1, y1 - 70);
x1 = x1; y1 = y1 - 100;
dc.Ellipse(x1 - 10, y1 - 10, x1 + 10, y1 + 10);
dc.MoveTo(x1, y1 + 40);
x1 = x1; y1 = y1 + 40;
dc.Ellipse(x1 - 10, y1 - 10, x1 + 10, y1 + 10);
Sleep(10);
dc.FillSolidRect(&rc, RGB(255, 255, 255));
}
/*dc.Rectangle(x1, y1, x2, y2);
x3 = x1 + dx / 6;
y3 = y1;
dc.MoveTo(x3, y3);
dc.LineTo(x3 + dx / 6, y1 + dy / 2);
dc.LineTo(x3, y1 + dy);
dc.LineTo(x3 - dx / 6, y1 + dy / 2);
dc.LineTo(x3, y3);
CBrush br3(0x0000FF);
SelectObject(dc, br3);
dc.FloodFill(x3, y3 + 5, cf);
x3 = x3 + dx / 3;
y3 = y1;
dc.MoveTo(x3, y3);
dc.LineTo(x3 + dx / 6, y1 + dy / 2);
dc.LineTo(x3, y1 + dy);
dc.LineTo(x3 - dx / 6, y1 + dy / 2);
dc.LineTo(x3, y3);
CBrush br4(0x00FFFF);
SelectObject(dc, br4);
dc.FloodFill(x3, y3 + 5, cf);
x3 = x3 + dx / 3;
y3 = y1;
dc.MoveTo(x3, y3);
dc.LineTo(x3 + dx / 6, y1 + dy / 2);
dc.LineTo(x3, y1 + dy);
dc.LineTo(x3 - dx / 6, y1 + dy / 2);
dc.LineTo(x3, y3);
CBrush br5(0x00CC00);
SelectObject(dc, br5);
dc.FloodFill(x3, y3 + 5, cf);*/
SelectObject(dc, hOldPen);
DeleteObject(hPenOxy);
//DeleteObject(br3);
//DeleteObject(br4);
//DeleteObject(br5);
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.