Hello.
I think there is a bug in the LISTVIEW_GetSelUnsorted function when this function is called while there is no Row in the list view.
I am using Emwin 5.32
If I call this line :
sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));
before adding a row, I got a crash in _LISTVIEW_SetSort
BUT if I call this line after a Adding a row All is OK.
Note, that if I don't call LISTVIEW_SetSort(hItem,1,1);
It will work ...
here is my code :
Display All
I think there is a bug in the LISTVIEW_GetSelUnsorted function when this function is called while there is no Row in the list view.
I am using Emwin 5.32
If I call this line :
sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));
before adding a row, I got a crash in _LISTVIEW_SetSort
BUT if I call this line after a Adding a row All is OK.
Note, that if I don't call LISTVIEW_SetSort(hItem,1,1);
It will work ...
here is my code :
C Source Code
- static const GUI_WIDGET_CREATE_INFO _aListJob[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 },
- { LISTVIEW_CreateIndirect, "Listview", GUI_ID_LISTVIEW0, 8, 85, 787, 300, 0, 0x0, 0 },
- };
- static void _cbDialogListJob(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTVIEW0);
- LISTVIEW_AddColumn(hItem, 2, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
- LISTVIEW_AddColumn(hItem, 220, "Nom", GUI_TA_LEFT | GUI_TA_TOP);
- LISTVIEW_AddColumn(hItem, 395, "Description", GUI_TA_LEFT | GUI_TA_TOP);
- LISTVIEW_AddColumn(hItem, 155, "Date", GUI_TA_LEFT | GUI_TA_TOP);
- LISTVIEW_SetCompareFunc(hItem, 0, LISTVIEW_CompareDec);
- LISTVIEW_SetCompareFunc(hItem, 1, LISTVIEW_CompareText);
- LISTVIEW_SetCompareFunc(hItem, 3, LISTVIEW_CompareText);
- LISTVIEW_SetSort(hItem,1,1);
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- void MainTask(void) {
- WM_HWIN v_hwin;
- int sel;
- static const char * _aTable_1[][4] = {
- {"1", "A", "Info 1", "07/07/2017\n14:33"},
- {"3", "E", "Info 2", "06/08/2017\n15:33" },
- {"5", "B", "Info 3", "06/10/2017\n14:40" },
- { "15","Z", "Info 4", "06/07/2016\n14:40" },
- { "18","I", "Info 5", "24/07/2017\n14:58" },
- { "20","A", "Info 6", "31/12/2017\n14:12" },
- { "21","C", "Info 7", "06/07/2017\n23:33" },
- { "32","F", "Info 8", "06/07/2013\n14:33" },
- };
- GUI_Init(); // Initialize the GUI
- WM_SetBkWindowColor(GUI_WHITE); // Set a default background color
- GUI_Clear();
- v_hwin = GUI_CreateDialogBox(_aListJob, GUI_COUNTOF(_aListJob), _cbDialogListJob, WM_HBKWIN, 0, 0);
- GUI_Delay(1000);
- sel = LISTVIEW_GetSelUnsorted(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0));
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+4);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+8);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+12);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+16);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+20);
- GUI_Delay(1000);
- LISTVIEW_AddRow(WM_GetDialogItem(v_hwin, GUI_ID_LISTVIEW0),(const GUI_ConstString *)_aTable_1+24);
- GUI_Delay(1000);
- do
- {
- GUI_Delay(1000);
- }while(1);
- }