硬汉嵌入式论坛

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

[emWin] 为什么我的emwin的edit显示不正常,鼠标划过才变成白色,内容才能正常显示。

[复制链接]

2

主题

3

回帖

9

积分

新手上路

积分
9
发表于 2017-12-5 20:24:23 | 显示全部楼层 |阅读模式
QQ图片20171204220756.jpg


来个大神帮看看吧,我发现不管是edit还是什么,只要是可以显示文本的都是黑色的,比如还有上下可以调数值的,也是黑色。。。。。
但是button按钮,滑块这种就是正常的。


  1. #include "DIALOG.h"
  2. #include "FramewinDLG.h"
  3. /*********************************************************************
  4. *
  5. *       Defines
  6. *
  7. **********************************************************************
  8. */
  9. #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
  10. #define ID_EDIT_0 (GUI_ID_USER + 0x01)
  11. #define ID_EDIT_1 (GUI_ID_USER + 0x02)
  12. #define ID_EDIT_2 (GUI_ID_USER + 0x06)
  13. #define ID_BUTTON_0 (GUI_ID_USER + 0x07)
  14. #define ID_BUTTON_1 (GUI_ID_USER + 0x08)
  15. #define ID_CHECKBOX_0 (GUI_ID_USER + 0x09)
  16. #define ID_TEXT_0 (GUI_ID_USER + 0x0A)
  17. #define ID_SLIDER_0 (GUI_ID_USER + 0x0B)
  18. #define ID_SPINBOX_0 (GUI_ID_USER + 0x0C)
  19. #define ID_MULTIEDIT_0 (GUI_ID_USER + 0x0D)
  20. #define ID_PROGBAR_0 (GUI_ID_USER + 0x0E)
  21. #define ID_BUTTON_2 (GUI_ID_USER + 0x10)
  22. // USER START (Optionally insert additional defines)
  23. // USER END
  24. /*********************************************************************
  25. *
  26. *       Static data
  27. *
  28. **********************************************************************
  29. */
  30. // USER START (Optionally insert additional static data)
  31. // USER END
  32. /*********************************************************************
  33. *
  34. *       _aDialogCreate
  35. */
  36. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  37.   { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 854, 480, 0, 0x0, 0 },
  38.   { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 719, 17, 80, 20, 0, 0x64, 0 },
  39.   { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 717, 48, 80, 20, 0, 0x64, 0 },
  40.   { EDIT_CreateIndirect, "Edit", ID_EDIT_2, 720, 79, 80, 20, 0, 0x64, 0 },
  41.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 694, 160, 80, 20, 0, 0x0, 0 },
  42.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 701, 200, 80, 20, 0, 0x0, 0 },
  43.   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 711, 248, 80, 20, 0, 0x0, 0 },
  44.   { TEXT_CreateIndirect, "Text", ID_TEXT_0, 594, 30, 80, 20, 0, 0x0, 0 },
  45.   { SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 697, 305, 80, 20, 0, 0x0, 0 },
  46.   { SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_0, 692, 364, 80, 20, 0, 0x0, 0 },
  47.   { MULTIEDIT_CreateIndirect, "Multiedit", ID_MULTIEDIT_0, 607, 347, 55, 35, 0, 0x0, 0 },
  48.   { PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_0, 745, 405, 80, 20, 0, 0x0, 0 },
  49.   { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 749, 433, 80, 20, 0, 0x0, 0 },
  50.   // USER START (Optionally insert additional widgets)
  51.   // USER END
  52. };
  53. /*********************************************************************
  54. *
  55. *       Static code
  56. *
  57. **********************************************************************
  58. */
  59. // USER START (Optionally insert additional static code)
  60. // USER END
  61. /*********************************************************************
  62. *
  63. *       _cbDialog
  64. */
  65. static void _cbDialog(WM_MESSAGE * pMsg) {
  66.   WM_HWIN hItem;
  67.   int     NCode;
  68.   int     Id;
  69.   // USER START (Optionally insert additional variables)
  70.   // USER END
  71.   switch (pMsg->MsgId) {
  72.   case WM_INIT_DIALOG:
  73.     //
  74.     // Initialization of 'Edit'
  75.     //
  76.     hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
  77.     EDIT_SetText(hItem, "123");
  78.     //
  79.     // Initialization of 'Edit'
  80.     //
  81.     hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
  82.     EDIT_SetText(hItem, "123");
  83.     //
  84.     // Initialization of 'Edit'
  85.     //
  86.     hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
  87.     EDIT_SetText(hItem, "123");
  88.     //
  89.     // Initialization of 'Checkbox'
  90.     //
  91.     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
  92.     CHECKBOX_SetText(hItem, "Check");
  93.     //
  94.     // Initialization of 'Multiedit'
  95.     //
  96.     hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
  97.     MULTIEDIT_SetText(hItem, "Multiedit");
  98.     // USER START (Optionally insert additional code for further widget initialization)
  99.     // USER END
  100.     break;
  101.   case WM_NOTIFY_PARENT:
  102.     Id    = WM_GetId(pMsg->hWinSrc);
  103.     NCode = pMsg->Data.v;
  104.     switch(Id) {
  105.     case ID_EDIT_0: // Notifications sent by 'Edit'
  106.       switch(NCode) {
  107.       case WM_NOTIFICATION_CLICKED:
  108.         // USER START (Optionally insert code for reacting on notification message)
  109.         // USER END
  110.         break;
  111.       case WM_NOTIFICATION_RELEASED:
  112.         // USER START (Optionally insert code for reacting on notification message)
  113.         // USER END
  114.         break;
  115.       case WM_NOTIFICATION_VALUE_CHANGED:
  116.         // USER START (Optionally insert code for reacting on notification message)
  117.         // USER END
  118.         break;
  119.       // USER START (Optionally insert additional code for further notification handling)
  120.       // USER END
  121.       }
  122.       break;
  123.     case ID_EDIT_1: // Notifications sent by 'Edit'
  124.       switch(NCode) {
  125.       case WM_NOTIFICATION_CLICKED:
  126.         // USER START (Optionally insert code for reacting on notification message)
  127.         // USER END
  128.         break;
  129.       case WM_NOTIFICATION_RELEASED:
  130.         // USER START (Optionally insert code for reacting on notification message)
  131.         // USER END
  132.         break;
  133.       case WM_NOTIFICATION_VALUE_CHANGED:
  134.         // USER START (Optionally insert code for reacting on notification message)
  135.         // USER END
  136.         break;
  137.       // USER START (Optionally insert additional code for further notification handling)
  138.       // USER END
  139.       }
  140.       break;
  141.     case ID_EDIT_2: // Notifications sent by 'Edit'
  142.       switch(NCode) {
  143.       case WM_NOTIFICATION_CLICKED:
  144.         // USER START (Optionally insert code for reacting on notification message)
  145.         // USER END
  146.         break;
  147.       case WM_NOTIFICATION_RELEASED:
  148.         // USER START (Optionally insert code for reacting on notification message)
  149.         // USER END
  150.         break;
  151.       case WM_NOTIFICATION_VALUE_CHANGED:
  152.         // USER START (Optionally insert code for reacting on notification message)
  153.         // USER END
  154.         break;
  155.       // USER START (Optionally insert additional code for further notification handling)
  156.       // USER END
  157.       }
  158.       break;
  159.     case ID_BUTTON_0: // Notifications sent by 'Button'
  160.       switch(NCode) {
  161.       case WM_NOTIFICATION_CLICKED:
  162.         // USER START (Optionally insert code for reacting on notification message)
  163.         // USER END
  164.         break;
  165.       case WM_NOTIFICATION_RELEASED:
  166.         // USER START (Optionally insert code for reacting on notification message)
  167.         // USER END
  168.         break;
  169.       // USER START (Optionally insert additional code for further notification handling)
  170.       // USER END
  171.       }
  172.       break;
  173.     case ID_BUTTON_1: // Notifications sent by 'Button'
  174.       switch(NCode) {
  175.       case WM_NOTIFICATION_CLICKED:
  176.         // USER START (Optionally insert code for reacting on notification message)
  177.         // USER END
  178.         break;
  179.       case WM_NOTIFICATION_RELEASED:
  180.         // USER START (Optionally insert code for reacting on notification message)
  181.         // USER END
  182.         break;
  183.       // USER START (Optionally insert additional code for further notification handling)
  184.       // USER END
  185.       }
  186.       break;
  187.     case ID_CHECKBOX_0: // Notifications sent by 'Checkbox'
  188.       switch(NCode) {
  189.       case WM_NOTIFICATION_CLICKED:
  190.         // USER START (Optionally insert code for reacting on notification message)
  191.         // USER END
  192.         break;
  193.       case WM_NOTIFICATION_RELEASED:
  194.         // USER START (Optionally insert code for reacting on notification message)
  195.         // USER END
  196.         break;
  197.       case WM_NOTIFICATION_VALUE_CHANGED:
  198.         // USER START (Optionally insert code for reacting on notification message)
  199.         // USER END
  200.         break;
  201.       // USER START (Optionally insert additional code for further notification handling)
  202.       // USER END
  203.       }
  204.       break;
  205.     case ID_SLIDER_0: // Notifications sent by 'Slider'
  206.       switch(NCode) {
  207.       case WM_NOTIFICATION_CLICKED:
  208.         // USER START (Optionally insert code for reacting on notification message)
  209.         // USER END
  210.         break;
  211.       case WM_NOTIFICATION_RELEASED:
  212.         // USER START (Optionally insert code for reacting on notification message)
  213.         // USER END
  214.         break;
  215.       case WM_NOTIFICATION_VALUE_CHANGED:
  216.         // USER START (Optionally insert code for reacting on notification message)
  217.         // USER END
  218.         break;
  219.       // USER START (Optionally insert additional code for further notification handling)
  220.       // USER END
  221.       }
  222.       break;
  223.     case ID_SPINBOX_0: // Notifications sent by 'Spinbox'
  224.       switch(NCode) {
  225.       case WM_NOTIFICATION_CLICKED:
  226.         // USER START (Optionally insert code for reacting on notification message)
  227.         // USER END
  228.         break;
  229.       case WM_NOTIFICATION_RELEASED:
  230.         // USER START (Optionally insert code for reacting on notification message)
  231.         // USER END
  232.         break;
  233.       case WM_NOTIFICATION_MOVED_OUT:
  234.         // USER START (Optionally insert code for reacting on notification message)
  235.         // USER END
  236.         break;
  237.       case WM_NOTIFICATION_VALUE_CHANGED:
  238.         // USER START (Optionally insert code for reacting on notification message)
  239.         // USER END
  240.         break;
  241.       // USER START (Optionally insert additional code for further notification handling)
  242.       // USER END
  243.       }
  244.       break;
  245.     case ID_MULTIEDIT_0: // Notifications sent by 'Multiedit'
  246.       switch(NCode) {
  247.       case WM_NOTIFICATION_CLICKED:
  248.         // USER START (Optionally insert code for reacting on notification message)
  249.         // USER END
  250.         break;
  251.       case WM_NOTIFICATION_RELEASED:
  252.         // USER START (Optionally insert code for reacting on notification message)
  253.         // USER END
  254.         break;
  255.       case WM_NOTIFICATION_VALUE_CHANGED:
  256.         // USER START (Optionally insert code for reacting on notification message)
  257.         // USER END
  258.         break;
  259.       // USER START (Optionally insert additional code for further notification handling)
  260.       // USER END
  261.       }
  262.       break;
  263.     case ID_BUTTON_2: // Notifications sent by 'Button'
  264.       switch(NCode) {
  265.       case WM_NOTIFICATION_CLICKED:
  266.         // USER START (Optionally insert code for reacting on notification message)
  267.         // USER END
  268.         break;
  269.       case WM_NOTIFICATION_RELEASED:
  270.         // USER START (Optionally insert code for reacting on notification message)
  271.         // USER END
  272.         break;
  273.       // USER START (Optionally insert additional code for further notification handling)
  274.       // USER END
  275.       }
  276.       break;
  277.     // USER START (Optionally insert additional code for further Ids)
  278.     // USER END
  279.     }
  280.     break;
  281.   // USER START (Optionally insert additional message handling)
  282.   // USER END
  283.   default:
  284.     WM_DefaultProc(pMsg);
  285.     break;
  286.   }
  287. }
  288. /*********************************************************************
  289. *
  290. *       Public code
  291. *
  292. **********************************************************************
  293. */
  294. /*********************************************************************
  295. *
  296. *       CreateFramewin
  297. */
  298. WM_HWIN CreateFramewin(void);
  299. WM_HWIN CreateFramewin(void) {
  300.   WM_HWIN hWin;
  301.   hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  302.   return hWin;
  303. }
  304. // USER START (Optionally insert additional public code)
  305. // USER END
  306. /*************************** End of file ****************************/
  307. void MainTask(void) {
  308.   GUI_Init();
  309.      WM_SetCreateFlags(WM_CF_MEMDEV);
  310.   while(1) {
  311.     CreateFramewin();
  312.         GUI_Delay(10);
  313.         GUI_Exec();
  314.   }
  315. }
复制代码
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115749
QQ
发表于 2017-12-6 01:38:47 | 显示全部楼层
先将函数CreateFramewin();放在while循环外面调用,这个函数仅需要调用一次即可。
另外就是GUI_Delay,GUI_Exec或者WM_Exec调用一个就可以了,一般我们都调用GUI_Delay,因为此函数除了延迟的作用,内部也调用GUI_Exec。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-16 05:21 , Processed in 0.227397 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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