Thread: VC++ setting text color of a button

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663

    VC++ setting text color of a button

    Hi,

    I searched around in MSDN for a few days, and I finally came up with the following code to set the text color of a radio button in a dialog box. Unfortunately, it doesn't work. I added the OnCtlColor() handler to my Dialog box class(CCodeProject_Dialog2Dlg). My dialog box has radio buttons, check boxes, combo boxes, list boxes and I tried substituting several of their ID's in the code, and none of the text changed color. Can anyone tell me how do change the text color on a button?

    Code:
    HBRUSH CCodeProject_Dialog2Dlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
    {
    	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    	 
    	if(pWnd->GetDlgCtrlID() == IDC_WIN98)
    	{
    		pDC->SetTextColor(RGB(255,0,0));
    		pDC->SetBkMode(TRANSPARENT);
    		
    	}
    
    	return hbr;
    
    }
    Last edited by 7stud; 10-11-2004 at 06:25 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  2. Setting Text simple
    By Nor in forum Windows Programming
    Replies: 5
    Last Post: 04-22-2002, 08:03 AM
  3. Setting static text color -- I know I'm doing something wrong
    By Garfield in forum Windows Programming
    Replies: 4
    Last Post: 01-26-2002, 01:59 PM
  4. Setting text colour
    By JamMan in forum C++ Programming
    Replies: 1
    Last Post: 11-19-2001, 11:43 AM
  5. Setting ListBox text
    By BubbleMan in forum Windows Programming
    Replies: 5
    Last Post: 09-19-2001, 07:09 AM