Widget ID - retreive handle error with WM_GetDialogItem() -child window

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

    • Widget ID - retreive handle error with WM_GetDialogItem() -child window

      I used the GUI_BUILDER to create 2 screens and another one that is instanciated twice a child of the first 2 screens.

      Source Code

      1. WM_HWIN CreateScreen1(void) {
      2. WM_HWIN hWin;
      3. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      4. CreateChildWindow(hWin, <position relative to the window>);
      5. return hWin;
      6. }
      7. WM_HWIN CreateScreen2(void) {
      8. WM_HWIN hWin;
      9. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      10. CreateChildWindow( hWin, <position relative to the window>);
      11. return hWin;
      12. }
      13. int CreateChildWindow(WM_HWIN hParent, int x0, int y0) {
      14. WM_HWIN hWin;
      15. assert( pHdle );
      16. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hParent, x0, y0);
      17. return (hWin) ? 0 : 1;
      18. }
      Display All


      I created for each dialog enums without taking care of unique ID, so the IDs for each is starting with :

      Source Code

      1. ID_WINDOW_0 = GUI_ID_USER + 0x00



      I never experienced problem when using WM_GetDialogItem() in screens without child window. But when I have child window WM_GetDialogItem(handleScreen1, ID_LISTVIEW) returns a wrong ID, alias the handle of the widget in the child window that matches the one as given as argument.

      Are the IDs of windows and child window ordered at the same level so that when calling WM_GetDialogItem() the first ID that is matching is returned ?
      So that I will have to use unique ID for them ?

      Can I safely use "common" ID on dialog'widget that have the parent as background ?

      thank you.

      using : stemwin v5.40
    • Hi,

      We recommend to use unique Ids.

      emWin searches in the given dialog and all its child windows/widgets for the given ID. So if using the same ID in a dialog and child dialog as well, you can't really say which handle will be returned by WM_GetDialogItem().

      This might work, but doesn't have to.

      Regards
      Sven