Re: How do I change the color of a button in a dialog?




The problem is that I would like MFC to handle the drawing of the buttons
control on my dialog, I only wish to change the button control color.

I have my dialog class derived from CDialog, in this class I have-

HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

In which I analyze the dialog items such as EDIT controls or BUTTON controls
and set the colors for some of them by modifying the returned brush, or by
calling-
pDC->SetBkColor(..)
pDC->SetTextColor(..) etc.

It does work fine with EDIT control but does not affect the BUTTON
control!!!
What should be done?




"William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx> wrote in message
news:u%23%23aiz6GGHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
> "Dov Aharonson" <dov@xxxxxxxxxxx> wrote in message
> news:OXrzKo6GGHA.312@xxxxxxxxxxxxxxxxxxxxxxx
>>I need to change the color of a button in a dialog box in runtime as a
>>result of user interaction with the program.
>>
>> Help is greatly appreciated
>
> Mark the button as owner drawn and respond to the message WM_CTLCOLORBTN
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/buttons/buttonreference/buttonmessages/wm_ctlcolorbtn.asp
>
> Regards,
> Will
>
>


.



Relevant Pages

  • Re: How do I change the color of a button in a dialog?
    ... > control on my dialog, I only wish to change the button control color. ... styles do not use the returned brush. ... Drawing push buttons requires several ... I'm no expert at MFC so I can't tell you whether it will do what you want. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Is it possible to separate the event-handling part from the control?
    ... parent should have absolutely NO KNOWLEDGE of how a control is drawn! ... colors, fonts, styles, and all other parameters involved in drawing it. ... Also, in MFC, some controlshave a concept ... of "owner" as I mentioned to David. ...
    (microsoft.public.vc.mfc)
  • Re: How to assign unique message codes and resource IDs?
    ... The control sends a message to the parent dialog under certain ... The control creates edit controls dynamically. ... the CListCtrl, so there is no possibility of conflict if you handle all the edit messages ...
    (microsoft.public.vc.mfc)
  • Re: OnKillFocus problems
    ... i've also created a set of in-place validation for edit controls. ... Basically, I've over-ridden OnKillFocus() and do my validation there, ... To add further to my confusion, you can't leave the edit control unless ...
    (microsoft.public.vc.mfc)
  • Re: CView::OnCtlColor to change font on a single CStatic
    ... I would like to reduce the font size on it. ... font for the above CStatic control (The rest of the screen and controls can ... Note that edit controls will fail to work correctly if the background ... background, but unless it is a solid bitmap for the brush, you will have registration ...
    (microsoft.public.vc.mfc)