dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Is there any straightforward way to change the background color of a check box?

  1. #1
    Join Date
    Jul 2019
    Posts
    2

    Is there any straightforward way to change the background color of a check box?

    Name:  test1 (2).png
Views: 155
Size:  6.6 KB

    I'm trying to change the white rectangle that makes up the background of the checkbox to gray like the surrounding color. However it seems that there is no easy way to do this. Is this even possible? I was told to try overriding #OnCtlColor# but I haven't been able to get that to work. My understanding of all things Windows and MFC is definitely lacking so my attempt could simply be wrong. I'm leaving for a moment soon but when I come back I can post the code of my attempt if that helps. Other than that, does anyone have any ideas / pointers to lead me in the right direction? Thanks.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,562

    Re: Is there any straightforward way to change the background color of a check box?

    Have a look at CMFCButton::SetFaceColor
    Victor Nijegorodov

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,555

    Re: Is there any straightforward way to change the background color of a check box?

    Code:
    HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    	HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    	if(pWnd->GetDlgCtrlID() == IDC_MYBUTTON)
    	      pDC->SetBkColor(RGB(255, 255, 255));
    	return hbr;
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)