|
listview上带了一个header控件,为了实现定时更新,需要用户调用窗口无效化才会起作用。
测试代码:
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.32 *
- * Compiled Oct 8 2015, 11:59:02 *
- * (c) 2015 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- // USER END
- #include "DIALOG.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
- #define ID_LISTVIEW_0 (GUI_ID_USER + 0x01)
- // USER START (Optionally insert additional defines)
- // USER END
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0x64, 0 },
- { LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 33, 21, 298, 158, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- int NCode;
- int Id;
- static int i = 0;
- char buf[100];
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Framewin'
- //
- hItem = pMsg->hWin;
- FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- FRAMEWIN_SetFont(hItem, GUI_FONT_32B_ASCII);
- FRAMEWIN_SetText(hItem, "armfly");
- //
- // Initialization of 'Listview'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
- LISTVIEW_AddColumn(hItem, 60, "STM32-V3", GUI_TA_HCENTER | GUI_TA_VCENTER);
- LISTVIEW_AddColumn(hItem, 60, "STM32-V4", GUI_TA_HCENTER | GUI_TA_VCENTER);
- LISTVIEW_AddColumn(hItem, 60, "STM32-V5", GUI_TA_HCENTER | GUI_TA_VCENTER);
- LISTVIEW_AddRow(hItem, NULL);
- LISTVIEW_SetGridVis(hItem, 1);
- LISTVIEW_AddColumn(hItem, 60, "STM32-V6", GUI_TA_HCENTER | GUI_TA_VCENTER);
- LISTVIEW_AddRow(hItem, NULL);
- LISTVIEW_AddRow(hItem, NULL);
- LISTVIEW_SetItemText(hItem, 0, 0, "A00");
- LISTVIEW_SetFont(hItem, GUI_FONT_16_ASCII);
- LISTVIEW_SetItemText(hItem, 1, 0, "A01");
- LISTVIEW_SetItemText(hItem, 2, 0, "A02");
- LISTVIEW_SetItemText(hItem, 3, 0, "A03");
- LISTVIEW_SetItemText(hItem, 0, 1, "B10");
- LISTVIEW_SetItemText(hItem, 1, 1, "B11");
- LISTVIEW_SetItemText(hItem, 2, 1, "B12");
- LISTVIEW_SetItemText(hItem, 3, 1, "B13");
- LISTVIEW_SetItemText(hItem, 0, 2, "C20");
- LISTVIEW_SetItemText(hItem, 1, 2, "C21");
- LISTVIEW_SetItemText(hItem, 2, 2, "C22");
- LISTVIEW_SetItemText(hItem, 3, 2, "C23");
- // USER START (Optionally insert additional code for further widget initialization)
- // USER END
- break;
- case WM_TIMER:
- hItem = LISTVIEW_GetHeader(WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0));
- sprintf(buf, "%d", i++);
- HEADER_SetItemText(hItem, 1, buf);
- WM_InvalidateWindow(hItem);
- WM_RestartTimer(pMsg->Data.v, 100);
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_LISTVIEW_0: // Notifications sent by 'Listview'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_SEL_CHANGED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- // USER START (Optionally insert additional public code)
- // USER END
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void)
- {
- WM_HWIN hDlg;
- WM_HTIMER hTimer;
- /* 初始化 */
- GUI_Init();
- /* 窗口自动使用存储设备 */
- WM_SetCreateFlags(WM_CF_MEMDEV);
- /* 创建对话框,使用GUIBulder5.32生成的对话框创建函数 */
- hDlg = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- /* 给对话框hDlg创建定时器,溢出时间是100ms */
- hTimer = WM_CreateTimer(WM_GetClientWindow(hDlg), 0, 100, 0);
- while(1)
- {
- GUI_Delay(50);
- }
- }
复制代码
|
|