Home > OS >  C for help (win32)
C for help (win32)

Time:09-20

Here is my copy others' code in a blank project to create a win32 application, can be normal in VS2017 create a window, but in the midst of VS2019 shows:

Error C2731 "wWinMain" : can't overloaded function

(1) the wWinMain instead WinMain nor can I
(2) I put the LPSTR szCmdLine instead LPWSTR szCmdLine, no matter use,
(3) application using UICODE code
Temporarily suspended
o# include & lt; Windows. H>

HINSTANCE hIst.
LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

Int APIENTRY wWinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
HIst=hInstance;//is convenient in use of the main function of other function handle to the instance
The static TCHAR szAppName []=TEXT (" HelloWin ");
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 (NULL, IDI_APPLICATION);
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,//the window class name
The TEXT (" simple window "),//window caption
WS_OVERLAPPEDWINDOW,//the window style
CW_USEDEFAULT,//initial position x
CW_USEDEFAULT,//initial position y
CW_USEDEFAULT,//initial size x
CW_USEDEFAULT,//initial y size
NULL,//the parent window handle
Window menu handle NULL,//
HInstance,//program instance handle
NULL);//creation parameters

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_CLOSE:
The DestroyWindow (HWND);
break;

Case WM_DESTROY:
The PostQuitMessage (0);
break;

Default:
Return DefWindowProc (HWND, message, wParam, lParam);

}

return 0;
}

CodePudding user response:

A new type of win32 project template, and then classify and paste in your code,
Otherwise let you modify the link editor, compiler configuration, you must persist,
  • Related