Sunday, February 25th 2018, 6:33pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Pmjagtap

Beginner

Date of registration: May 5th 2016

Posts: 11

Location: UK

Occupation: electronic eng

1

Thursday, November 24th 2016, 12:47pm

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;
}

}

Pmjagtap

Beginner

Date of registration: May 5th 2016

Posts: 11

Location: UK

Occupation: electronic eng

2

Thursday, November 24th 2016, 1:17pm

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.
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;
}

}

This post has been edited 1 times, last edit by "Pmjagtap" (Nov 24th 2016, 1:20pm)


byteblaster

Beginner

Date of registration: Jun 19th 2014

Posts: 7

3

Tuesday, November 29th 2016, 7:26am

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
WM_HWIN WM_GetTopMostWindow(void)
{
  WM_HWIN hOld = 0;
  WM_HWIN hWin;

  hWin = WM_GetFirstChild(WM_HBKWIN);

  while(hWin)
  {
    hOld = hWin;
    hWin = WM_GetNextSibling(hWin);
  }

  return hOld;
}

void windowClose(WM_HWIN hWin)
{
  WM_DeleteWindow(hWin);

  WM_HWIN hTopMostWindow = WM_GetTopMostWindow();

  if(WM_IsWindow(hTopMostWindow))
  {
    WM_SetFocus(hTopMostWindow);
    WM_MakeModal(hTopMostWindow);
  }
}