[ucgui] 子窗口父窗口

 

它创建了3个窗口:

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

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

 1 static void _cbWin(WM_MESSAGE * pMsg) {
 2     GUI_COLOR Color;
 3     switch (pMsg->MsgId) {
 4         case WM_PAINT:
 5         WM_GetUserData(pMsg->hWin, &Color, 4);
 6         GUI_SetBkColor(Color);
 7         GUI_Clear();
 8         break;
 9         default:
10         WM_DefaultProc(pMsg);
11     }
12 }
13 /*********************************************************************
14 *
15 * _cbDoSomething
16 */
17 static void _cbDoSomething(WM_HWIN hWin, void * p) {
18     int Value = *(int *)p;
19     WM_MoveWindow(hWin, Value, Value);
20 }
21 /*********************************************************************
22 *
23 * MainTask
24 */
25 void Fun(void) {
26     WM_HWIN hWin_1, hWin_2, hWin_3;
27     int Value = 10;
28     GUI_COLOR aColor[] = {GUI_RED, GUI_GREEN, GUI_BLUE};
29     GUI_Init();
30     WM_SetDesktopColor(GUI_BLACK);
31     hWin_1 = WM_CreateWindow( 10, 10, 100, 100, WM_CF_SHOW, _cbWin, 4);
32     hWin_2 = WM_CreateWindowAsChild(10, 10, 80, 80, hWin_1, WM_CF_SHOW, _cbWin, 4);
33     hWin_3 = WM_CreateWindowAsChild(10, 10, 60, 60, hWin_2, WM_CF_SHOW, _cbWin, 4);
34     WM_SetUserData(hWin_1, &aColor[0], 4);
35     WM_SetUserData(hWin_2, &aColor[1], 4);
36     WM_SetUserData(hWin_3, &aColor[2], 4);
37     while (1) {
38         WM_ForEachDesc(WM_HBKWIN, _cbDoSomething, (void *)&Value);
39         Value *= -1;
40         GUI_Delay(500);
41     }
42 }
  • 前两个为回调函数,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);

 

posted @ 2014-08-23 01:41  beautifulzzzz  阅读(1693)  评论(0编辑  收藏  举报