static void _cbBkWindow(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_ClearRect(0, 0, 240, 300);
default:
WM_DefaultProc(pMsg);
}
}
static void _cbMyMainWindow(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_ClearRect(0, 0, 99, 199);
GUI_SetFont(&GUI_Font8x16);
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLUE);
GUI_DispStringAt("here is hwin1",0,0);
GUI_DispStringAt("here is hwin1",0,15);
GUI_DispStringAt("here is hwin1",0,31);
//GUI_DispStringAt("here is hwin1",0,47);
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
WM_HWIN hWin1;
WM_CALLBACK *_cbPreviousWin;
int i;
GUI_Init();
//①创建窗口函数;_cbMyMainWindow是创建窗口时的回调函数用于重绘窗口。
hWin1 = WM_CreateWindow(0,0,100,40,WM_CF_SHOW,_cbMyMainWindow,0);
//②设置背景窗口的回调函数,主要功能是清除背景。使用指针_cbPreviousWin保存其原始的回调函数。
_cbPreviousWin = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
//③移动窗口,观察现象
for (i = 0; i < 60; i++) {
WM_MoveWindow(hWin1, 2, 2);
GUI_Delay(100);
}
//④删除窗口
WM_DeleteWindow(hWin1);
//⑤执行操作
GUI_Exec();
//⑥恢复背景窗口的回调函数
WM_SetCallback(WM_HBKWIN, _cbPreviousWin);
//使背景窗口无效,下次就会重绘窗口
WM_Invalidate(WM_HBKWIN);
while(1)
{
GUI_Delay(10);
}
}
STemWin之窗口管理
最新推荐文章于 2022-07-22 08:02:41 发布