Answered Change Text Color of a Checkbox

  • Thursday, March 08, 2012 1:05 PM
     
     

    Hi,
    The problem domain is: C++, Win32 (Compatible with XP, Vista, Win7, Win8 - 32 & 64 bits)
    I am using Visual Studio 2010 - VC++ - Project is based on ATL, WTL

    I have already seen this and it does not help me. http://social.msdn.microsoft.com/Forums/en-NZ/vcgeneral/thread/cd6e7637-3550-4d1c-9b11-4f0f0965675f

    I have a checkbox control (BUTTON) on my dialogbox resource.
    CONTROL         "Remember me",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,89,273,167,11
    I am already handling: WM_CTLCOLORSTATIC - by which I am maintaining transparency of the controls and changing the text color of controls.
    For some reasons, (I am not aware of) the Dialogbox also gets this WindowMessage for checkbox as well, even though it is a Button not a Static.

    This is a basic code written on OnCtlColorStatic()
    DefWindowProc()
    ::SetTextColor((HDC)wParam, m_crText);
    ::SetBkMode((HDC)wParam, TRANSPARENT);
    return Brush...

    It is working fine for all Static controls, and even for the checkbox it is making it transparent - BUT it is unable to change the Text Color of the checkbox!

    When I made the Checkbox as BS_OWNERDRAW then I started to get the WM_CTLCOLORBTN message (which is good) but then whole control is not drawn and in the DialogBox class I will have to handle the WM_DRAWITEM and to draw the full checkbox control myself which is what I do not want to do.

    So how to solve this issue?

    Regards - Habib


    • Moved by Bob_BaoMVP Friday, March 09, 2012 2:43 AM (From:Application Compatibility for Windows Desktop Development)
    •  

All Replies