I'm using emWin libraries on a NXP board with a single-task (polling loop).
I have a visible/active window (Main Window) that covers all the display and a button inside. When the user press the button, I'd like to create and show another window (Slave Window), created on-the-fly in WM_NOTIFICATION_RELEASED message. The Slave Window covers the entire display and it should be on top of the Main Window.
Display All
dialog_entercode_create() creates and returns the handle of the newly created Slave Window. It isn't shown, so the call WM_ShowWindow(hDialog). When finished, the user press a button on Slave Window and the effect should be to delete Slave Window and automatically show again the Main Window.
I tried to send an application-defined message (WM_USER) from the callback function of the Slave Window to the Main Window. In the WM_USER code of the Main Window, I tried to call WM_DeleteWindow(hDialog), but the application crashes. I think because the messages aren't send through a queue mechanism, but inside the WM_SendMessage(). So, when the Main Window calls WM_DeleteWindow(), the Slave Window is yet active and its callback is running so it can't be deleted.
I can call WM_HideWindow() instead of WM_DeleteWindow(), but I'd like to completely deallocate the Slave Window after the user has finished using it.
The problem is similar to a non-blocking Dialog window, but I couldn't understand how it works with Dialogs feature of emWin. Could I call GUI_EndDialog() with a custom window not created with GUI_CreateDialogBox()?
I have a visible/active window (Main Window) that covers all the display and a button inside. When the user press the button, I'd like to create and show another window (Slave Window), created on-the-fly in WM_NOTIFICATION_RELEASED message. The Slave Window covers the entire display and it should be on top of the Main Window.
Source Code
- static void
- cbBackgroundWin(WM_MESSAGE *pMsg)
- {
- WM_HWIN hWin = pMsg->hWin;
- switch(pMsg->MsgId) {
- case WM_NOTIFY_PARENT: {
- switch(pMsg->Data.v) {
- case WM_NOTIFICATION_RELEASED:
- hDialog = dialog_entercode_create(hWin, code, sizeof(code) - 1);
- WM_ShowWindow(hDialog);
- break;
- }
- break;
- }
- case WM_USER:
- ?????
- break;
- default:
- WM_DefaultProc(pMsg);
- }
- }
dialog_entercode_create() creates and returns the handle of the newly created Slave Window. It isn't shown, so the call WM_ShowWindow(hDialog). When finished, the user press a button on Slave Window and the effect should be to delete Slave Window and automatically show again the Main Window.
I tried to send an application-defined message (WM_USER) from the callback function of the Slave Window to the Main Window. In the WM_USER code of the Main Window, I tried to call WM_DeleteWindow(hDialog), but the application crashes. I think because the messages aren't send through a queue mechanism, but inside the WM_SendMessage(). So, when the Main Window calls WM_DeleteWindow(), the Slave Window is yet active and its callback is running so it can't be deleted.
I can call WM_HideWindow() instead of WM_DeleteWindow(), but I'd like to completely deallocate the Slave Window after the user has finished using it.
The problem is similar to a non-blocking Dialog window, but I couldn't understand how it works with Dialogs feature of emWin. Could I call GUI_EndDialog() with a custom window not created with GUI_CreateDialogBox()?