Dropdown widget WM_SetFocus problem

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

  • 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

    The post was edited 3 times, last by Thomas W. ().

  • 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
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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
  • 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 Source Code

    1. WM_HWIN LISTBOX_GetOwner(LISTBOX_Handle hObj) {
    2. LISTBOX_Obj * pObj;
    3. WM_HWIN hOwner;
    4. hOwner = 0;
    5. if (hObj) {
    6. WM_LOCK();
    7. pObj = LISTBOX_LOCK_H(hObj); {
    8. hOwner = pObj->hOwner ? pObj->hOwner : WM_GetParent(hObj);
    9. } GUI_UNLOCK_H(pObj);
    10. WM_UNLOCK();
    11. }
    12. return hOwner;
    13. }
    Display All


    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
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.