Update Text

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

  • Update Text

    I have made a Window with 1 Text Field and 1 Button.

    Update Text with Button works fine.

    C Source Code

    1. /*********************************************************************
    2. * *
    3. * SEGGER Microcontroller GmbH & Co. KG *
    4. * Solutions for real time microcontroller applications *
    5. * *
    6. **********************************************************************
    7. * *
    8. * C-file generated by: *
    9. * *
    10. * GUI_Builder for emWin version 5.22 *
    11. * Compiled Jul 4 2013, 15:16:01 *
    12. * (c) 2013 Segger Microcontroller GmbH & Co. KG *
    13. * *
    14. **********************************************************************
    15. * *
    16. * Internet: www.segger.com Support: support@segger.com *
    17. * *
    18. **********************************************************************
    19. */
    20. // USER START (Optionally insert additional includes)
    21. // USER END
    22. #include "DIALOG.h"
    23. /*********************************************************************
    24. *
    25. * Defines
    26. *
    27. **********************************************************************
    28. */
    29. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
    30. #define ID_TEXT_0 (GUI_ID_USER + 0x01)
    31. #define ID_BUTTON_0 (GUI_ID_USER + 0x02)
    32. // USER START (Optionally insert additional defines)
    33. // USER END
    34. /*********************************************************************
    35. *
    36. * Static data
    37. *
    38. **********************************************************************
    39. */
    40. // USER START (Optionally insert additional static data)
    41. // USER END
    42. /*********************************************************************
    43. *
    44. * _aDialogCreate
    45. */
    46. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    47. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
    48. { TEXT_CreateIndirect, "Text", ID_TEXT_0, 103, 93, 80, 20, 0, 0x64, 0 },
    49. { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 104, 152, 80, 20, 0, 0x0, 0 },
    50. // USER START (Optionally insert additional widgets)
    51. // USER END
    52. };
    53. /*********************************************************************
    54. *
    55. * Static code
    56. *
    57. **********************************************************************
    58. */
    59. // USER START (Optionally insert additional static code)
    60. // USER END
    61. /*********************************************************************
    62. *
    63. * _cbDialog
    64. */
    65. static void _cbDialog(WM_MESSAGE * pMsg) {
    66. WM_HWIN hItem;
    67. int NCode;
    68. int Id;
    69. // USER START (Optionally insert additional variables)
    70. // USER END
    71. switch (pMsg->MsgId) {
    72. case WM_INIT_DIALOG:
    73. //
    74. // Initialization of 'Text'
    75. //
    76. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    77. TEXT_SetText(hItem, "Before");
    78. // USER START (Optionally insert additional code for further widget initialization)
    79. // USER END
    80. break;
    81. case WM_NOTIFY_PARENT:
    82. Id = WM_GetId(pMsg->hWinSrc);
    83. NCode = pMsg->Data.v;
    84. switch(Id) {
    85. case ID_BUTTON_0: // Notifications sent by 'Button'
    86. switch(NCode) {
    87. case WM_NOTIFICATION_CLICKED:
    88. // USER START (Optionally insert code for reacting on notification message)
    89. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    90. TEXT_SetText(hItem, "After Button pressed");
    91. // USER END
    92. break;
    93. case WM_NOTIFICATION_RELEASED:
    94. // USER START (Optionally insert code for reacting on notification message)
    95. // USER END
    96. break;
    97. // USER START (Optionally insert additional code for further notification handling)
    98. // USER END
    99. }
    100. break;
    101. // USER START (Optionally insert additional code for further Ids)
    102. // USER END
    103. }
    104. break;
    105. // USER START (Optionally insert additional message handling)
    106. // USER END
    107. default:
    108. WM_DefaultProc(pMsg);
    109. break;
    110. }
    111. }
    112. /*********************************************************************
    113. *
    114. * Public code
    115. *
    116. **********************************************************************
    117. */
    118. /*********************************************************************
    119. *
    120. * CreateWindow
    121. */
    122. WM_HWIN CreateWindow(void);
    123. WM_HWIN CreateWindow(void) {
    124. WM_HWIN hWin;
    125. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    126. return hWin;
    127. }
    128. // USER START (Optionally insert additional public code)
    129. // USER END
    130. /*************************** End of file ****************************/
    Display All




    But I have no idea how a callback must looks like to do that from extern

    like

    C Source Code

    1. // USER START (Optionally insert additional public code)
    2. /***********************************************************************
    3. Update Text Field*/
    4. WM_HWIN UpdateText(void);
    5. WM_HWIN UpdateText(void) {
    6. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    7. TEXT_SetText(hItem, "Text changed:");
    8. }




    That allone not works, how to do it right??

    regards

    Jim