switch dialogbox

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

    • switch dialogbox

      Hi.
      Using a nested window in a project I made based on the following example gives an error.
      I want to enter the sub-menus by pressing the buttons.
      For example
      Settings(dialog1)-> Display(dialog2)- -> Resolution(dialog3)
      Settings(dialog1)--> Audio(dialog4)--> Device(dialog5)

      C Source Code

      1. C Source Code
      2. #include "DIALOG.h"
      3. /*********************************************************************
      4. *
      5. * Externals
      6. *
      7. **********************************************************************
      8. */
      9. /*********************************************************************
      10. *
      11. * Defines
      12. *
      13. **********************************************************************
      14. */
      15. #define ID_WINDOW_00 (GUI_ID_USER + 0x00)
      16. #define ID_TEXT_00 (GUI_ID_USER + 0x01)
      17. #define ID_BUTTON_00 (GUI_ID_USER + 0x03)
      18. #define ID_WINDOW_10 (GUI_ID_USER + 0x00)
      19. #define ID_TEXT_10 (GUI_ID_USER + 0x01)
      20. #define ID_BUTTON_10 (GUI_ID_USER + 0x03)
      21. /*********************************************************************
      22. *
      23. * Static data
      24. *
      25. **********************************************************************
      26. */
      27. /*********************************************************************
      28. *
      29. * _aDialogCreate
      30. */
      31. static const GUI_WIDGET_CREATE_INFO _aDialogCreate0[] = {
      32. { WINDOW_CreateIndirect, "Window", ID_WINDOW_00, 0, 0, 320, 240, 0, 0x0, 0 },
      33. { TEXT_CreateIndirect, "Dialog 1", ID_TEXT_00, 100, 100, 120, 40, 0, 0x0, 0 },
      34. { BUTTON_CreateIndirect, "Switch", ID_BUTTON_00, 110, 170, 80, 20, 0, 0x0, 0 },
      35. };
      36. /*********************************************************************
      37. *
      38. * _aDialogCreate
      39. */
      40. static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
      41. { WINDOW_CreateIndirect, "Window", ID_WINDOW_10, 0, 0, 320, 240, 0, 0x0, 0 },
      42. { TEXT_CreateIndirect, "Dialog 2", ID_TEXT_10, 100, 100, 120, 40, 0, 0x0, 0 },
      43. { BUTTON_CreateIndirect, "Switch", ID_BUTTON_10, 110, 170, 80, 20, 0, 0x0, 0 },
      44. };
      45. static WM_HWIN _hDialog0;
      46. static WM_HWIN _hDialog1;
      47. /*********************************************************************
      48. *
      49. * Static code
      50. *
      51. **********************************************************************
      52. */
      53. /*********************************************************************
      54. *
      55. * _cbDialog1
      56. */
      57. static void _cbDialog1(WM_MESSAGE * pMsg) {
      58. WM_HWIN hItem;
      59. int NCode;
      60. int Id;
      61. switch (pMsg->MsgId) {
      62. case WM_INIT_DIALOG:
      63. //
      64. // Initialization of 'Window'
      65. //
      66. hItem = pMsg->hWin;
      67. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00EFFFBF));
      68. //
      69. // Initialization of 'Dialog 1'
      70. //
      71. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
      72. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00000000));
      73. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
      74. TEXT_SetFont(hItem, GUI_FONT_32B_1);
      75. break;
      76. case WM_NOTIFY_PARENT:
      77. Id = WM_GetId(pMsg->hWinSrc);
      78. NCode = pMsg->Data.v;
      79. switch(Id) {
      80. case ID_BUTTON_10: // Notifications sent by 'Switch'
      81. switch(NCode) {
      82. case WM_NOTIFICATION_RELEASED:
      83. WM_HideWindow(_hDialog1);
      84. WM_ShowWindow(_hDialog0);
      85. break;
      86. }
      87. break;
      88. }
      89. break;
      90. default:
      91. WM_DefaultProc(pMsg);
      92. break;
      93. }
      94. }
      95. /*********************************************************************
      96. *
      97. * _cbDialog0
      98. */
      99. static void _cbDialog0(WM_MESSAGE * pMsg) {
      100. WM_HWIN hItem;
      101. int NCode;
      102. int Id;
      103. switch (pMsg->MsgId) {
      104. case WM_INIT_DIALOG:
      105. //
      106. // Initialization of 'Window'
      107. //
      108. hItem = pMsg->hWin;
      109. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00100040));
      110. //
      111. // Initialization of 'Dialog 1'
      112. //
      113. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_00);
      114. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
      115. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
      116. TEXT_SetFont(hItem, GUI_FONT_32B_1);
      117. break;
      118. case WM_NOTIFY_PARENT:
      119. Id = WM_GetId(pMsg->hWinSrc);
      120. NCode = pMsg->Data.v;
      121. switch(Id) {
      122. case ID_BUTTON_00: // Notifications sent by 'Switch'
      123. switch(NCode) {
      124. case WM_NOTIFICATION_RELEASED:
      125. WM_HideWindow(_hDialog0);
      126. WM_ShowWindow(_hDialog1);
      127. break;
      128. }
      129. break;
      130. }
      131. break;
      132. default:
      133. WM_DefaultProc(pMsg);
      134. break;
      135. }
      136. }
      137. /*********************************************************************
      138. *
      139. * _cbBk
      140. */
      141. static void _cbBk(WM_MESSAGE * pMsg) {
      142. switch (pMsg->MsgId) {
      143. case WM_PAINT:
      144. GUI_SetBkColor(GUI_GRAY);
      145. GUI_Clear();
      146. break;
      147. default:
      148. WM_DefaultProc(pMsg);
      149. break;
      150. }
      151. }
      152. /*********************************************************************
      153. *
      154. * Public code
      155. *
      156. **********************************************************************
      157. */
      158. /*********************************************************************
      159. *
      160. * MainTask
      161. */
      162. void MainTask(void) {
      163. GUI_Init();
      164. WM_SetCallback(WM_HBKWIN, _cbBk);
      165. _hDialog0 = GUI_CreateDialogBox(_aDialogCreate0, GUI_COUNTOF(_aDialogCreate0), _cbDialog0, WM_HBKWIN, 0, 0);
      166. _hDialog1 = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog1, WM_HBKWIN, 0, 0);
      167. WM_HideWindow(_hDialog1);
      168. while (1) {
      169. GUI_Delay(100);
      170. }
      171. }
      Display All
      What could be the problem?

      Regards,
      Hakan
    • Hi,

      What kind of error do you get?

      On my end the example runs good.

      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.
    • I did a little experiment, the sample file is failing.
      I'm running the system, I touch the button a lot of times and the system crashes after a while.(I've touched the button without stopping, and I think it's crashing at the 20th touch)

      edit:Crashed after 1 minute.
      Regards,
      Hakan

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