Article View: borland.public.cppbuilder.nativeapi
Article #32Disabling theming for VCL's
From: Mike Collins
Date: Sat, 02 Aug 2008 22:34
Date: Sat, 02 Aug 2008 22:34
63 lines
2940 bytes
2940 bytes
Hay guys, I've got a little problem that i thought i had fixed but it's
coming back to kick me.
I have a GUI that is built along the lines of MS OneCare / WinDefender. We
use a TImage streatched across the main form and load a JPEG background to
create a graphical backdrop.
At the top of the form i have a toolbar that is created with a transparent
background, using the TCoolBar. This system all works ok on < XP i.e. my
toolbar appears transparent over the image.
However, on XP, when theming is enabled, my toolbar looks crap i.e. when the
user mouses-over, the buttons are painted with a gray background instead of
the image background. I tried to resolve this by disabling theming for the
TToolbar / TCoolbar using some code that i *found*, and it seemed to work.
However, the system frequently falls over and the toolbar reverts to being
painted as is. The code i'm using looks like this,
void TUtilities::DisableXPTheme(HWND p_hWindow)
{
bool bFreeLib = false;
HINSTANCE hUxThemeDLL = NULL;
// See if UxTheme.dll is already loaded, it it is, use it's handle
hUxThemeDLL = GetModuleHandle("UxTheme.dll");
if (!hUxThemeDLL)
{
// If it's not loaded, call LoadLibrary() - must unload the dll once
it is finished
hUxThemeDLL = LoadLibrary("UxTheme.dll");
bFreeLib = true;
}
if (hUxThemeDLL)
{
TSetWindowTheme SetWindowTheme = NULL;
SetWindowTheme = (TSetWindowTheme)GetProcAddress(hUxThemeDLL,
"SetWindowTheme");
if (SetWindowTheme)
{
(SetWindowTheme)(p_hWindow, (wchar_t *)" ", (wchar_t *)" ");
}
//Free the library:
if (bFreeLib)
{
FreeLibrary(hUxThemeDLL);
hUxThemeDLL = NULL;
}
}
}
and i'm calling it from the OnShow like this:
Utils->DisableXPTheme(clbCoolBar->Handle);
Utils->DisableXPTheme(tlbMain->Handle);
has anyone got any suggestions?
Best regards
Mike
Technical Details
Message-ID:
<4894d00f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,58d8bddbf4d0fd32,start X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Mike Collins" <its@TheBottomOfThePost> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Disabling theming for VCL's Date: Sat, 2 Aug 2008 22:34:43 -0000 Lines: 65 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 78.150.175.142 Message-ID: <4894d00f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1217712143 78.150.175.142 (2 Aug 2008 14:22:23 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 2761