How to delete a SWIPELIST

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to delete a SWIPELIST

    Good morning,
    I'm using emWin library ver.5.32 on STM32F746 and it works very well.
    Now I'm trying to use the new SWIPELIST function but when I go back to the previous menu (ie destroing the page) the system crash with a MEMFAULT.
    Could You explain me the correct sequence to destroy the swipelist?
    Here attached my code.
    Thank a lot in advance!
    Simone

    Brainfuck Source Code

    1. /* Includes ------------------------------------------------------------------*/#include "gui_main.h"#include "BUTTON.h"#include "win.h"#include "main.h"
    2. /*********************************************************************** Defines************************************************************************/#define ID_WINDOW_0 (GUI_ID_USER + 0x00)#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
    3. #define GUI_ID_SPINBOX_BACKLIGHT (GUI_ID_USER + 0x40)
    4. /*********************************************************************** _aDialogCreate*/static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { WINDOW_CreateIndirect, "AdminMain", ID_WINDOW_0, 0, 0, 800, 400, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "", ID_BUTTON_0, 680, 15, 70, 70, 0, 0x0, 0 }, //"BtnBack"// { SWIPELIST_CreateIndirect, "Swipe1", GUI_ID_SWIPELIST0, 100, 90, 540, 300, 0 },};
    5. #define SWIPE0_ITEMS 7 // Number of available items#define SWIPE0_SEPARATORS 1
    6. static const char * paItemText[SWIPE0_SEPARATORS][SWIPE0_ITEMS] = { { "Language", "Backlight", "Stand-by", "Sound", "Voice", "Board code", "Other", },};//// Information about the separators//static const char * paSeperatorText[] = { "General",};
    7. WM_HMEM hSwipelist;
    8. /*********************************************************************** _cbDialog*/static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; //WM_HMEM hSwipelist; uint16_t i,j; int Id, NCode;
    9. switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_TRANSPARENT);
    10. WM_MOTION_Enable(1);
    11. //hSwipelist = WM_GetDialogItem(pMsg->hWin, GUI_ID_SWIPELIST0); hSwipelist = SWIPELIST_CreateAsChild(120, 100, 540, 300, pMsg->hWin, GUI_ID_SWIPELIST0, WM_CF_SHOW); SWIPELIST_SetDefaultBkColor(SWIPELIST_CI_BK_SEP_ITEM, GUI_DARKGRAY); SWIPELIST_SetBkColor(hSwipelist, SWIPELIST_CI_BK_ITEM_UNSEL, GUI_SWIPECOLOR); SWIPELIST_SetTextColor(hSwipelist, SWIPELIST_CI_BK_ITEM_UNSEL, GUI_BLACK);
    12. SWIPELIST_SetBorderSize(hSwipelist, SWIPELIST_BI_BOTTOM, 1); SWIPELIST_SetBorderSize(hSwipelist, SWIPELIST_BI_LEFT, 1); SWIPELIST_SetBorderSize(hSwipelist, SWIPELIST_BI_RIGHT, 1); SWIPELIST_SetBorderSize(hSwipelist, SWIPELIST_BI_TOP, 1); SWIPELIST_SetBkColor(hSwipelist, SWIPELIST_CI_BK_ITEM_SEL, GUI_SWIPECOLOR); SWIPELIST_SetTextColor(hSwipelist, SWIPELIST_CI_BK_ITEM_SEL, GUI_BLACK);
    13. for (j = 0; j < SWIPE0_SEPARATORS; j++) { SWIPELIST_AddSepItem(hSwipelist, paSeperatorText[j], 30); for (i = 0; i < SWIPE0_ITEMS; i++) { SWIPELIST_AddItem(hSwipelist, paItemText[j][i], 50); SWIPELIST_SetFont(hSwipelist, 1+i,GUI_FONT_20_1); } } //hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX_BACKLIGHT); hItem = SPINBOX_CreateEx(0, 0, 100, 40, WM_HBKWIN, WM_CF_SHOW, GUI_ID_SPINBOX_BACKLIGHT, 1, 100); SPINBOX_SetFont(hItem, GUI_FONT_20_1); SPINBOX_SetValue(hItem, set.v.bklight); SWIPELIST_ItemAttachWindow(hSwipelist, 2, hItem, 435, 5);
    14. WM_MOTION_SetMoveable(hSwipelist, WM_CF_MOTION_Y, 1);
    15. // // Initialization of 'BtnBack' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetText(hItem, "Back"); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_0: // Notifications sent by 'BtnBack' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: WM_MOTION_Enable(0); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX_BACKLIGHT); SWIPELIST_ItemDetachWindow(hSwipelist, hItem); for(i=0;i<(SWIPE0_SEPARATORS+SWIPE0_ITEMS);i++) SWIPELIST_DeleteItem(hSwipelist, i); WM_DeleteWindow(pMsg->hWin); currWin = CreateAdminMain(); break; } break; } break;
    16. default: WM_DefaultProc(pMsg); break; }}
    17. /*********************************************************************** Public code************************************************************************//*********************************************************************** CreateAdminParam*/WM_HWIN CreateAdminParam(void);WM_HWIN CreateAdminParam(void) { WM_HWIN hWin;
    18. GUI_SelectLayer(1); GUI_SetBkColor(GUI_TRANSPARENT); hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); return hWin;}
    Display All
  • Hi Simone,

    A simple call of WM_DeleteWindow() should be sufficient. Normally all items attached to the swipelist should be deleted with the SWIPELIST widget itself.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Ok, I also thought so (see the enclosed code), but when I enter in the WM_DeleteWindow routine the system crash!
    Actually the only way that I've found to use the swipelist in a menu is to create it and then Hide/show it keeping memory allocated!
    I noted the same problem trying the sample in Visual Studio (attached code).
    Files
    • GUIConf_c.txt

      (3.8 kB, downloaded 354 times, last: )
    • GUIConf_h.txt

      (4.11 kB, downloaded 347 times, last: )
    • LCDConf_c.txt

      (5.43 kB, downloaded 332 times, last: )
    • LCDConf_h.txt

      (2.89 kB, downloaded 337 times, last: )
    • SWIPELIST_c.txt

      (5.41 kB, downloaded 368 times, last: )
  • Hi,

    Try to call GUI_EndDialog(pMsg->hWin, 0); instead. You are using a blocking method to create a dialog. With a call of WM_DeleteWindow() you won't return from GUI_ExecDialogBox().

    Attached is an example which uses a non blocking function to create a dialog.

    Regards,
    Sven
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.