[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);

 




本文转自beautifulzzzz博客园博客,原文链接:http://www.cnblogs.com/zjutlitao/p/3930540.html,如需转载请自行联系原作者

相关文章
|
2月前
|
索引
MFC工具栏和状态栏
MFC工具栏和状态栏
18 1
c#窗体——显示子窗口父窗口
c#窗体——显示子窗口父窗口
251 0
|
区块链
MFC为应用程序添加托盘(右键托盘,弹出菜单)
源代码:http://download.csdn.net/detail/nuptboyzhb/4137784 1.       导入一个托盘图标的资源(.ico)格式;资源ID为IDI_ICON1 2.
1271 0
MFC实现为窗体添加的背景图片
将一个bmp图片添加到资源中 在资源视图中更改位图资源的ID为IDB_BITMAP_BACKGROUND。   第一种方法:   在Dialog中添加一个Picture Control控件,将Picture Control控件的Type属性 更改为Bitmap。
837 0
pyqt5实现打开子窗口
# -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class FirstWindow(QWidget): close_signal = pyqtSi...
2346 0

热门文章

最新文章