CHECKBOX background color

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

    • CHECKBOX background color

      I want to change the checkbox color using function CHECKBOX_SetBoxBkColor(). Problem is the color does not change..
      Here is my simple code:


      WM_TOUCH:

      hItem = WM_GetDialogItem(pMsg->hWin, ID_STATUS_CHECKBOX_1);
      CHECKBOX_SetBoxBkColor(hItem, GUI_YELLOW, CHECKBOX_CI_ENABLED);
      break;

      Any problem with my code? How can I solve the problem?
      Thanks
    • Hi,

      If you are using the SkinFlex look for widgets (which is the default), some functions have no direct impact. This is also true for the checkbox.

      The area of the CHECKBOX consists of multiple colors (there is a small gradient), therefor it wouldn't make sense to set a single color.

      For these widgets you have to use the function <WIDGET>_GetSkinFlexProps() and <WIDGET>_SetSkinFlexProps() to modify their colors.

      Read the properties with the get-function, modify it and write the properties back with the set-function.

      Attached is a short example on how to do this with the checkbox.

      Regards,
      Sven
      Files
    • okay thanks!

      Also, I don't want the checkbox to be set manually by the user, so I put WIDGET_SetFocusable(hItem, 0) in the WM_INIT_DIALOG section.
      Despite this, the checkbox status can still be changed manually by the user..

      Is there another way to do so or am I doing something wrong?
    • Hi,

      You could either set a custom callback for the checkbox and react on WM_TOUCH but simply do nothing:

      C Source Code

      1. hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
      2. WM_SetCallback(hItem, _cbCheckbox);


      C Source Code

      1. static void _cbCheckbox(WM_MESSAGE * pMsg) {
      2. switch (pMsg->MsgId) {
      3. case WM_TOUCH:
      4. break;
      5. default:
      6. CHECKBOX_Callback(pMsg);
      7. break;
      8. }
      9. }


      Or you read the enabled flex skin properties and set them for disabled state. Then you can disable the checkbox but it will look like enbaled. It can be still set programatically.

      C Source Code

      1. static void _cbDialog(WM_MESSAGE * pMsg) {
      2. WM_HWIN hItem;
      3. int NCode;
      4. int Id;
      5. static int Index;
      6. GUI_COLOR aColor0[] = { GUI_DARKRED, GUI_DARKBLUE };
      7. GUI_COLOR aColor1[] = { GUI_RED, GUI_BLUE };
      8. static CHECKBOX_SKINFLEX_PROPS Props = {0};
      9. switch (pMsg->MsgId) {
      10. case WM_INIT_DIALOG:
      11. //
      12. // Initialization of 'Checkbox'
      13. //
      14. hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
      15. CHECKBOX_SetText(hItem, "Check");
      16. WM_DisableWindow(hItem);
      17. CHECKBOX_GetSkinFlexProps(&Props, CHECKBOX_SKINFLEX_PI_ENABLED);
      18. CHECKBOX_SetSkinFlexProps(&Props, CHECKBOX_SKINFLEX_PI_DISABLED);
      19. break;
      20. case WM_NOTIFY_PARENT:
      21. Id = WM_GetId(pMsg->hWinSrc);
      22. NCode = pMsg->Data.v;
      23. switch(Id) {
      24. case ID_BUTTON_0: // Notifications sent by 'Button'
      25. switch(NCode) {
      26. case WM_NOTIFICATION_RELEASED:
      27. hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
      28. if (CHECKBOX_GetState(hItem)) {
      29. CHECKBOX_SetState(hItem, 0);
      30. } else {
      31. CHECKBOX_SetState(hItem, 1);
      32. }
      33. break;
      34. }
      35. break;
      36. }
      37. break;
      38. default:
      39. WM_DefaultProc(pMsg);
      40. break;
      41. }
      42. }
      Display All


      Regards,
      Sven