CHECKBOX

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

    • Hello,

      Not sure if we understand you correctly, but this issue does not seem to be related to Embedded Studio.
      Could you clarify what product you are using and what you are trying to achieve exactly?

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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 contact us per e-mail.
      Alternatively our support ticketing system can be used as well: segger.com/ticket/
    • Hi,

      try this:

      C Source Code

      1. #include "DIALOG.h"
      2. #include "stdlib.h"
      3. /*********************************************************************
      4. *
      5. * Externals
      6. *
      7. **********************************************************************
      8. */
      9. /*********************************************************************
      10. *
      11. * Defines
      12. *
      13. **********************************************************************
      14. */
      15. #define RADIUS 50
      16. /*********************************************************************
      17. *
      18. * Static data
      19. *
      20. **********************************************************************
      21. */
      22. /*********************************************************************
      23. *
      24. * Static code
      25. *
      26. **********************************************************************
      27. */
      28. /*********************************************************************
      29. *
      30. * _cbBk
      31. */
      32. static void _cbBk(WM_MESSAGE * pMsg) {
      33. WM_HWIN hItem;
      34. int NCode;
      35. int Id;
      36. int State;
      37. int xPos;
      38. int yPos;
      39. GUI_COLOR aColor[] = {GUI_RED, GUI_GREEN, GUI_BLUE, GUI_MAGENTA, GUI_CYAN, GUI_YELLOW };
      40. int Index;
      41. switch (pMsg->MsgId) {
      42. case WM_PAINT:
      43. //
      44. // Clear with white
      45. //
      46. GUI_SetBkColor(GUI_WHITE);
      47. GUI_Clear();
      48. //
      49. // Calculate the center of the screen
      50. //
      51. xPos = LCD_GetXSize() >> 1;
      52. yPos = LCD_GetYSize() >> 1;
      53. //
      54. // get 'random' index and set a foreground color to draw the circles with
      55. //
      56. Index = rand() % GUI_COUNTOF(aColor);
      57. GUI_SetColor(aColor[Index]);
      58. //
      59. // Get handle of the CHECKBOX and get its state
      60. //
      61. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CHECK0);
      62. State = CHECKBOX_GetState(hItem);
      63. if (State == 0) {
      64. GUI_DrawCircle(xPos, yPos, RADIUS); // Only a cricle outline
      65. } else {
      66. GUI_FillCircle(xPos, yPos, RADIUS); // A circle filled with color
      67. }
      68. break;
      69. case WM_NOTIFY_PARENT:
      70. //
      71. // Check who sends a message and what type of message
      72. //
      73. Id = WM_GetId(pMsg->hWinSrc);
      74. NCode = pMsg->Data.v;
      75. switch (Id) {
      76. case GUI_ID_CHECK0:
      77. switch (NCode) {
      78. case WM_NOTIFICATION_VALUE_CHANGED:
      79. //
      80. // Each time the state of the CHECKBOX changes we mark the desktop window
      81. // as invalid, next time GUI_Delay() (or GUI_Exec()) gets called the window
      82. // gets redrawn.
      83. //
      84. WM_InvalidateWindow(WM_HBKWIN);
      85. break;
      86. }
      87. break;
      88. }
      89. break;
      90. default:
      91. WM_DefaultProc(pMsg);
      92. break;
      93. }
      94. }
      95. /*********************************************************************
      96. *
      97. * Public code
      98. *
      99. **********************************************************************
      100. */
      101. /*********************************************************************
      102. *
      103. * MainTask
      104. */
      105. void MainTask(void) {
      106. WM_HWIN hCheckbox;
      107. CHECKBOX_SKINFLEX_PROPS Props;
      108. GUI_Init();
      109. //
      110. // Set a callback for the desktop window, this will manage the
      111. // drawing and handles the notifications send from the CHECKBOX.
      112. //
      113. WM_SetCallback(WM_HBKWIN, _cbBk);
      114. //
      115. // Create a CHECKBOX as child of the desktop window (WM_HBKWIN).
      116. //
      117. hCheckbox = CHECKBOX_CreateEx(10, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_CHECK0);
      118. while (1) {
      119. GUI_Delay(100);
      120. }
      121. }
      122. /*************************** End of file ****************************/
      Display All

      Regards,
      Sven
    • Hi Sven,

      Could you please help me with the logic. I have dumped the code provided by you but the same case is repeated here: Checkbox is not enabling and color is not filled. Initially it is unchecked and checkbox is not giving functionality to enable it.

      Regards,
      Saieesh Kumar A