Custom widget is not notifying its FrameWin parent

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

  • Custom widget is not notifying its FrameWin parent

    Hi,

    I have some custom widgets in my project and I have noticed that when they are added to a FrameWin they do not notify its parent as expected.

    The framewin is created like this:

    C Source Code

    1. static const GUI_WIDGET_CREATE_INFO widget_info[] =
    2. {
    3. { FRAMEWIN_CreateIndirect, NULL, WDG_FRAMEWIN, 0, 0, 400, 235, 0 },
    4. // Custom Widget - Manifold Id
    5. { TEXT_CreateIndirect, NULL, WDG_TXT_PRODUCT, 20, 75, 100, 50, 0, 0, 0 },
    6. // Custom Widget - Product
    7. { BUTTON_CreateIndirect, NULL, WDG_BTN_CLOSE, 125, 145, 150, 45, 0, 0, 0 }
    8. };


    The custom widgets are added on the WM_INIT_DIALOG:

    C Source Code

    1. case WM_INIT_DIALOG:
    2. {
    3. // ...
    4. snprintf(tmp_array, TempArraySize, "%s", "Configuration");
    5. FRAMEWIN_SetText(my_hd, tmp_array);
    6. // Custom Widget.
    7. g_spin_text[SPIN_TEXT_MAN] = SPIN_TEXT_BOX_create(50, 50, 300, 50, my_hd, WM_CF_SHOW);
    8. // ...
    9. // Custom Widget - Spin text box
    10. g_spin_text[SPIN_TEXT_PRODUCT] = SPIN_TEXT_BOX_create(130, 110, 250, 50, my_hd, WM_CF_SHOW);
    11. tmp_hd = WM_GetDialogItem(my_hd, WDG_BTN_CLOSE);
    12. BUTTON_SetText(tmp_hd, _tCLOSE);
    13. // ...
    14. }
    Display All


    The problem happens here:

    C Source Code

    1. case WM_NOTIFY_PARENT:
    2. {
    3. id = WM_GetId(src_hd);
    4. nCode = pMsg->Data.v;
    5. if(src_hd == g_spin_text[SPIN_TEXT_MAN])
    6. {
    7. if(nCode == WM_NOTIFICATION_VALUE_CHANGED)
    8. {
    9. ManCb(pMsg);
    10. }
    11. }
    12. else if(src_hd == g_spin_text[SPIN_TEXT_PRODUCT])
    13. {
    14. if(nCode == WM_NOTIFICATION_VALUE_CHANGED)
    15. {
    16. SpinTextCb(pMsg);
    17. }
    18. }
    Display All


    So, the methods ManCb(pMsg) and SpinTextCb(pMsg) never execute. In my opinion because the widgets are kinda of outside the frame. I need to know how to tell the framewin that the widgets are indeed inside the frame.

    I tested the same kind of implementation with a usual window, not a framewin, and everything worked just fine.

    Thanks.
  • Further debug information

    I have debugged the code and noticed that my frame window is not receiving a WM_NOTIFY_PARENT. I thought that maybe the notification does not happen because my widget is custom and is being created outside the GUI_WIDGET_CREATE_INFO, so I used the WM_AttachWindow to attach it to the winframe. Unfortunatelly, the problem still persists.
  • I have found the solution thinking about how to implement a timer in a FrameWin. I submitted a question about it some weeks ago, the link is here.
    It appears that some functions must be implemented using another callback, according to the following squeme:

    C Source Code

    1. static void cbFrameWin(WM_MESSAGE * pMsg)
    2. {
    3. // ...
    4. switch (pMsg->MsgId)
    5. {
    6. case WM_NOTIFY_PARENT:
    7. {
    8. // ...
    9. if(src_hd == g_spin_text[SPIN_TEXT_MANIFOLD])
    10. {
    11. if(nCode == WM_NOTIFICATION_VALUE_CHANGED)
    12. {
    13. // Executes the callback of the custom widget
    14. }
    15. }
    16. }
    17. break;
    18. default:
    19. { FRAMEWIN_Callback(pMsg); }
    20. break;
    21. }
    22. }
    23. static void WdwCb(WM_MESSAGE* pMsg)
    24. {
    25. // ...
    26. switch (pMsg->MsgId)
    27. {
    28. case WM_INIT_DIALOG:
    29. {
    30. // ...
    31. WM_SetCallback(my_hd, cbFrameWin);
    32. }
    33. break;
    34. default:
    35. { WM_DefaultProc(pMsg); }
    36. break;
    37. }
    38. }
    39. // ...
    40. wm_hwin = GUI_CreateDialogBox( widget_info,
    41. GUI_COUNTOF(widget_info),
    42. WdwCb,
    43. WM_HBKWIN, // Background window
    44. 200, 50);
    Display All


    After some weeks working with emWin I must say that the documentation concerning custom widgets is very weak and covers issues too simple. Maybe a document with more information and complex examples would help a lot of users.
  • Hi,

    we have an application note available on our website regarding custom widgets. Maybe this is helpful for you.

    segger.com/downloads/appnotes/AN03002_Custom_Widget_Type.pdf

    Regards
    Sven
    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.