硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3039|回复: 9
收起左侧

[emWin] 关于函数MULTIPAGE_SetTabHeight和MULTIPAGE_SetTabWidth的使用

[复制链接]

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117586
QQ
发表于 2017-6-20 01:51:44 | 显示全部楼层 |阅读模式
客户反映这两个函数使用没有效果,实际是有效果的,注意不要设置错位置了:
效果显现如下:
QQ截图20170622145726.png

======================================================
可以在模拟器上面运行的完成测试代码,直接复制到模拟器上面就可以跑:
  1. #include "DIALOG.h"
  2. /*
  3. ************************************************************************************************
  4. *                             添加到多页控件第一个页面窗口的对话框
  5. ************************************************************************************************
  6. */
  7. /*********************************************************************
  8. *
  9. *       Defines
  10. *
  11. **********************************************************************
  12. */
  13. #define ID_WINDOW_01 (GUI_ID_USER + 0x10)
  14. #define ID_BUTTON_01 (GUI_ID_USER + 0x11)
  15. // USER START (Optionally insert additional static data)
  16. // USER END
  17. /*********************************************************************
  18. *
  19. *       _aDialogCreate
  20. */
  21. static const GUI_WIDGET_CREATE_INFO _aDialogCreatePage1[] = {
  22.   { WINDOW_CreateIndirect, "Window", ID_WINDOW_01, 0, 0, 400, 200, 0, 0x0, 0 },
  23.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_01, 127, 68, 129, 43, 0, 0x0, 0 },
  24. };
  25. /*********************************************************************
  26. *
  27. *       Static code
  28. *
  29. **********************************************************************
  30. */
  31. // USER START (Optionally insert additional static code)
  32. // USER END
  33. /*********************************************************************
  34. *
  35. *       _cbDialog
  36. */
  37. static void _cbDialogPage1(WM_MESSAGE * pMsg) {
  38.   WM_HWIN hItem;
  39.   int     NCode;
  40.   int     Id;
  41.   // USER START (Optionally insert additional variables)
  42.   // USER END
  43.   switch (pMsg->MsgId) {
  44.   case WM_INIT_DIALOG:
  45.     //
  46.     // Initialization of 'Button'
  47.     //
  48.     hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_01);
  49.     BUTTON_SetFont(hItem, GUI_FONT_16B_ASCII);
  50.     BUTTON_SetText(hItem, "Page1");
  51.     // USER START (Optionally insert additional code for further widget initialization)
  52.     // USER END
  53.     break;
  54.   case WM_NOTIFY_PARENT:
  55.     Id    = WM_GetId(pMsg->hWinSrc);
  56.     NCode = pMsg->Data.v;
  57.     switch(Id) {
  58.     case ID_BUTTON_01: // Notifications sent by 'Button'
  59.       switch(NCode) {
  60.       case WM_NOTIFICATION_CLICKED:
  61.         // USER START (Optionally insert code for reacting on notification message)
  62.         // USER END
  63.         break;
  64.       case WM_NOTIFICATION_RELEASED:
  65.         // USER START (Optionally insert code for reacting on notification message)
  66.         // USER END
  67.         break;
  68.       // USER START (Optionally insert additional code for further notification handling)
  69.       // USER END
  70.       }
  71.       break;
  72.     // USER START (Optionally insert additional code for further Ids)
  73.     // USER END
  74.     }
  75.     break;
  76.   default:
  77.     WM_DefaultProc(pMsg);
  78.     break;
  79.   }
  80. }
  81. /*********************************************************************
  82. *
  83. *       CreateWindowPage1
  84. */
  85. WM_HWIN CreateWindowPage1(void) {
  86.   WM_HWIN hWin;
  87.   hWin = GUI_CreateDialogBox(_aDialogCreatePage1, GUI_COUNTOF(_aDialogCreatePage1), _cbDialogPage1, WM_HBKWIN, 0, 0);
  88.   return hWin;
  89. }
  90. /*
  91. ************************************************************************************************
  92. *                             添加到多页控件第二个页面窗口的对话框
  93. ************************************************************************************************
  94. */
  95. /*********************************************************************
  96. *
  97. *       Defines
  98. *
  99. **********************************************************************
  100. */
  101. #define ID_WINDOW_02 (GUI_ID_USER + 0x20)
  102. #define ID_BUTTON_02 (GUI_ID_USER + 0x21)
  103. // USER START (Optionally insert additional static data)
  104. // USER END
  105. /*********************************************************************
  106. *
  107. *       _aDialogCreate
  108. */
  109. static const GUI_WIDGET_CREATE_INFO _aDialogCreatePage2[] = {
  110.   { WINDOW_CreateIndirect, "Window", ID_WINDOW_02, 0, 0, 400, 200, 0, 0x0, 0 },
  111.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_02, 127, 68, 129, 43, 0, 0x0, 0 },
  112. };
  113. /*********************************************************************
  114. *
  115. *       Static code
  116. *
  117. **********************************************************************
  118. */
  119. // USER START (Optionally insert additional static code)
  120. // USER END
  121. /*********************************************************************
  122. *
  123. *       _cbDialog
  124. */
  125. static void _cbDialogPage2(WM_MESSAGE * pMsg) {
  126.   WM_HWIN hItem;
  127.   int     NCode;
  128.   int     Id;
  129.   // USER START (Optionally insert additional variables)
  130.   // USER END
  131.   switch (pMsg->MsgId) {
  132.   case WM_INIT_DIALOG:
  133.     //
  134.     // Initialization of 'Button'
  135.     //
  136.     hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_02);
  137.     BUTTON_SetFont(hItem, GUI_FONT_16B_ASCII);
  138.     BUTTON_SetText(hItem, "Page2");
  139.     // USER START (Optionally insert additional code for further widget initialization)
  140.     // USER END
  141.     break;
  142.   case WM_NOTIFY_PARENT:
  143.     Id    = WM_GetId(pMsg->hWinSrc);
  144.     NCode = pMsg->Data.v;
  145.     switch(Id) {
  146.     case ID_BUTTON_02: // Notifications sent by 'Button'
  147.       switch(NCode) {
  148.       case WM_NOTIFICATION_CLICKED:
  149.         // USER START (Optionally insert code for reacting on notification message)
  150.         // USER END
  151.         break;
  152.       case WM_NOTIFICATION_RELEASED:
  153.         // USER START (Optionally insert code for reacting on notification message)
  154.         // USER END
  155.         break;
  156.       // USER START (Optionally insert additional code for further notification handling)
  157.       // USER END
  158.       }
  159.       break;
  160.     // USER START (Optionally insert additional code for further Ids)
  161.     // USER END
  162.     }
  163.     break;
  164.   default:
  165.     WM_DefaultProc(pMsg);
  166.     break;
  167.   }
  168. }
  169. /*********************************************************************
  170. *
  171. *       CreateWindowPage2
  172. */
  173. WM_HWIN CreateWindowPage2(void) {
  174.   WM_HWIN hWin;
  175.   hWin = GUI_CreateDialogBox(_aDialogCreatePage2, GUI_COUNTOF(_aDialogCreatePage2), _cbDialogPage2, WM_HBKWIN, 0, 0);
  176.   return hWin;
  177. }
  178. /*
  179. ************************************************************************************************
  180. *                             添加到多页控件第三个页面窗口的对话框
  181. ************************************************************************************************
  182. */
  183. /*********************************************************************
  184. *
  185. *       Defines
  186. *
  187. **********************************************************************
  188. */
  189. #define ID_WINDOW_03 (GUI_ID_USER + 0x30)
  190. #define ID_BUTTON_03 (GUI_ID_USER + 0x31)
  191. // USER START (Optionally insert additional static data)
  192. // USER END
  193. /*********************************************************************
  194. *
  195. *       _aDialogCreate
  196. */
  197. static const GUI_WIDGET_CREATE_INFO _aDialogCreatePage3[] = {
  198.   { WINDOW_CreateIndirect, "Window", ID_WINDOW_03, 0, 0, 400, 200, 0, 0x0, 0 },
  199.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_03, 127, 68, 129, 43, 0, 0x0, 0 },
  200. };
  201. /*********************************************************************
  202. *
  203. *       Static code
  204. *
  205. **********************************************************************
  206. */
  207. // USER START (Optionally insert additional static code)
  208. // USER END
  209. /*********************************************************************
  210. *
  211. *       _cbDialog
  212. */
  213. static void _cbDialogPage3(WM_MESSAGE * pMsg) {
  214.   WM_HWIN hItem;
  215.   int     NCode;
  216.   int     Id;
  217.   // USER START (Optionally insert additional variables)
  218.   // USER END
  219.   switch (pMsg->MsgId) {
  220.   case WM_INIT_DIALOG:
  221.     //
  222.     // Initialization of 'Button'
  223.     //
  224.     hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_03);
  225.     BUTTON_SetFont(hItem, GUI_FONT_16B_ASCII);
  226.     BUTTON_SetText(hItem, "Page3");
  227.     // USER START (Optionally insert additional code for further widget initialization)
  228.     // USER END
  229.     break;
  230.   case WM_NOTIFY_PARENT:
  231.     Id    = WM_GetId(pMsg->hWinSrc);
  232.     NCode = pMsg->Data.v;
  233.     switch(Id) {
  234.     case ID_BUTTON_03: // Notifications sent by 'Button'
  235.       switch(NCode) {
  236.       case WM_NOTIFICATION_CLICKED:
  237.         // USER START (Optionally insert code for reacting on notification message)
  238.         // USER END
  239.         break;
  240.       case WM_NOTIFICATION_RELEASED:
  241.         // USER START (Optionally insert code for reacting on notification message)
  242.         // USER END
  243.         break;
  244.       // USER START (Optionally insert additional code for further notification handling)
  245.       // USER END
  246.       }
  247.       break;
  248.     // USER START (Optionally insert additional code for further Ids)
  249.     // USER END
  250.     }
  251.     break;
  252.   default:
  253.     WM_DefaultProc(pMsg);
  254.     break;
  255.   }
  256. }
  257. /*********************************************************************
  258. *
  259. *       CreateWindowPage3
  260. */
  261. WM_HWIN CreateWindowPage3(void) {
  262.   WM_HWIN hWin;
  263.   hWin = GUI_CreateDialogBox(_aDialogCreatePage3, GUI_COUNTOF(_aDialogCreatePage3), _cbDialogPage3, WM_HBKWIN, 0, 0);
  264.   return hWin;
  265. }
  266. /*********************************************************************
  267. *
  268. *       Defines
  269. *
  270. **********************************************************************
  271. */
  272. #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
  273. #define ID_MULTIPAGE_0 (GUI_ID_USER + 0x01)
  274. // USER START (Optionally insert additional defines)
  275. // USER END
  276. /*********************************************************************
  277. *
  278. *       Static data
  279. *
  280. **********************************************************************
  281. */
  282. // USER START (Optionally insert additional static data)
  283. // USER END
  284. /*********************************************************************
  285. *
  286. *       _aDialogCreate
  287. */
  288. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  289.   { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0x0, 0 },
  290.   { MULTIPAGE_CreateIndirect, "Multipage", ID_MULTIPAGE_0, 23, 25, 400, 240, 0, 0x0, 0 },
  291.   // USER START (Optionally insert additional widgets)
  292.   // USER END
  293. };
  294. /*********************************************************************
  295. *
  296. *       Static code
  297. *
  298. **********************************************************************
  299. */
  300. // USER START (Optionally insert additional static code)
  301. // USER END
  302. /*********************************************************************
  303. *
  304. *       _cbDialog
  305. */
  306. static void _cbDialog(WM_MESSAGE * pMsg) {
  307.   WM_HWIN hItem;
  308.   WM_HWIN hWinPage;
  309.   int     NCode;
  310.   int     Id;
  311.   // USER START (Optionally insert additional variables)
  312.   // USER END
  313.   switch (pMsg->MsgId) {
  314.   case WM_INIT_DIALOG:
  315.     //
  316.     // Initialization of 'Framewin'
  317.     //
  318.     hItem = pMsg->hWin;
  319.     FRAMEWIN_SetFont(hItem, GUI_FONT_32B_ASCII);
  320.     FRAMEWIN_SetText(hItem, "armfly");
  321.     FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
  322.     //
  323.     // Initialization of 'Multipage'
  324.     //
  325.     hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);
  326.     MULTIPAGE_SetFont(hItem, GUI_FONT_16_ASCII);
  327.     MULTIPAGE_SetTabHeight(hItem, 40);
  328.     hWinPage = CreateWindowPage1();
  329.     MULTIPAGE_AddEmptyPage(hItem, hWinPage, "STM32-V4");
  330.     MULTIPAGE_SetTabWidth(hItem, 100, 0);
  331.     hWinPage = CreateWindowPage2();
  332.     MULTIPAGE_AddEmptyPage(hItem, hWinPage, "STM32-V5");
  333.     MULTIPAGE_SetTabWidth(hItem, 120, 1);
  334.     hWinPage = CreateWindowPage3();
  335.     MULTIPAGE_AddEmptyPage(hItem, hWinPage, "STM32-V6");
  336.     MULTIPAGE_SetTabWidth(hItem, 150, 2);
  337.     // USER START (Optionally insert additional code for further widget initialization)
  338.     // USER END
  339.     break;
  340.   case WM_NOTIFY_PARENT:
  341.     Id    = WM_GetId(pMsg->hWinSrc);
  342.     NCode = pMsg->Data.v;
  343.     switch(Id) {
  344.     case ID_MULTIPAGE_0: // Notifications sent by 'Multipage'
  345.       switch(NCode) {
  346.       case WM_NOTIFICATION_CLICKED:
  347.         // USER START (Optionally insert code for reacting on notification message)
  348.         // USER END
  349.         break;
  350.       case WM_NOTIFICATION_RELEASED:
  351.         // USER START (Optionally insert code for reacting on notification message)
  352.         // USER END
  353.         break;
  354.       case WM_NOTIFICATION_MOVED_OUT:
  355.         // USER START (Optionally insert code for reacting on notification message)
  356.         // USER END
  357.         break;
  358.       case WM_NOTIFICATION_VALUE_CHANGED:
  359.         // USER START (Optionally insert code for reacting on notification message)
  360.         // USER END
  361.         break;
  362.       // USER START (Optionally insert additional code for further notification handling)
  363.       // USER END
  364.       }
  365.       break;
  366.     // USER START (Optionally insert additional code for further Ids)
  367.     // USER END
  368.     }
  369.     break;
  370.   // USER START (Optionally insert additional message handling)
  371.   // USER END
  372.   default:
  373.     WM_DefaultProc(pMsg);
  374.     break;
  375.   }
  376. }
  377. /*********************************************************************
  378. *
  379. *       Public code
  380. *
  381. **********************************************************************
  382. */
  383. /*********************************************************************
  384. *
  385. *       CreateFramewin
  386. */
  387. WM_HWIN CreateFramewin(void);
  388. WM_HWIN CreateFramewin(void) {
  389.   WM_HWIN hWin;
  390.   hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  391.   return hWin;
  392. }
  393. // USER START (Optionally insert additional public code)
  394. // USER END
  395. /*************************** End of file ****************************/
  396. /*********************************************************************
  397. *
  398. *       MainTask
  399. */
  400. void MainTask(void)
  401. {
  402.      /* 初始化 */
  403.     GUI_Init();
  404.     /* 窗口自动使用存储设备 */
  405.     WM_SetCreateFlags(WM_CF_MEMDEV);
  406.     /* 创建对话框,使用GUIBulder5.32生成的对话框创建函数 */
  407.     CreateFramewin();
  408.     while(1)
  409.     {
  410.         GUI_Delay(50);
  411.     }
  412. }
