🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Mike Collins Sat, 02 Aug 2008 22:34
Disabling theming for VCL's
#32
Author: Mike Collins
Date: Sat, 02 Aug 2008 22:34
63 lines
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
Re: Disabling theming for VCL's
#33
Author: Remy Lebeau (TeamB)
Date: Mon, 04 Aug 2008 17:11
36 lines
2415 bytes
"Mike Collins" <its@TheBottomOfThePost> wrote in message 
news:4894d00f@newsgroups.borland.com...

> We use a TImage streatched across the main form and load
> a JPEG background to create a graphical backdrop.

I would suggest using the form's OnPaint event for that instead.

> However, the system frequently falls over and the toolbar reverts
> to being painted as is.

The toolbar's HWND is likely be recreated in response to some action.  Every 
time a new HWND is created, you will have to call SetWindowTheme() again.

>   // See if UxTheme.dll is already loaded, it it is, use it's handle

That is redundant.  LoadLibrary() already does that for you.  DLLs are 
reference counted.  If the DLL is already loaded, LoadLibrary() will simply 
increment its reference count, not reload it anew.  The DLL is not freed 
until its reference count falls to 0.

>         (SetWindowTheme)(p_hWindow, (wchar_t *)" ", (wchar_t *)" ");

You can't cast a char* to a wchar_t* like that.  If you need to use a 
wchar_t* literal, then prefix it with an 'L' instead:

    (SetWindowTheme)(p_hWindow, L" ", L" ");

BTW, you did not say which version of BCB you are using?  If BCB2006 or 
later, then the VCL has native support for UxTheme.dll, so you don't have to 
access it manually.  It also has ways of controlling when theming should be 
active or not for any given control.


Gambit 
Re: Disabling theming for VCL's
#52
Author: mikecollins999
Date: Tue, 12 Aug 2008 15:11
11 lines
1592 bytes
where have all the news groups gone?

I've been away for a week and everyone has disapeared.

Anyway - thats for the reply remy (not sure if this post will appear)
- any suggestions on how i can detect when the ttoolbar's WHND is
created / recreated?

Many thanks,

Mike
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads