Thursday, October 19th 2017, 4:42pm UTC+2

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.

Thomas W.

Beginner

Date of registration: Jun 2nd 2015

Posts: 38

1

Tuesday, November 3rd 2015, 8:41am

Dropdown widget WM_SetFocus problem

Hi,

I have an issue with the DROPDOWN widget.

I have a dialog window which contains a dropdown widget and other widgets. Further on, I want to display some notification messages which appear about 2 seconds on the screen after a certain event (e.g. USB MSD attached). The window which displays the notification message is created as a sibling of the dialog window which contains the DROPDOWN widget. When the notification widget is created the “create function” derives the currently focused widget (WM_GetFocussedWindow()) of the dialog window, stores this item and sets the focus to one of the widgets of the notification window. When the notification window is deleted the buffered item of the dialog window is set focused again. This procedure works fine except one case. If the DROPDOWN widget is expanded I get a “MCU usage fault” exception when I want to set the focus to the buffered item, since it seems that the buffered item is the expanded dropdown list and not the widget itself.

Can you help me to find a solution or workaround for my issue?

Maybe there is a function which stores/restores the complete WM context of a dialog?

Regards Thomas

This post has been edited 3 times, last edit by "Thomas W." (Nov 3rd 2015, 9:15am)


SEGGER - Jörg

Super Moderator

Date of registration: Dec 20th 2007

Posts: 81

2

Thursday, November 5th 2015, 12:28pm

Hi Thomas,

With WM_IsWindow() you could check if a handle represents a currently existing window or not. It could be used to avoid setting a focus to a non existing window. Independent of that we could not reproduce any problem with the dialog behavior of emWin (see attached sample).

Regards, Jörg
SEGGER - Jörg has attached the following file:

Thomas W.

Beginner

Date of registration: Jun 2nd 2015

Posts: 38

3

Thursday, November 5th 2015, 1:06pm

Hi Jörg,

thank you for your response.

I am sure that your code is working, but it does not exactly correspond with my problem.
If I call the function WM_GetFocussedWindow() when a Dropdown widget is expanded then I get the handle of the Listbox and not of the Dropdown widget.
(I checked this with the aid of the callback function.) So what I need is a function or a workaround where I can get the handle of the Dropdown widget from its relative Listbox handle.
Like an inverted DROPDOWN_GetListbox(hItem) funktion (e.g. LISTBOX_GetDropdown(hItem)).


regards Thomas

SEGGER - Jörg

Super Moderator

Date of registration: Dec 20th 2007

Posts: 81

4

Thursday, November 5th 2015, 2:46pm

Hi Thomas,

We added a new function LISTBOX_GetOwner() to emWin. It can be used either to get the owner (in case of an open DROPDOWN the DROPDOWNis the owner) or the parent window of a LISTBOX. Here is the code:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WM_HWIN LISTBOX_GetOwner(LISTBOX_Handle hObj) {
  LISTBOX_Obj * pObj;
  WM_HWIN	hOwner;

  hOwner = 0;
  if (hObj) {
	WM_LOCK();
	pObj = LISTBOX_LOCK_H(hObj); {
  	hOwner = pObj->hOwner ? pObj->hOwner : WM_GetParent(hObj);
	} GUI_UNLOCK_H(pObj);
	WM_UNLOCK();
  }
  return hOwner;
}


We added the code into LISTBOX.c and the prototype to LISTBOX.h. It will be available in future versions. Please let us know if it helps.

Regards, Jörg

Thomas W.

Beginner

Date of registration: Jun 2nd 2015

Posts: 38

5

Friday, November 6th 2015, 10:07am

Hi Jörg,

perfect.
I think this will solve my problem.
When will you release the new version (approximately)?

regards
Thomas