Wednesday, December 13th 2017, 7:59am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Frost

Beginner

Date of registration: May 6th 2016

Posts: 11

1

Wednesday, December 7th 2016, 2:41pm

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

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 442

2

Thursday, December 8th 2016, 3:19pm

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/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

Frost

Beginner

Date of registration: May 6th 2016

Posts: 11

3

Friday, December 9th 2016, 7:19am

Sven, thanks for the fast and clear response!