|

楼主 |
发表于 2020-2-25 15:50:53
|
显示全部楼层
Update:
使用WM_TIMER定时器,也是一样的问题。
完整代码:
- #include "DIALOG.h"
- #include <time.h>
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- #define ID_EDIT_0 (GUI_ID_USER + 0x01)
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 170, 1024, 528, 0, 0x0, 0 },
- { EDIT_CreateIndirect, "EDIT", ID_EDIT_0, 10, 20, 100, 40, 0, 0x0, 0 },
- };
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- int NCode;
- int Id;
- char buf[50];
- switch (pMsg->MsgId) {
- case WM_TIMER:
- {
- time_t now = time(NULL);
- struct tm *time;
- time = localtime(&now);
- sprintf(buf, "%04d/%02d/%02d %02d:%02d:%02d", time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
- GUI_SetColor(GUI_RED);
- GUI_DispStringAt(buf, 790, 738);
- }
- WM_RestartTimer(pMsg->Data.v, 1000);
- break;
- case WM_INIT_DIALOG:
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
-
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- EDIT_SetText(hItem, "");
- EDIT_EnableBlink(hItem, 500, 1);
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch (Id) {
- case ID_EDIT_0:
- switch (NCode) {
- case WM_NOTIFICATION_CLICKED:
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- break;
- case WM_NOTIFICATION_RELEASED:
- break;
- case WM_NOTIFICATION_SEL_CHANGED:
- break;
-
- }
- break;
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- WM_HWIN CreateMainWindow(void);
- WM_HWIN CreateMainWindow(void) {
- WM_HWIN hWin;
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- return hWin;
- }
- void MainTask(void) {
- char buf[50];
- GUI_Init();
- if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
- GUI_ErrorOut("Not enough memory available.");
- return;
- }
- //WM_EnableMemdev(WM_HBKWIN);
- WM_SetCreateFlags(WM_CF_MEMDEV);
- GUI_UC_SetEncodeUTF8();
- WM_HWIN hMainWin;
- hMainWin = CreateMainWindow();
- WM_EnableMemdev(hMainWin);
- WM_SetCallback(WM_HBKWIN, _cbDialog);
- WM_CreateTimer(WM_HBKWIN, 0, 1000, 0);
- while (1) {
- GUI_Delay(1000);
-
- }
- }
复制代码 |
|