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

一个windows编程的有关问题

2012-03-26 
一个windows编程的问题#includewindows.h LRESULTCALLBACKWinProc(HWNDhwnd,//handletowindowUINTuMsg,/

一个windows编程的问题
#include   "windows.h "

LRESULT   CALLBACK   WinProc(
    HWND   hwnd,             //   handle   to   window
    UINT   uMsg,             //   message   identifier
    WPARAM   wParam,     //   first   message   parameter
    LPARAM   lParam       //   second   message   parameter
);
int   WINAPI   WinMain(HINSTANCE   hInstance,
      HINSTANCE   hPrevInstance,
      LPTSTR   lpCmdLine,
      int   nShowCmd)
{
WNDCLASSEX   wndclass;

wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.cbSize=sizeof(WNDCLASSEX);
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
        wndclass.hIcon=LoadIcon(NULL,IDI_QUESTION);
wndclass.hIconSm=LoadIcon(NULL,IDI_QUESTION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WinProc;
wndclass.lpszClassName= "abc ";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;

RegisterClassEx(&wndclass);

HWND   hwnd;
hwnd=CreateWindow     // <---expression   cannot   be   eveluated!!( "abc ", "title ",WS_POPUP,0,0,640,480,NULL,NULL,hInstance,NULL);
       
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);


MSG   msg;
while(true)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(GetAsyncKeyState(VK_ESCAPE) <0)
break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
}


}

return(0);
}

LRESULT   CALLBACK   WinProc(
    HWND   hwnd,             //   handle   to   window
    UINT   uMsg,             //   message   identifier
    WPARAM   wParam,     //   first   message   parameter
    LPARAM   lParam       //   second   message   parameter
)
{
switch(uMsg)
{
default:
return   DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return(1);
}

在以上的这段代码中,我单步跟踪调试的时候发现hwnd句柄从头到尾都是
Error:expression   cannot   be   eveluated
这是为什么?

[解决办法]
hwnd,已经不为NULL了,说明已经成功创建了,程序已经正确执行了,
至于Error:expression cannot be eveluated ,只是调试器不支持你通过hwnd了解该句柄更详细的信息,不知道你理他做甚?

热点排行