How to detect a WM_DisableWindow in a custom widget.

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

  • How to detect a WM_DisableWindow in a custom widget.

    I have a lot of custom widgets in my project. All of them created with WM_CreateWindowAsChild and returning a handle to the main window. Something like this:

    C Source Code

    1. SPIN_TEXT_BOX_HD SPIN_TEXT_BOX_create(int x, int y, int w, int h, WM_HWIN hWinParent, U32 style)
    2. {
    3. SPIN_TEXT_BOX_HD mainHd;
    4. WM_HWIN widgetHd;
    5. spin_text_box_t dft_data = {0, 0, 0, {NULL} };
    6. btn_data_t btn_data = {0, FALSE};
    7. // Edit dimensions
    8. int ew;
    9. mainHd = WM_CreateWindowAsChild(x, y, w, h, hWinParent, style, cbMain, sizeof(spin_text_box_t));
    10. WM_SetUserData(mainHd, &dft_data, sizeof(spin_text_box_t));
    11. widgetHd = BUTTON_CreateEx( 0, 0, 50, 50, mainHd, style, 0, WDG_BTN_DEC);
    12. WM_SetCallback(widgetHd, cbButton);
    13. WM_SetUserData(widgetHd, &btn_data, sizeof(btn_data_t));
    14. // Edit width
    15. ew = w - 2*50;
    16. widgetHd = EDIT_CreateEx ( 50, 0, ew, 50, mainHd, style, 0, WDG_LABEL_TXT, 24);
    17. WM_SetCallback(widgetHd, cbEdit);
    18. btn_data.arrow_right = TRUE;
    19. widgetHd = BUTTON_CreateEx( 50+ew, 0, 50, 50, mainHd, style, 0, WDG_BTN_INC);
    20. WM_SetCallback(widgetHd, cbButton);
    21. WM_SetUserData(widgetHd, &btn_data, sizeof(btn_data_t));
    22. return mainHd;
    23. }
    Display All


    As you can see, in this example I have a main child window, that is going to be child of the window passed as parameter on the method create. And I have 3 windows that are children of this so called 'main child window'.

    My question is. Is it possible to receive a message via callback (in my example the callback is called cbMain) when I use a WM_DisableWindow and WM_EnableWindow?

    My focus here is try to develop a custom widget with the same interface as the emWin Widgets.

    The post was edited 2 times, last by RodolfoDias ().

  • Hi,

    Yes there is a way. In your 'cbMain' simply react on WM_NOTIFY_ENABLE. If pMsg->Data.v is 0 it gets disabled if the value is 1 it gets enabled.

    C Source Code

    1. case WM_NOTIFY_ENABLE:
    2. if (pMsg->Data.v == 1) {
    3. //
    4. // Enable
    5. //
    6. } else if (pMsg->Data.v == 0) {
    7. //
    8. // Disable
    9. //
    10. }
    11. WM_DefaultProc(pMsg);
    12. break;
    Display All


    If you want to create your own widget, you might want to take a look into our application note regarding creating own widgets:
    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.