Tuesday, April 24th 2018, 6:28pm UTC+2

You are not logged in.

  • Login
  • Register

Ivancho

Beginner

Date of registration: Sep 15th 2016

Posts: 23

1

Wednesday, January 11th 2017, 9:30am

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

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 562

2

Wednesday, January 11th 2017, 3:00pm

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
SEGGER - Schoenen has attached the following file:
  • DeleteDialog.zip (1.37 kB - 109 times downloaded - Last download: Yesterday, 5:11pm)

Similar threads