Board index » Visual Studio » Painting the background of my control the same colour as my owner

Painting the background of my control the same colour as my owner

Visual Studio305
Hi, whats the best way of painting the background of my child window the

same as my parent window? Im using a tab control and have a dialog

placed over it, but when i use XP styles, the dialog is grey, but the

tab background is white, so i want them to match. (See your graphics

options - right click desktop ->properties, for a comparison of the tab

control).



Ive tried the following 2 pieces of code in OnEraseBkgnd()



CDC* pParentDC = m_pParentWnd->GetDC();

COLORREF crBack = pParentDC->GetBkColor();



CRect rctArea;

this->GetClientRect(&rctArea);

pDC->FillSolidRect(&rctArea, crBack);





and





CDC* pParentDC = m_pParentWnd->GetDC();

CBrush* pBrush = pParentDC->GetCurrentBrush();



CRect rctArea;

this->GetClientRect(&rctArea);

pDC->FillRect(rctArea, pBrush);





Which works ok, ie with no xp style, theyre grey, with XP style they are

white. But the tab background isnt actual white, its slightly off white,

so you can still see a border, so i presume i dont have the correct

colours loaded (ie, theyre reset when not in the middle of the parent

controls paint method).



Can anyone shed some light onto getting the dialogs the same colour please?



Cheers



Mark


-
 

Re:Painting the background of my control the same colour as my owner

"Mark Ingram" <mark.ingram@removeme.softease.com>wrote in message

Quote
Hi, whats the best way of painting the background of my child window the

same as my parent window? Im using a tab control and have a dialog

placed over it, but when i use XP styles, the dialog is grey, but the

tab background is white, so i want them to match.



No promises, but...



http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/shellcc/platform/commctls/userex/functions/enablethemedialogtexture.asp



...have you tried using this API yet?



--

Jeff Partch [VC++ MVP]





-

Re:Painting the background of my control the same colour as my owner

Mark wrote:

Quote


Can anyone shed some light onto getting the dialogs the same colour please?





Maybe GetSysColor(COLOR_3DFACE)



It worked on different shades of gray dialogs,

but I didn't use it on white XP style dialog...



muchan

-

Re:Painting the background of my control the same colour as my owner

Jeff Partch [MVP] wrote:

Quote
"Mark Ingram" <mark.ingram@removeme.softease.com>wrote in message

news:Or%235t19IFHA.2132@TK2MSFTNGP14.phx.gbl...



>Hi, whats the best way of painting the background of my child window the

>same as my parent window? Im using a tab control and have a dialog

>placed over it, but when i use XP styles, the dialog is grey, but the

>tab background is white, so i want them to match.





No promises, but...



http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/shellcc/platform/commctls/userex/functions/enablethemedialogtexture.asp



...have you tried using this API yet?





I tried using that by defining _WIN32_WINNT 0x0501 and trying to call

that function but it caused loads of compilation errors.



I cant use GetSysColor either, because its default is grey, even if you

use XP themes.



I can imagine EnableThemeDialogTexture works in an API project, but its

not working well for me in MFC. Got any ideas howto get around this?

-

Re:Painting the background of my control the same colour as my owner

Mark Ingram wrote:

Quote


I cant use GetSysColor either, because its default is grey, even if you

use XP themes.





How about GetSysColorCOLOR_WINDOW); ?



muchan

-