|
-
April 10th, 2000, 08:31 AM
#1
How to change all background colors for controls in a dialog box
Hi everybody,
Here's my problem : in a dialog based application, how can I change the text and background color of all the controls in the dialog box ?
I don't want to change the colors for each control : if I erase one of them in the dialog resource, I have to do the same in the code. I have searched around the OnCtlColor function, but it doesn't work at all. Here is the standard implementation for that function :
HBRUSH MyDlgClass::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
Instead of that code, I've tried to do something like this :
{
CBrush br;
br.CreateSolidBrush(RGB(255, 0, 0)); // Red color
return (HBRUSH) br;
}
Why this code doesn't colorize the controls in red ?
This code produces the right behaviour :
{
if(nCtlColor == CTLCOLOR_EDIT)
Beep(100, 10); // Multiple beep sounds are produced when the dialog appears and one beep is
// produced when a control gets the focus
}
But why returning my personal brush doesn't work ?
Thanks a lot !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|