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()?

    Thanks,
    Johannes
  • 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).

    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.