复制代码
回复

使用道具 举报

14

主题

78

回帖

120

积分

初级会员

积分
120
发表于 2017-6-22 10:20:40 | 显示全部楼层
我在板上试了,MULTIPAGE_SetTabHeight能改变高度,
MULTIPAGE_SetTabWidth不能改变宽度。

用的是emwin526,是否版本太低?
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117586
QQ
 楼主| 发表于 2017-6-22 14:52:57 | 显示全部楼层

回 mcza30 的帖子

mcza30:我在板上试了,MULTIPAGE_SetTabHeight能改变高度,
MULTIPAGE_SetTabWidth不能改变宽度。

用的是emwin526,是否版本太低? (2017-06-22 10:20) 
专门测试了下,模拟器上面也是一样的,宽度不可设置的话,用显示空格代替吧
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117586
QQ
 楼主| 发表于 2017-6-22 15:00:06 | 显示全部楼层
重新测试了下,解决了,注意下面问题即可:
QQ截图20170622145653.png

QQ截图20170622145726.png
回复

使用道具 举报

14

主题

78

回帖

120

积分

初级会员

积分
120
发表于 2017-6-22 17:50:57 | 显示全部楼层
[s:151] [s:151] [s:151]
回复

使用道具 举报

12

主题

33

回帖

69

