Click here to Skip to main content
15,916,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: static libraries & templates Pin
Anthony_Yio8-Oct-03 1:03
Anthony_Yio8-Oct-03 1:03 
GeneralRe: static libraries & templates Pin
ZoogieZork8-Oct-03 5:18
ZoogieZork8-Oct-03 5:18 
GeneralRe: static libraries & templates Pin
cmk8-Oct-03 9:55
cmk8-Oct-03 9:55 
GeneralSecure wireless pc Pin
aprogrammer20027-Oct-03 21:52
aprogrammer20027-Oct-03 21:52 
GeneralMultiple choice..Creating Splitter windows Pin
DarkestDreams7-Oct-03 21:24
sussDarkestDreams7-Oct-03 21:24 
GeneralRe: Multiple choice..Creating Splitter windows Pin
Anthony_Yio8-Oct-03 1:12
Anthony_Yio8-Oct-03 1:12 
Generalradio/check backcolor Pin
Gabriel.P.G7-Oct-03 19:05
Gabriel.P.G7-Oct-03 19:05 
GeneralRe: radio/check backcolor Pin
Mike Danberg7-Oct-03 20:39
Mike Danberg7-Oct-03 20:39 
You don't need to make them owner-drawn, it can be done leaving them as is. However, you are handling the drawing logic to some extent. There is a function that is generic to all controls called OnCtlColor. This is what handles the color for every control created. You need to override this in order to change the color. This is all done in the control's Parent class.

Here's an example:

HBRUSH CChat::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if(m_EditMessageView.m_hWnd == pWnd->m_hWnd)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0));

return m_brWhiteBrush;
}
else
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
}


The part in the else statement is what is already there by default. The part in the if statement was added to change the color.

What's going on in the code is we check the control's handle that we want to change and see if it matches the control that currently has focus. If we are in the correct control, then we apply the changes. The brush that is returned was intialized in the constructor as follows:

m_brWhiteBrush.CreateSolidBrush(RGB(255,255,255));

Returning the brush changes the control's background color. Don't think this really has an effect on checkboxes and radio buttons though.

Mike

P.S. This all comes from a book I have, Microsoft's MFC book by Jeff Prosise. Good book to have Smile | :)
GeneralRe: radio/check backcolor Pin
Rickard Andersson207-Oct-03 22:32
Rickard Andersson207-Oct-03 22:32 
GeneralRe: radio/check backcolor Pin
Jonas Larsson7-Oct-03 23:40
Jonas Larsson7-Oct-03 23:40 
GeneralRe: radio/check backcolor Pin
Rickard Andersson208-Oct-03 0:19
Rickard Andersson208-Oct-03 0:19 
GeneralRe: radio/check backcolor Pin
Jonas Larsson8-Oct-03 0:45
Jonas Larsson8-Oct-03 0:45 
GeneralRe: radio/check backcolor Pin
Gabriel.P.G8-Oct-03 16:58
Gabriel.P.G8-Oct-03 16:58 
GeneralRe: radio/check backcolor Pin
Mike Danberg8-Oct-03 17:41
Mike Danberg8-Oct-03 17:41 
QuestionHow cartoon move on the screen Pin
sunju7-Oct-03 18:35
sunju7-Oct-03 18:35 
Generalauto restart application Pin
GeneKwok7-Oct-03 17:37
GeneKwok7-Oct-03 17:37 
GeneralRe: auto restart application Pin
valikac7-Oct-03 17:53
valikac7-Oct-03 17:53 
GeneralRe: auto restart application Pin
GeneKwok7-Oct-03 19:14
GeneKwok7-Oct-03 19:14 
GeneralRe: auto restart application Pin
Toni787-Oct-03 20:10
Toni787-Oct-03 20:10 
GeneralRe: auto restart application Pin
GeneKwok7-Oct-03 23:22
GeneKwok7-Oct-03 23:22 
GeneralRe: auto restart application Pin
Toni788-Oct-03 8:04
Toni788-Oct-03 8:04 
GeneralInteresting Problem with IOCP and AcceptEx() :: Winsock Pin
valikac7-Oct-03 17:12
valikac7-Oct-03 17:12 
GeneralRe: Interesting Problem with IOCP and AcceptEx() :: Winsock Pin
cmk7-Oct-03 19:17
cmk7-Oct-03 19:17 
GeneralRe: Interesting Problem with IOCP and AcceptEx() :: Winsock Pin
valikac8-Oct-03 5:39
valikac8-Oct-03 5:39 
GeneralOutput box. Pin
esepich7-Oct-03 15:23
esepich7-Oct-03 15:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.