我用WM_CreateWindow()创建窗口得到句柄 hParentWnd,GUI_Delay(1000)执行后可以显示出创建的窗口;
又用WM_CreateWindowAsChild()创建窗口作为hParentWnd的子窗口,执行GUI_Delay(1000)后没反应是为什么呢?
父窗口和子窗口的毁掉函数都设置了。
/*窗口创建例子*/
void DemoRedraw(void)
{
GUI_HWIN hParentWnd;
while(1)
{
hParentWnd=WM_CreateWindow(30,30,100,100,WM_CF_SHOW,cbParentWin,0);
GUI_Delay(1000);
/*用回调函数创建子窗口*/
WM_CreateWindowAsChild(130,30,100,100,
hParentWnd,WM_CF_SHOW,
cbChildWin,0);
GUI_Delay(1000);
}
}
/*子窗口回调函数*/
static void cbChildWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetColor(GUI_BLACK);
GUI_SetBkColor(GUI_BLUE);
GUI_Clear(); //设置完字体颜色和背景颜色后必须先清屏,再显示字符等。
GUI_DispString("Background of window has not been redraw");
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*父窗口回调函数*/
static void cbParentWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_RED);
GUI_Clear();
GUI_DispString("Foreground window");
GUI_DispString("
after build ");
break;
default:
WM_DefaultProc(pMsg);
}
} |