On Closing top (child) Modal Window bottom(parent) window looses Modality

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

  • On Closing top (child) Modal Window bottom(parent) window looses Modality

    Hello All,

    I am experiencing problem with Modal functionality on STemwin 1.2 (emwin 5.32) as well on STemwin 1.1.2 (emwin 5.22).

    Problem is when I close top(child) modal window I loose Modal behaviour of bottom(Parent of top child) window. And then I am able to touch background window .

    Although If I dont create another child from parent window parent window sustains its modality throughout its life time.

    Its only when I create another child with modal(Or even MESSAGEBOX_Create("xxx","Error",GUI_MESSAGEBOX_CF_MODAL);) and close that child window parent win looses modality.

    My code is a follows could some buddy recreate this issue?


    //----------------Parent win creation----------------------------------------------
    hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, 0, 0);
    WM_MakeModal(hWin );

    //---------------Call Back Routine-------------------------------------------------
    static void _cbDialog(WM_MESSAGE * pMsg) {

    switch (pMsg->MsgId) {
    WM_HWIN hItem;
    int NCode;
    int Id;

    case WM_NOTIFY_PARENT:
    Id = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {

    case ID_BUTTON_0:
    switch(NCode) {
    case WM_NOTIFICATION_RELEASED:
    //-----------------------------------------------------------------------Try one of following block ------------------------------------------------------
    //--------------Another Modal Child creation on top of parent-------------------------------
    hItem= GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); //Child win creation
    WM_MakeModal(hItem);

    //-------------OR evenModal Msgbox()--------------------------------------------------------
    MESSAGEBOX_Create("This is Modal type", "Error",GUI_MESSAGEBOX_CF_MODAL);


    break;
    }
    break;
    }

    }
  • RE: On Closing top (child) Modal Window bottom(parent) window looses Modality

    Quick work around is ..

    Just before child winow gets deleted make its parent Modal again..

    Put following code in modal child's call back routine..


    case WM_DELETE:
    hItem = WM_GetParent(pMsg->hWin);
    WM_MakeModal(hItem);
    break;

    ^^

    But will not work if "MESSAGEBOX_Create("This is Modal type", "Error",GUI_MESSAGEBOX_CF_MODAL);" was called from parent. Upon its closure parent will still loose modality.

    Pmjagtap wrote:

    Hello All,

    I am experiencing problem with Modal functionality on STemwin 1.2 (emwin 5.32) as well on STemwin 1.1.2 (emwin 5.22).

    Problem is when I close top(child) modal window I loose Modal behaviour of bottom(Parent of top child) window. And then I am able to touch background window .

    Although If I dont create another child from parent window parent window sustains its modality throughout its life time.

    Its only when I create another child with modal(Or even MESSAGEBOX_Create("xxx","Error",GUI_MESSAGEBOX_CF_MODAL);) and close that child window parent win looses modality.

    My code is a follows could some buddy recreate this issue?


    //----------------Parent win creation----------------------------------------------
    hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, 0, 0);
    WM_MakeModal(hWin );

    //---------------Call Back Routine-------------------------------------------------
    static void _cbDialog(WM_MESSAGE * pMsg) {

    switch (pMsg->MsgId) {
    WM_HWIN hItem;
    int NCode;
    int Id;

    case WM_NOTIFY_PARENT:
    Id = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {

    case ID_BUTTON_0:
    switch(NCode) {
    case WM_NOTIFICATION_RELEASED:
    //-----------------------------------------------------------------------Try one of following block ------------------------------------------------------
    //--------------Another Modal Child creation on top of parent-------------------------------
    hItem= GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0); //Child win creation
    WM_MakeModal(hItem);

    //-------------OR evenModal Msgbox()--------------------------------------------------------
    MESSAGEBOX_Create("This is Modal type", "Error",GUI_MESSAGEBOX_CF_MODAL);


    break;
    }
    break;
    }

    }

    The post was edited 1 time, last by Pmjagtap ().

  • C Source Code

    1. WM_HWIN WM_GetTopMostWindow(void)
    2. {
    3. WM_HWIN hOld = 0;
    4. WM_HWIN hWin;
    5. hWin = WM_GetFirstChild(WM_HBKWIN);
    6. while(hWin)
    7. {
    8. hOld = hWin;
    9. hWin = WM_GetNextSibling(hWin);
    10. }
    11. return hOld;
    12. }
    13. void windowClose(WM_HWIN hWin)
    14. {
    15. WM_DeleteWindow(hWin);
    16. WM_HWIN hTopMostWindow = WM_GetTopMostWindow();
    17. if(WM_IsWindow(hTopMostWindow))
    18. {
    19. WM_SetFocus(hTopMostWindow);
    20. WM_MakeModal(hTopMostWindow);
    21. }
    22. }
    Display All