Don't step on the white. Zen Mode Windows program implementation
The code is as follows
#include <windows.h>lresult CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (//Program entry, WINAPI is a function calling convention that shows how to generate machine code that puts call parameters in the stack hinstance hinstance//instance handle, identifies the program, HINSTANCE hpreinstance//16 bits used to identify the previous instance of the program, 32 bits are no longer used, parameters are null, LPSTR szcmdline//call command line, int icmdshow)//window display method {static TCHAR szname[] = TEXT ("Hiyun"); HWND hwnd; MSG msg; Wndclass Wc;wc.style = Cs_vredraw | Cs_hredraw;wc.cbclsextra = 0;wc.cbwndextra = 0;wc.hbrbackground = (hbrush) getstockobject (WHITE_BRUSH); wc.hCursor = LoadCursor (null, idc_arrow); Wc.hicon = LoadIcon (null, idi_application); wc.hinstance = Hinstance;wc.lpfnwndproc = Wndproc;wc.lpszmenuname = Null;wc.lpszclassname = Szname;if (! RegisterClass (&WC)) {MessageBox (NULL, TEXT ("Registration failed!") "), TEXT (" failed "), MB_OK | Mb_iconerror);} hwnd = CreateWindow (SzName, TEXT ("Do not step on the white piece of Zen mode-Xianyunyehe production, QQ Group 116920287"), ws_overlappedwindow,400, +, +, 600,null, NULL, H Instance, NULL); ShowWindow (hwnd, icmdshow); UpdateWindow (HWND); while (GetMessage (&msg, NULL, 0, 0)) {TranslatemeSsage (&msg);D ispatchmessage (&msg);} return Msg.wparam;} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc; Paintstruct PS; Rect rect; TCHAR szbuff[50];static Hbrush brushpass = CreateSolidBrush (RGB (223, 223, 223)), static int I, j, X, Y, TX, ty;static int R Uning, Cxchar, Cychar, Cxclient, Cyclient, Cxsquare, cysquare;static TCHAR playname[] = TEXT ("YUN"); static ULONG score = 0 , t;static int loc[20];switch (message) {case wm_create:runing = 0;HDC = GetDC (hwnd); Textmetric TM; GetTextMetrics (hdc, &TM); Cxchar = Tm.tmavecharwidth;cychar = Tm.tmheight + tm.tmexternalleading; ReleaseDC (hwnd, HDC); return 0;case wm_size:cxclient = loword (lparam); cyclient = HiWord (lparam); cxsquare = Cxclient/4;cy Square = (int) (Cxsquare * 1.5); for (i = 0; I <= cyclient/cysquare + 2; ++i) {Loc[i] = rand ()% 4;} return 0;case wm_lbuttondown:tx = x = LoWord (lparam), Ty = y = hiword (lparam); x/= cxsquare;y = (cyclient-y)/Cysquare;i F (loc[0] = = x && y = = 0 &&!runing) {runing = 1;invalidaterect (hwnd, NULL, True);} else if (loc[1] = = x && y = = 1 && runing) {score++;for (i = 0; I <= cyclient/cysquare + 1; ++i) {Loc[i] = Loc[i + 1];} Loc[i] = rand ()% 4;invalidaterect (hwnd, NULL, True);} return 0;case WM_PAINT:HDC = BeginPaint (hwnd, &PS); SetBkMode (hdc, TRANSPARENT); SetTextColor (hdc, RGB (255, 0, 0)); for (i = 1; i < 4; ++i) {Movetoex (hdc, Cxsquare * I, 0, NULL); LineTo (HDC, Cxsquare * I, cyclient);} for (i = 0; I <= cyclient/cysquare + 1; ++i) {Movetoex (hdc, 0, Cyclient-cysquare * i, NULL); LineTo (hdc, cxclient, Cyclient-cysquare * i), j = loc[i];if (i = = 0 && runing) SelectObject (hdc, brushpass); Elsese Lectobject (hdc, Getstockobject (Black_brush)); Rectangle (HDC, J * Cxsquare, Cyclient-cysquare * (i + 1), Cxsquare * (j + 1) + 1, Cyclient-cysquare * i + 1); if (!runin G && i = = 0) {TextOut (hdc, J * cxsquare + CXSQUARE/2-Cxchar * 1.5, Cyclient-cysquare/2,szbuff, wsprintf (SzB Uff, TEXT ("Start")));}} TeXtout (hdc, Cxchar, Cychar, szbuff,wsprintf (Szbuff, Text ("player:%s"), playname)); t = wsprintf (Szbuff, Text ("Score:%ld" ), score); TextOut (HDC, cxclient-(t + 2) * Cxchar, Cychar, Szbuff, T); EndPaint (hwnd, &PS); return 0;case wm_destroy:postquitmessage (0); return 0;} Return DefWindowProc (HWND, message, wparam, lparam);}
Don't step on the white. Zen Mode Windows program implementation