当前位置:网站首页>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
边栏推荐
- Student achievement management
- Oracle query foreign keys contain comma separated data
- The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
- 集合之List接口
- The query type of MySQL is very inefficient.
- Configure automatic implementation of curd projects
- [Mysql] LEFT函数 | RIGHT函数
- Idempotency practice operation, explaining idempotency based on business
- Find the number of leaf nodes of binary tree
- Seminar playback video: how to improve Jenkins' ability to become a real Devops platform
猜你喜欢
It can receive multiple data type parameters - variable parameters
Blazor University (12) - component lifecycle
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
一套组合拳,打造一款 IDEA 护眼方案
QT dynamic translation of Chinese and English languages
QT learning summary
Quartz. Www. 18fu Used in net core
12.<tag-链表和常考点综合>-lt.234-回文链表
Flink customizes the application of sink side sinkfunction
ASP. Net 6 middleware series - conditional Middleware
随机推荐
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
js递归树结构计算每个节点的叶子节点的数量并且输出
New ORM framework -- Introduction to beetlsql
2022g2 boiler stoker examination question bank and online simulation examination
Generate QR code through zxing
Super easy to use asynchronous export function of Excel
集合之List接口
poi根据数据创建导出excel
Supersocket is Use in net5 - concept
Do you really understand hashcode and equals???
ASP. Net 6 middleware series - conditional Middleware
队列的存储和循环队列
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
Idea view history [file history and project history]
Knowledge of software testing~
IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
Explication détaillée des fonctions send () et recv () du programme Socket
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)