WM_SetUserData - issue for widget of DIALOG

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

    • WM_SetUserData - issue for widget of DIALOG

      Hello, everyone.

      There is a DIALOG with one BUTTON, that has ExtraBytes.

      After storing data to the BUTTON-widget with WM_SetUserData the function WM_GetDialogItem for get BUTTON-widget returns 0.

      Here is source-code:

      C Source Code

      1. #define Data_t long long
      2. #define TEST_FRAMEWIN (GUI_ID_USER + 0x00)
      3. #define TEST_BUTTON (GUI_ID_USER + 0x01)
      4. static const GUI_WIDGET_CREATE_INFO _aDialogTest[] = {
      5. { FRAMEWIN_CreateIndirect, "Main window", TEST_FRAMEWIN, 0, 0, 200, 200, FRAMEWIN_CF_MOVEABLE, 0x0, sizeof(Data_t) },
      6. { BUTTON_CreateIndirect, "Button", TEST_BUTTON, 100, 10, 80, 20, 0, 0x0, sizeof(Data_t) },
      7. };
      8. static void _cbTest(WM_MESSAGE * pMsg) {
      9. int test;
      10. switch (pMsg->MsgId) {
      11. case WM_NOTIFY_PARENT:
      12. switch (pMsg->Data.v) {
      13. case WM_NOTIFICATION_RELEASED:
      14. switch (WM_GetId(pMsg->hWinSrc)) {
      15. case TEST_BUTTON:
      16. GUI_MessageBox("Button works", "BUTTON", 0); // check if button works
      17. break;
      18. }
      19. break;
      20. }
      21. break;
      22. default:
      23. WM_DefaultProc(pMsg);
      24. break;
      25. }
      26. }
      27. void MainTask() {
      28. GUI_Init();
      29. WM_SetBkWindowColor(GUI_WHITE);
      30. WM_HWIN mainWin = GUI_CreateDialogBox(_aDialogTest, GUI_COUNTOF(_aDialogTest), _cbTest, WM_HBKWIN, 0, 0);
      31. WM_HWIN button = WM_GetDialogItem(mainWin, TEST_BUTTON);
      32. int readBytes;
      33. Data_t value = 1234567890;
      34. readBytes = WM_SetUserData(button, &value, sizeof(Data_t));
      35. //Data_t readValue;
      36. //readBytes = WM_GetUserData(button, &readValue, sizeof(Data_t));
      37. button = WM_GetDialogItem(mainWin, TEST_BUTTON); // here button is 0
      38. while (1) {
      39. GUI_Delay(100);
      40. };
      41. }
      Display All
      Best regards,
      Volodymyr.

      The post was edited 1 time, last by volodymyr ().

    • Hello,

      WM_GetUserData()/WM_SetUserData() is for simple windows.

      For widgets just use specific <WIDGET>_GetUserData()/<WIDGET>_SetUserData() functions.

      In your case it is BUTTON_SetUserData().

      Calling WM_SetUserData() for the button may have caused button-specific parameters to overwrite.

      Alex.
    • LexaGb wrote:

      Hello,

      WM_GetUserData()/WM_SetUserData() is for simple windows.

      For widgets just use specific <WIDGET>_GetUserData()/<WIDGET>_SetUserData() functions.

      In your case it is BUTTON_SetUserData().

      Calling WM_SetUserData() for the button may have caused button-specific parameters to overwrite.

      Alex.
      Thanks, Alex, you are right.
      Best regards,
      Volodymyr.