分类: LINUX
2008-03-24 09:46:48
在注册自己定义的控件时,注册函数位置不能随便放置。
我在如下位置放置的时候,一开始没啥问题,后来自己定义的控件多了,在程序运行的时候莫名其妙的会死掉,后来我把注册函数RegisterAllControl()换了一个位置就好了,调整到了MSG_CREATE消息中。
int MiniGUIMain (int argc, const char* argv[])
{
MSG Msg;
HWND hMainWnd;
MAINWINCREATE CreateInfo;
#ifdef _LITE_VERSION
SetDesktopRect(0, 0, 578, 555);
#endif
// 注册控件
RegisterAllControl();
CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER ;
CreateInfo.dwExStyle = WS_EX_NONE;
CreateInfo.spCaption = "";
CreateInfo.hMenu = 0;
CreateInfo.hCursor = GetSystemCursor(0);
CreateInfo.hIcon = 0;
CreateInfo.MainWindowProc = PressureWinProc;
CreateInfo.lx = 0;
CreateInfo.ty = 0;
CreateInfo.rx = 578;
CreateInfo.by = 555;
CreateInfo.iBkColor = COLOR_black;
CreateInfo.dwAddData = 0;
CreateInfo.hHosting = HWND_DESKTOP;
hMainWnd = CreateMainWindow (&CreateInfo);
if (hMainWnd == HWND_INVALID)
return -1;
ShowWindow(hMainWnd, SW_SHOWNORMAL);
while (GetMessage(&Msg, hMainWnd)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainWindowThreadCleanup (hMainWnd);
UnregisterAllControl ();
return 0;
}