[ucgui] 子窗口父窗口

时间:2022-10-24 23:52:36

它创建了3个窗口:

  • 第一个作为桌面的子窗口
  • 第二个作为第一个窗口的子窗口
  • 第三个作为第二个窗口的子窗口

窗口创建后,使用WM_ForEachDesc()在其父窗口中移动各个窗口:

 static void _cbWin(WM_MESSAGE * pMsg) {
GUI_COLOR Color;
switch (pMsg->MsgId) {
case WM_PAINT:
WM_GetUserData(pMsg->hWin, &Color, );
GUI_SetBkColor(Color);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* _cbDoSomething
*/
static void _cbDoSomething(WM_HWIN hWin, void * p) {
int Value = *(int *)p;
WM_MoveWindow(hWin, Value, Value);
}
/*********************************************************************
*
* MainTask
*/
void Fun(void) {
WM_HWIN hWin_1, hWin_2, hWin_3;
int Value = ;
GUI_COLOR aColor[] = {GUI_RED, GUI_GREEN, GUI_BLUE};
GUI_Init();
WM_SetDesktopColor(GUI_BLACK);
hWin_1 = WM_CreateWindow( , , , , WM_CF_SHOW, _cbWin, );
hWin_2 = WM_CreateWindowAsChild(, , , , hWin_1, WM_CF_SHOW, _cbWin, );
hWin_3 = WM_CreateWindowAsChild(, , , , hWin_2, WM_CF_SHOW, _cbWin, );
WM_SetUserData(hWin_1, &aColor[], );
WM_SetUserData(hWin_2, &aColor[], );
WM_SetUserData(hWin_3, &aColor[], );
while () {
WM_ForEachDesc(WM_HBKWIN, _cbDoSomething, (void *)&Value);
Value *= -;
GUI_Delay();
}
}
  • 前两个为回调函数,Fun函数为主函数,建立3个窗口
  • WM_HWIN WM_CreateWindow(int x0, int y0,
    int width, int height,
    U8 Style, WM_CALLBACK * cb
    int NumExtraBytes);
  • WM_HWIN WM_CreateWindowAsChild(int x0, int y0,
    int width, int height,
    WM_HWIN hWinParent,
    U8 Style,
    WM_CALLBACK* cb
    int NumExtraBytes);
  • void WM_ForEachDesc(WM_HWIN hWin, WM_tfForEach * pcb, void * pData);