首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

帮忙看一下这段代码有什么有关问题

2012-01-29 
帮忙看一下这段代码有什么问题#includewindows.hLRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwP

帮忙看一下这段代码有什么问题
#include   <windows.h>
LRESULT   CALLBACK   WndProc(HWND   hwnd,UINT   message,WPARAM   wParam,LPARAM   lParam);
int   WINAPI   WinMain(HINSTANCE   hInstance,HINSTANCE   hPrevInstance,LPSTR   lpCmdLine,int   nShowCmd){
static   TCHAR   szAppName[]   =   TEXT( "TextOuta ");
HWND   hwnd;
MSG   msg;
WNDCLASS   wndclass;
wndclass.style=   CS_HREDRAW   |   CS_VREDRAW;
wndclass.lpfnWndProc=   WndProc;
wndclass.hIcon=   LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=   LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=   (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.cbClsExtra=   0;
wndclass.cbWndExtra=   0;
wndclass.hInstance=   hInstance;
wndclass.lpszClassName=   szAppName;
wndclass.lpszMenuName=   NULL;
if(   !RegisterClass(   &wndclass   )   ){
MessageBox(NULL,TEXT( "This   application   needs   Windows   NT! "),szAppName,MB_ICONERROR);
return   0;
}
hwnd   =   CreateWindow(szAppName,
TEXT( "Text   out "),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
while(   GetMessage(&msg,hwnd,0,0)   ){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return   msg.wParam;
}
LRESULT   CALLBACK   WndProc(HWND   hwnd,UINT   message,WPARAM   wParam,LPARAM   lParam){
/*HDC   hdc;
PAINTSTRUCT   ps;
switch(message){
case   WM_CREATE:
return   0;
case   WM_PAINT:
hdc   =   BeginPaint(hwnd,&ps);
//SetTextAlign(hdc,TA_TOP   |   TA_RIGHT);
//TextOut(hdc,100,100,TEXT( "HELLO   WORLD "),11);
EndPaint(hwnd,&ps);
return   0;
case   WM_DESTROY:
PostQuitMessage(0);
return   0;
}*/
return   DefWindowProc(hwnd,message,wParam,lParam);
}
窗口关闭了,但是进程还在,而且CPU占用率为100%

[解决办法]
while( GetMessage(&msg,hwnd,0,0) ){

while( GetMessage(&msg,NULL,0,0) ){

热点排行