Disable focus re-drawing on GUIBuilder generated BUTTON

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

    • Disable focus re-drawing on GUIBuilder generated BUTTON

      Hi to all,

      I'm using STemwin ( a free version of EMWinprecompiled for STM32 processor) in this release, GUIBuilder is delivered for free.

      My project consist of a resistive touch screen.
      I want to disable the focus feature of Buttons, because press on a button cause redraw of previously pressed button.

      How can I do this ?

      this is my GUIBuilder outpu:

      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.44 *
      11. * Compiled Nov 10 2017, 08:53:57 *
      12. * (c) 2017 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_BUTTON_0 (GUI_ID_USER + 0x01)
      31. #define ID_BUTTON_1 (GUI_ID_USER + 0x02)
      32. #define ID_BUTTON_2 (GUI_ID_USER + 0x03)
      33. #define ID_BUTTON_3 (GUI_ID_USER + 0x04)
      34. #define ID_BUTTON_4 (GUI_ID_USER + 0x05)
      35. // USER START (Optionally insert additional defines)
      36. // USER END
      37. /*********************************************************************
      38. *
      39. * Static data
      40. *
      41. **********************************************************************
      42. */
      43. // USER START (Optionally insert additional static data)
      44. // USER END
      45. /*********************************************************************
      46. *
      47. * _aDialogCreate
      48. */
      49. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      50. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 240, 320, 0, 0x0, 0 },
      51. { BUTTON_CreateIndirect, "Button_1", ID_BUTTON_0, 45, 7, 150, 50, 0, 0x0, 0 },
      52. { BUTTON_CreateIndirect, "Button_2", ID_BUTTON_1, 45, 71, 150, 50, 0, 0x0, 0 },
      53. { BUTTON_CreateIndirect, "Button_3", ID_BUTTON_2, 45, 135, 150, 50, 0, 0x0, 0 },
      54. { BUTTON_CreateIndirect, "Button_4", ID_BUTTON_3, 45, 199, 150, 50, 0, 0x0, 0 },
      55. { BUTTON_CreateIndirect, "Button_5", ID_BUTTON_4, 45, 263, 150, 50, 0, 0x0, 0 },
      56. // USER START (Optionally insert additional widgets)
      57. // USER END
      58. };
      59. /*********************************************************************
      60. *
      61. * Static code
      62. *
      63. **********************************************************************
      64. */
      65. // USER START (Optionally insert additional static code)
      66. // USER END
      67. /*********************************************************************
      68. *
      69. * _cbDialog
      70. */
      71. static void _cbDialog(WM_MESSAGE * pMsg) {
      72. WM_HWIN hItem;
      73. int NCode;
      74. int Id;
      75. // USER START (Optionally insert additional variables)
      76. // USER END
      77. switch (pMsg->MsgId) {
      78. case WM_INIT_DIALOG:
      79. //
      80. // Initialization of 'Window'
      81. //
      82. hItem = pMsg->hWin;
      83. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00804000));
      84. // USER START (Optionally insert additional code for further widget initialization)
      85. // USER END
      86. break;
      87. case WM_NOTIFY_PARENT:
      88. Id = WM_GetId(pMsg->hWinSrc);
      89. NCode = pMsg->Data.v;
      90. switch(Id) {
      91. case ID_BUTTON_0: // Notifications sent by 'Button_1'
      92. switch(NCode) {
      93. case WM_NOTIFICATION_CLICKED:
      94. // USER START (Optionally insert code for reacting on notification message)
      95. GUI_DispStringHCenterAt("Pulsante 1" , 10, 160);
      96. // USER END
      97. break;
      98. case WM_NOTIFICATION_RELEASED:
      99. // USER START (Optionally insert code for reacting on notification message)
      100. // USER END
      101. break;
      102. // USER START (Optionally insert additional code for further notification handling)
      103. // USER END
      104. }
      105. break;
      106. case ID_BUTTON_1: // Notifications sent by 'Button_2'
      107. switch(NCode) {
      108. case WM_NOTIFICATION_CLICKED:
      109. // USER START (Optionally insert code for reacting on notification message)
      110. GUI_DispStringHCenterAt("Pulsante 2" , 10, 160);
      111. // USER END
      112. break;
      113. case WM_NOTIFICATION_RELEASED:
      114. // USER START (Optionally insert code for reacting on notification message)
      115. // USER END
      116. break;
      117. // USER START (Optionally insert additional code for further notification handling)
      118. // USER END
      119. }
      120. break;
      121. case ID_BUTTON_2: // Notifications sent by 'Button_3'
      122. switch(NCode) {
      123. case WM_NOTIFICATION_CLICKED:
      124. // USER START (Optionally insert code for reacting on notification message)
      125. GUI_DispStringHCenterAt("Pulsante 3" , 10, 160);
      126. // USER END
      127. break;
      128. case WM_NOTIFICATION_RELEASED:
      129. // USER START (Optionally insert code for reacting on notification message)
      130. // USER END
      131. break;
      132. // USER START (Optionally insert additional code for further notification handling)
      133. // USER END
      134. }
      135. break;
      136. case ID_BUTTON_3: // Notifications sent by 'Button_4'
      137. switch(NCode) {
      138. case WM_NOTIFICATION_CLICKED:
      139. // USER START (Optionally insert code for reacting on notification message)
      140. GUI_DispStringHCenterAt("Pulsante 4" , 10, 160);
      141. // USER END
      142. break;
      143. case WM_NOTIFICATION_RELEASED:
      144. // USER START (Optionally insert code for reacting on notification message)
      145. // USER END
      146. break;
      147. // USER START (Optionally insert additional code for further notification handling)
      148. // USER END
      149. }
      150. break;
      151. case ID_BUTTON_4: // Notifications sent by 'Button_5'
      152. switch(NCode) {
      153. case WM_NOTIFICATION_CLICKED:
      154. // USER START (Optionally insert code for reacting on notification message)
      155. GUI_DispStringHCenterAt("Pulsante 5" , 10, 160);
      156. // USER END
      157. break;
      158. case WM_NOTIFICATION_RELEASED:
      159. // USER START (Optionally insert code for reacting on notification message)
      160. // USER END
      161. break;
      162. // USER START (Optionally insert additional code for further notification handling)
      163. // USER END
      164. }
      165. break;
      166. // USER START (Optionally insert additional code for further Ids)
      167. // USER END
      168. }
      169. break;
      170. // USER START (Optionally insert additional message handling)
      171. // USER END
      172. default:
      173. WM_DefaultProc(pMsg);
      174. break;
      175. }
      176. }
      177. /*********************************************************************
      178. *
      179. * Public code
      180. *
      181. **********************************************************************
      182. */
      183. /*********************************************************************
      184. *
      185. * CreateWindow
      186. */
      187. WM_HWIN CreateWindow(void);
      188. WM_HWIN CreateWindow(void) {
      189. WM_HWIN hWin;
      190. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      191. return hWin;
      192. }
      193. // USER START (Optionally insert additional public code)
      194. // USER END
      195. /*************************** End of file ****************************/
      Display All
      Thanks for your time.

      Regards
    • Hi,

      You can disable the focus ability of a widget with WIDGET_SetFocusable(). It makes sense to disable the focus in the WM_INIT_DIALOG case of your dialog callback:

      C Source Code

      1. for (i = 0; i < 5; i++) {
      2. hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0 + i);
      3. WIDGET_SetFocusable(hItem, 0);
      4. }
      Best regards,
      Florian
      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.