Home > Software engineering >  Why in the win32 application always appear always open a precompiled header file: 'the Debug/mi
Why in the win32 application always appear always open a precompiled header file: 'the Debug/mi

Time:10-13

#include
#include
#include
#include
#include
#include
# define NOLE 0
# define OOO - 1
# define X 18
# define 60 W
# define 40 H
# define LE 300
Const COLORREF LERGB []={
0 x008000,
0 x800000,
0 x0080ff,
0 x800080,
0 x404080,
0 xc08000,
0 x40ff00,
0 xff00ff,
0 x00ffc0};

Int map [W + 2] [H + 2];
Int count;
Int le;
Char a, [10].
The HWND HWND;
HDC HDC.
PAINTSTRUCT pt;

HDC DHDC MHDC;
The RECT drect;
HBITMAP HMBMP;
Cx, int cy;


Void MapInit ();
Void LeftClick (int x, int y);
Void RightClick (int x, int y);
Void IfLe ();
Void LeDraw (int, int j);
Void LeColor (int, int j, a COLORREF x, int s);
Void ZeroLe (int, int j);
Void Old ();
Void SetOld (int x, int y, a COLORREF r, int, int s);
Void DrawInit ();

LRESULT a CALLBACK WndProc (HWND HWND, UINT Message, WPARAM WPARAM, LPARAM LPARAM) {
The switch (the Message) {
Case WM_KEYDOWN:
The switch (wParam) {
Case 'N' :
MapInit ();
break;
}
break;
Case WM_LBUTTONDOWN:
LeftClick (LOWORD (lParam), HIWORD (lParam));
break;
Case WM_RBUTTONDOWN:
RightClick (LOWORD (lParam), HIWORD (lParam));
break;
In case the WM_PAINT:
HDc=BeginPaint (hWnd, & amp; Pt);
BitBlt (DHDC, 0, 0, cx, cy, MHDC, 0, 0, SRCCOPY);
EndPaint (hWnd, & amp; Pt);
break;
Case WM_CLOSE:
The DestroyWindow (HWND);
break;
Case WM_DESTROY:
The PostQuitMessage (0);
break;
Default:
Return DefWindowProc (HWND, Message, wParam, lParam);
}
return 0;
}

Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
Modifed WNDCLASSEX wc.
The HWND HWND;
MSG MSG.

Memset (& amp; Wc, 0, sizeof (wc));
Wc. CbSize=sizeof (modifed WNDCLASSEX);
Wc. LpfnWndProc=WndProc;
The wc. The hInstance=hInstance;
Wc. HCursor=LoadCursor (NULL, IDC_ARROW);

Wc. HbrBackground=(HBRUSH) (COLOR_WINDOW + 1);
Wc. LpszClassName="WindowClass";
Wc. HIcon=LoadIcon (NULL, IDI_APPLICATION);
Wc. HIconSm=LoadIcon (NULL, IDI_APPLICATION);

if(! RegisterClassEx (& amp; Wc)) {
MessageBox (NULL, "Windows Registration Failed!" , "Error!" , MB_ICONEXCLAMATION | MB_OK);
return 0;
}

HWND=CreateWindowEx (WS_EX_CLIENTEDGE, "WindowClass", "Caption,"
WS_VISIBLE | WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME ^ WS_MAXIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
1090,
752,
NULL, NULL, hInstance, NULL);

If (HWND==NULL) {
MessageBox (NULL, "Window Creation Failed!" , "Error!" , MB_ICONEXCLAMATION | MB_OK);
Return 0;
}

HWnd=hWnd;
Count=0;
Le=0;
Srand (time (NULL));
DrawInit ();
MapInit ();

While (GetMessage (& amp; Msg, NULL, 0, 0) & gt; 0 {
TranslateMessage (& amp; Msg);
DispatchMessage (& amp; Msg);
}

DeleteObject (MHDC);
ReleaseDC (hWnd, DHDC);

Return Msg. WParam;
}

Void MapInit ()
{
Int I, j, k, d;
Count=0;
Le=0;

for(i=1; i<=W; I++) for (j=1; j<=H; J++) map [I] [j]=NOLE;

While (count{
I=rand () % W) + 1;
J=rand () % H) + 1;
If (map [I] [j]==0)
{
The map [I] [j]=OOO;
count++;
}
}

For (I=1; I & lt;=W; I++)
For (j=1; J & lt;=H; J++)
If (map [I] [j] & gt;=NOLE)
{
Count=0;
For (k=1; K & lt;=1; K++)
For (d=1; D & lt;=1; D++)
If (1 & lt;=I + k & amp; & I + k & lt;
=W& & 1 & lt;=j + d & amp; & J + d & lt; H=
& & The map [I] + k + d [j] The map [I] [j]=count;
}
SelectObject (MHDC, GetStockObject (GRAY_BRUSH));
SetBkColor (x808080 MHDC, 0);
For (I=1; I & lt;=W; I++)
For (j=1; J & lt;=H; J++)
{
A Rectangle (MHDC, (I - 1) * X, (j - 1) * X, I * X, j * X).
}

BitBlt (DHDC, 0, 0, cx, cy, MHDC, 0, 0, SRCCOPY);
}

Void LeftClick (int x, int y)
{
Int I=(int) floor (x/x);
Int j=(int) floor (y/X);
If (map [I + 1] [m + 1] & gt;=NOLE)
{
If (map [I + 1] [j + 1)==NOLE) ZeroLe (I, j);
The else LeDraw (I, j);
BitBlt (DHDC, 0, 0, cx, cy, MHDC, 0, 0, SRCCOPY);
}
The else
{
IfLe ();
BitBlt (DHDC, 0, 0, cx, cy, MHDC, 0, 0, SRCCOPY);
MessageBox (hWnd, "Bad", "Game", MB_OK);
MapInit ();
}
}

Void RightClick (int x, int y)
{
Int I=(int) floor (x/x);
Int j=(int) floor (y/X);
LeColor (I, j, 0, 1);
If (map [I + 1] [j + 1)==OOO)
{
Le++;
Map [I + 1] [j + 1)=2;
}
If (le==le)
{
IfLe ();
MessageBox (hWnd, "Good", "Game", MB_OK);
MapInit ();
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related