我是新手,问一个VC++的问题!

来源:百度知道 编辑:UC知道 时间:2024/04/27 13:49:09
各位看一下这个VC++6.0的代码,编译时没有错误,为什么没显示窗口?

#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="fuyu2009";
wndcls.lpszMe

给你调试了半天,日!!错在最后的窗口回调函数:最下面那几行:
default:
DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
改成:
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

回调函数的消息处理有误。
default:
DefWindowProc(hwnd,uMsg,wParam,lParam);应该改为:
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);