Home > OS >  "Windows programming" book "helloWorld" application source code, is always an er
"Windows programming" book "helloWorld" application source code, is always an er

Time:10-20

#include
LRESULT a CALLBACK WndProc (HWMD, UINT, WPARAM, LPARAM);
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE, hPrevInstance,
PSTR szCmdLine, int iCmdShow //the error C2146: syntax error: missing ') before the identifier 'szCm
//the error C2081: 'hPrevInstance' : the name in formal parameter list il
//the error C2081: 'PSTR' : the name in formal parameter list illegal
//the error C2061: syntax error: identifier 'szCmdLine'
//the error C2059: syntax error: '; '
//the error C2059: syntax error: ', '/
//the error C2059: syntax error: ')


{
The static TCHAR szAppName []=TEXT (" hELLOwIN ");
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 (NULL, IDI_APPLICATION);
Wndclass. HCursor=LoadCursor (NULL, IDC_ARROW);
Wndclass. HbrBackgrond=(HBRUSH) GETsTOCKoBJECT (WHITE_BRUSH);
Wndclass. LpszMenuName=NULL;
Wndclass. LpszClassName=szAppName;
if(! RegisterClass (& amp; Wndclass))
{
The Message (NULL, TEXT (" This program reqires Windows NT!" ),
SzAppName, MB_ICONERROR);
return 0;
}
HWND=CreateWindow (szAppName,
The TExt (" The Hello Program "),
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)
{
HDC HDC.
PAINTSTRUCT ps;
The RECT the RECT.
The switch (the message)
{
Case WM_CREATE message handler:
PlaySound (TEXT (" hellowin. Wav "), NULL, SND_FILENAME | SND_ASYNC);
return 0;
Case MWM_PAINT:
//the error C2051: case expression not constant
//the error C2065: 'MWM_PAINT: undeclared identifier
[b]

HDC=BeginPaint (HWND, & amp; Ps);
GetClientRect (HWDN, & amp; The rect);
//the error C2065: 'HWDN: undeclared identifier
//warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'int'
//warning C4024: 'GetClientRect' : the company types for formal and actual parameter 1


DrawText (HDC, TEXT (" Hello, Windows 98!" ), 1, & amp; The rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint (HWND, & amp; Ps);
return 0;
Case MWM_DESTROY:
//the error C2051: case expression not constant
//the error C2065: 'MWM_DESTROY: undeclared identifier

The PostQuitMessage (0);
return 0;
}
Return DefWindowProc (HWND, message, wParam, lParam);

}

CodePudding user response:

#include

CodePudding user response:

#include , test,

CodePudding user response:

#include , test the secret

CodePudding user response:

Everyone, no matter use, after a sticker or a bunch of mistakes...

CodePudding user response:

Is HWND instead of HWMD

HINSTANCE, hPrevInstance here more than a comma in the middle

CodePudding user response:

Is a wndclass. HbrBackground rather than a wndclass. HbrBackgrond

Is the GetStockObject rather than GetStockObject

Is the TEXT rather than TEXT

Small problems too much, only to find it

CodePudding user response:

For problem statement added start a new line/* */comment and then wrote the revised statement

 # include 

/* LRESULT CALLBACK WndProc (HWMD, UINT, WPARAM, LPARAM); */
LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

/* int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE, hPrevInstance, */
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)//the error C2146: syntax error: missing ') before the identifier 'szCm
//the error C2081: 'hPrevInstance' : the name in formal parameter list il
//the error C2081: 'PSTR' : the name in formal parameter list illegal
//the error C2061: syntax error: identifier 'szCmdLine'
//the error C2059: syntax error: '; '
//the error C2059: syntax error: ', '/
//the error C2059: syntax error: ')

{
The static TCHAR szAppName []=TEXT (" hELLOwIN ");

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 (NULL, IDI_APPLICATION);
Wndclass. HCursor=LoadCursor (NULL, IDC_ARROW);
/* wndclass. HbrBackgrond=(HBRUSH) GETsTOCKoBJECT (WHITE_BRUSH); */
Wndclass. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related