I'm in vc6.0 written before, as if the same code can be pulled out of the normal
Here is my code
# include & lt; Windows. H>
LRESULT a CALLBACK cfy_CallBack (
HWND HWND,//handle to the window
UINT uMsg,//the message identifier
WPARAM WPARAM,//the first message parameter
LPARAM LPARAM//second message parameter
);
Int WINAPI WinMain (
HINSTANCE HINSTANCE,//handle to the current instance
HINSTANCE hPrevInstance,//handle to the previous instance
LPSTR lpCmdLine,//command line
Int nCmdShow//show the state
)
{
WNDCLASS start_form;
Start_form. CbClsExtra=NULL;
Start_form. CbWndExtra=NULL;
Start_form. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);
Start_form. HCursor=LoadCursor (NULL, IDC_ARROW);
Start_form. HIcon=LoadIcon (NULL, IDI_ASTERISK);
Start_form. HInstance=hInstance;
Start_form. LpfnWndProc=cfy_CallBack;
Start_form. LpszClassName="cfy_form";
Start_form. LpszMenuName=NULL;
Start_form. Style=CS_HREDRAW | CS_VREDRAW;
RegisterClass (& amp; Start_form);
The HWND cfy_hwnd;
Cfy_hwnd=CreateWindow (" cfy_form "and" sharp ", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow (cfy_hwnd SW_NORMAL);
UpdateWindow (cfy_hwnd);
MSG MSG.
While (GetMessage (& amp; MSG, cfy_hwnd, NULL, NULL))
{
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
return false;
}
LRESULT a CALLBACK cfy_CallBack (
HWND HWND,//handle to the window
UINT uMsg,//the message identifier
WPARAM WPARAM,//the first message parameter
LPARAM LPARAM//second message parameter
)
{
/* the switch (uMsg)
{
Case WM_DESTROY:
The PostQuitMessage (0);
}
*/
Return DefWindowProc (HWND, uMsg wParam, lParam);
}
That a comment code, regardless of is the same, point destroyed just after closing the window interface, but also to destroy the task manager program, and program CPU is as much as 50%,
CodePudding user response:
Whether start_form didn't shut downCodePudding user response:
I use vc6.0 test is the same situation, I also can not find out where there is something wrong withCodePudding user response:
The GetMessage the second parameter can be set to null, reason analysis to understand, very good for youCodePudding user response:
Clear in the MSDN says: GetMessage return value can be nonzero, Zero or - 1Explicitly warned not to write code like this: while (GetMessage (lpMsg hWnd, 0, 0))
And you just do that,
CodePudding user response:
Educated,,,