The best way to delete a DialogBox and to create a new one after pressing a button ?

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

  • The best way to delete a DialogBox and to create a new one after pressing a button ?

    Hello emWin-users,

    I dont want to place a huge code here so I will try to compress it and to concentrate on the important part of it:


    Can you tell me what is the best way to delete a DialogBox with a WindowAsChild on it (invisible one) and to create a new DialogBox right after that (for example after pressing a button). I did the following, but it sometimes crashes:



    case ID_BUTTON_NEXT:

    //WHAT ABOUT THIS :

    WM_DeleteWindow(hWin1);
    WM_DeleteWindow(hWin2);

    GUI_Clear();
    NextScreen();
    GUI_SetOrg(0, 480);

    break;
    }
    break;
    }
    break;
    default:
    WM_DefaultProc(pMsg);
    }
    }


    /*********************************************************************
    *
    * Public code
    *
    **********************************************************************
    */
    /*********************************************************************
    *
    * MainTask
    */


    void MainScreen(void) {

    WM_SetCreateFlags(WM_CF_MEMDEV);

    hWin1 = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, WM_HBKWIN, 0, 0);
    hWin2 = WM_CreateWindowAsChild(100, 100, 320, 220, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_MEMDEV, _cbWin, 0);

    }


    /// NEXT SCREEN ////

    void NextScreen(void) {
    WM_SetCreateFlags(WM_CF_MEMDEV);
    hWin3 = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbCallback, WM_HBKWIN, 0, 0);hWin4 = WM_CreateWindowAsChild(100, 580, 320, 220, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_MEMDEV, _cbWin, 0);
    }

    Thank you in advance!Ivo
  • Hi,

    Just call WM_DeleteWindow() and all child windows of the window to be deleted will be deleted, too.

    Take a look into the application attached. There I create dialog containing a button to close it. On button press I delete the dialog and create right after that another 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.