Home > database >  Why this program according to the book to knock but can't compile, the following code
Why this program according to the book to knock but can't compile, the following code

Time:10-02

//the header file
# define IDI_ICON 101

//Next to the default values for the new objects
//
# ifdef APSTUDIO_INVOKED
# # ifndef APSTUDIO_READONLY_SYMBOLS
# define _APS_NEXT_RESOURCE_VALUE 106
# define _APS_NEXT_COMMAND_VALUE 40001
# define _APS_NEXT_CONTROL_VALUE 1000
# define _APS_NEXT_SYMED_VALUE 101
# endif
# endif


//the source code

#include
# include "334-335. H"
//# define IDI_ICON 101
LRESULT a CALLBACK WndProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM);
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
TCHAR szAppName []=TEXT (" IconDemo ");
The HWND HWND;
MSG MSG.
WNDCLASS WNDCLASS;

Wndclass. Style=CS_HREDRAW | CS_VREDRAW;
Wndclass. LpfnWndProc=WndProc;
Wndclass. CbClsExtra=0;
Wndclass. CbWndExtra=0;
Wndclass. HInstance=hInstance;
Wndclass. HIcon=LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON));
Wndclass. HCursor=LoadCursor (NULL, IDC_ARROW);
Wndclass. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);
Wndclass. LpszMenuName=NULL;
Wndclass. LpszClassName=szAppName;

if (! RegisterClass (& amp; Wndclass))
{
MessageBox (NULL, TEXT (" This program requires Windows NT! "), szAppName, MB_ICONERROR);
return 0;
}

HWND=CreateWindow (szAppName, TEXT (" Icon Demo "),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT CW_USEDEFAULT,
CW_USEDEFAULT CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);

ShowWindow (HWND, iCmdShow);
UpdateWindow (HWND);

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

Return MSG. WParam;
}

LRESULT a CALLBACK WndProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
The static HICON HICON;
Static int cxIcon cyIcon, cxClient cyClient;
HDC HDC.
HINSTANCE HINSTANCE,
PAINTSTRUCT ps;
Int x, y;

The switch (the message)
{
Case WM_CREATE message handler:
HInstance=(lParam) (LPCREATESTRUCT) - & gt; HInstance;
HIcon=LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON));
CxIcon=GetSystemMetrics (SM_CXICON);
CyIcon=GetSystemMetrics (SM_CYICON);
return 0;
Case WM_SIZE:
CxClient=LOWORD (lParam);
CxClient=HIWORD (lParam);
return 0;
In case the WM_PAINT:
HDC=BeginPaint (HWND, & amp; Ps);
For (y=0; Y & lt; CyClient; Y +=cyIcon)
For (x=0; X & lt; CxClient; X +=cxIcon)
DrawIcon (HDC, x, y, hIcon);
EndPaint (HWND, & amp; Ps);
return 0;
Case WM_DESTROY:
The PostQuitMessage (0);
return 0;
}
Return DefWindowProc (HWND, message, wParam, lParam);
}

Error message as shown in figure,

  • Related