Purpose of Widget IDs

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

  • Purpose of Widget IDs

    The user guide says, it is possible to separate all widgets from each other by using unique IDs.
    Well, is this needed by the emWin library to work correctly or is this just a benefit the user may profit from, e.g. when calling WM_GetId()?

  • Hello Johannes,

    Giving the widget an ID is not essential but might be quite handy.

    When creating a widget you can give them an ID, e.g. with a predefined button ID:

    C Source Code

    1. BUTTON_CreateAsChild(10, 10, 80, 20, WM_HBKWIN, GUI_ID_BUTTON0, WM_CF_SHOW)

    This will create a button as child of the desktop window.

    The given ID will allow us to get the button handle from any position in the application. Simply call WM_GetDialogItem(WM_HBKWIN, GUI_ID_BUTTON0) and you will get the handle of the button with this ID attached to the given dialog handle (here it is the desktop window).