当前位置:网站首页>Visual programming - Experiment 1
Visual programming - Experiment 1
2022-04-23 03:22:00 【Tang Encheng_ hhhc】
The difficulty of this experiment is to arrange the following poem vertically
“ Mine old friend left the west from the Yellow Crane Tower ”,
“ In this flowery March journeyed south to Yangzhou ”,
“ Alone sail, far shadow, blue sky ”,
“ Only to see the Yangtze River flow in the sky ”,
#include<windows.h>
long WINAPI WndProc
(
HWND hWnd,
UINT iMessage,
UINT wParam,
LONG lParam
);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow);
//------------------------------- The main function --------------------------------------------------
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG Message;
if (!InitWindowsClass(hInstance)) return FALSE;
if (!InitWindows(hInstance, nCmdShow))return FALSE;
while (GetMessage(&Message, 0, 0, 0))// Message loop
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
//----------------------------------- Message handler -----------------------------------
long WINAPI WndProc(HWND hWnd, UINT iMessage, UINT wParam, LONG lParam)
{
HPEN hP;
HBRUSH hB;
static long nXChar, nYChar;
HDC hDC; // Define a handle to the device context
short x;
TEXTMETRIC tm;
short LnCount = 4;
PAINTSTRUCT PtStr; // Defines a structure variable that points to the drawing information
const static TCHAR* textbuf[] =
{
L" Mine old friend left the west from the Yellow Crane Tower ",
L" In this flowery March journeyed south to Yangzhou ",
L" Alone sail, far shadow, blue sky ",
L" Only to see the Yangtze River flow in the sky ",
};
switch (iMessage) // Process the message
{
case WM_PAINT: // Handle redraw messages
hDC = BeginPaint(hWnd, &PtStr); // Start painting
for (int i = 4; i > 0; i--)
{
nXChar = 350 +( i+1) * 25;
nYChar = 10;
for (int j = 0; j < 7; j++)
{
nYChar = 10 + j * 25;
TextOut(hDC, nXChar, nYChar, (LPCWSTR)textbuf[4-i] + j, 1);
}
}
SetMapMode(hDC, MM_TEXT);
hP = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
SelectObject(hDC, hP);
MoveToEx(hDC, 80, 70, NULL);
LineTo(hDC, 40, 10);
MoveToEx(hDC, 40,10 , NULL);
LineTo(hDC, 120, 10);
MoveToEx(hDC, 80, 70, NULL);
LineTo(hDC, 120, 10);
Ellipse(hDC, 40, 70, 120, 160);
MoveToEx(hDC, 80, 160, NULL);
LineTo(hDC, 50, 190);
LineTo(hDC, 50, 220);
LineTo(hDC, 110, 220);
LineTo(hDC, 110, 190);
LineTo(hDC, 80, 160);
hB = (HBRUSH)GetStockObject(BLACK_BRUSH);
SelectObject(hDC, hB);
RoundRect(hDC, 180, 10, 260, 70, 10, 10);
Pie(hDC, 180, 70, 260, 160, 210, 70, 230, 70);
Rectangle(hDC, 180, 160, 260, 220);
EndPaint(hWnd, &PtStr);
return 0;
case WM_DESTROY: // End the application
PostQuitMessage(0);
return 0;
default: // Other message handlers
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
}
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hWnd = CreateWindow(L"Bitmap", L"202 visualization _ Experiment 1 ",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbWndExtra = 0;
WndClass.cbClsExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(WHITE_BRUSH));
WndClass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION));
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = L"Bitmap";
WndClass.lpszMenuName = L"Menu";
WndClass.style = 0;
return RegisterClass(&WndClass);
}
The result is shown in the figure :

版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621319638.html
边栏推荐
- QT dynamic translation of Chinese and English languages
- Mysql database design specification
- Queue storage and circular queue
- 为什么BI对企业这么重要?
- MySql关键字GROUP_CONCAT,组合连接查询
- Test experience data
- QT uses drag and drop picture to control and mouse to move picture
- oracle 查询外键含有逗号分隔的数据
- Docker pulls MySQL and connects
- 软件测试相关知识~
猜你喜欢

2022G2电站锅炉司炉考试题库及在线模拟考试

Why is bi so important to enterprises?

MySQL keyword group_ Concat, combined connection query

QT learning summary

Knowledge of software testing~

2022 P cylinder filling training test questions and simulation test
![[mock data] fastmock dynamically returns the mock content according to the incoming parameters](/img/1e/c4aad49d16fb21a19865ba75128e43.png)
[mock data] fastmock dynamically returns the mock content according to the incoming parameters

Top 9 task management system in 2022
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

Problem a: face recognition
随机推荐
Charles uses three ways to modify requests and responses
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
2022 P cylinder filling training test questions and simulation test
2022a special equipment related management (elevator) work license question bank and simulation examination
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
WinForm allows the form form to switch between the front and active states
Fiddler use
Experiment 6 input / output stream
C-10 program error correction (recursive function): number to character
The query type of MySQL is very inefficient.
Docker pulls MySQL and connects
2022g2 boiler stoker examination question bank and online simulation examination
批量下载文件----压缩后再下载
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
全新的ORM框架——BeetlSQL介绍
General testing technology [1] classification of testing
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
Course design of Database Principle -- material distribution management system
socket編程 send()與 recv()函數詳解