积分

初级会员

积分
69
发表于 2017-7-11 23:59:33 | 显示全部楼层
[s:151]  [s:151]  [s:151]  [s:151]
回复

使用道具 举报

2

主题

14

回帖

20

积分

新手上路

积分
20
发表于 2017-7-12 08:31:55 | 显示全部楼层
QQ图片20170712082342.png QQ图片20170712082254.png
楼主!想问下,左右显示的时候只能是垂直排列吧?我想要实现字是水平排列的左边显示有没有方法呢?
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117586
QQ
 楼主| 发表于 2017-7-12 10:20:58 | 显示全部楼层

回 47小白羊 的帖子

47小白羊:
楼主!想问下,左右显示的时候只能是垂直排列吧?我想要实现字是水平排列的左边显示有没有方法呢?
 (2017-07-12 08:31) 
应该不支持。
回复

使用道具 举报

45

主题

45

回帖

45

积分

初级会员

积分
45
发表于 2017-8-11 10:42:57 | 显示全部楼层

回 eric2013 的帖子

eric2013:应该不支持。 (2017-07-12 10:20) 
每次打开第一个页面是STM32-V6,为什么不是STM32-V4呢?
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117586
QQ
 楼主| 发表于 2017-8-11 11:17:27 | 显示全部楼层

回 pengzisheng 的帖子

pengzisheng:每次打开第一个页面是STM32-V6,为什么不是STM32-V4呢? (2017-08-11 10:42)
这个是默认的,显示最后一个。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-17 04:11 , Processed in 0.052552 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表