1 #include "windows.h"
2 #include "stdio.h"
3
4
5
6
7 LRESULT CALLBACK winQZproc(
8 HWND hwnd, // handle to window
9 UINT uMsg, // message identifier
10 WPARAM wParam, // first message parameter
11 LPARAM lParam // second message parameter
12 );
13
14
15
16
17 int WINAPI WinMain(
18 HINSTANCE hInstance, // handle to current instance
19 HINSTANCE hPrevInstance, // handle to previous instance
20 LPSTR lpCmdLine, // command line
21 int nCmdShow // show state
22 )
23 {
24 WNDCLASS wnd;
25 wnd.cbClsExtra=NULL;
26 wnd.cbWndExtra=NULL;
27 wnd.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
28 wnd.hCursor=LoadCursor(hInstance,IDC_CROSS);
29 wnd.hIcon=LoadIcon(hInstance,IDI_APPLICATION);
30 wnd.hInstance=hInstance;
31 wnd.lpfnWndProc=winQZproc;
32 wnd.lpszClassName="qz2021";
33 wnd.lpszMenuName=NULL;
34 wnd.style=CS_HREDRAW|CS_VREDRAW;
35 RegisterClass(&wnd);
36
37
38 //*********************************//
39
40 HWND hwnd;
41 hwnd= CreateWindow("qz2021","遵义枫林软件工作室",WS_OVERLAPPEDWINDOW,0,0, 800,500,NULL,NULL,hInstance,NULL);
42 if(hwnd==NULL)
43 {
44 return 0;
45 }
46 ShowWindow(hwnd,SW_SHOWNORMAL);
47 UpdateWindow(hwnd);
48
49 //***********消息循环//
50 MSG msg;
51 while(GetMessage(&msg,hwnd,NULL,NULL))
52 {
53 TranslateMessage(&msg);
54 DispatchMessage(&msg);
55
56 }
57 //*************回调函数********.//
58
59
60 return 0;
61
62 }
63
64 LRESULT CALLBACK winQZproc(
65 HWND hwnd, // handle to window
66 UINT uMsg, // message identifier
67 WPARAM wParam, // first message parameter
68 LPARAM lParam // second message parameter
69 )
70 {
71 switch(uMsg)
72 {
73 case WM_PAINT:
74 HDC hdc;
75 PAINTSTRUCT dc;
76 hdc=BeginPaint(hwnd,&dc);
77 TextOut(hdc,0,50,"遵义枫林软件工作室",strlen("遵义枫林软件工作室"));
78 EndPaint(hwnd,&dc);
79 break;
80
81 case WM_CHAR:
82 char str[20];
83 sprintf(str,"char is %c",(char)wParam);
84 MessageBox(hwnd,str,"按下的字符",NULL);
85 break;
86
87 case WM_LBUTTONDOWN:
88 MessageBox(hwnd,"LeftMouse click","鼠标左键按下",NULL);
89 HDC hdc1;
90 hdc1=GetDC(hwnd);
91
92
93 TextOut(hdc1,0,100,"鼠标左键按下",strlen("鼠标左键按下"));
94 ReleaseDC(hwnd,hdc1);
95 break;
96
97 case WM_CLOSE:
98 if (IDYES==MessageBox(NULL,"你确定要结束当前应用程序!","消息关闭",MB_YESNO))
99 {
100 DestroyWindow(hwnd);
101 PostQuitMessage(0);
102
103 }
104 break;
105 case WM_DESTROY:
106 PostQuitMessage(0);
107 break;
108
109 default:
110 return DefWindowProc(hwnd,uMsg,wParam,lParam);
111 }
112
113
114 }
![]()