 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Boki Guest
|
Posted: Mon Jul 14, 2003 8:19 pm Post subject: Detecting if XP theme is ON |
|
|
Hi,
I have created THEMED SpinEdit with using next procedures:
function OpenThemeData(hwnd: HWND; pszClassList: LPCWSTR): THandle;
stdcall;
external 'uxtheme.dll';
function CloseThemeData(hTheme: THandle): HRESULT; stdcall;
external 'uxtheme.dll';
function DrawThemeBackground(hTheme: THandle; hdc: HDC; iPartId, iStateId:
Integer; const pRect: TRect; pClipRect: PRECT): HRESULT; stdcall;
external 'uxtheme.dll';
1. How to detect when theme is enabled and only THEN to display themed
graphics. And
how to detect NON WindowsXP Operating system to avoid calls to these
procedures.
2. Probably when I run component on some OS where "uxtheme.dll" not exist,
program with my component will show error. I have not check this yet, but
probably this will be result. And people who don't have WinXP will probably
not be able to install my component.
Regards
Boki
|
|
| Back to top |
|
 |
Gary Williams Guest
|
Posted: Mon Jul 14, 2003 9:59 pm Post subject: Re: Detecting if XP theme is ON |
|
|
Boki wrote:
| Quote: | 1. How to detect when theme is enabled and only THEN to display themed
graphics. And
how to detect NON WindowsXP Operating system to avoid calls to these
procedures.
|
Under Delphi 7, this boolean property seems to indicate the current state of
the XP theme:
ThemeServices.ThemesEnabled (use the Themes.pas VCL unit)
It is only True if the user is running XP and the XP theme is enabled.
As near as I can tell, it is undocumented.
-Gary
|
|
| Back to top |
|
 |
Boki Guest
|
Posted: Mon Jul 14, 2003 10:29 pm Post subject: Re: Detecting if XP theme is ON |
|
|
Hi
It is unbelievable how this theming stuff is complicated :(
I will try to read ThemeSrv for this property. This property goo deep into
units :)
Boki
"Gary Williams" <0@0.0.0.0> wrote
| Quote: |
Boki wrote:
1. How to detect when theme is enabled and only THEN to display themed
graphics. And
how to detect NON WindowsXP Operating system to avoid calls to these
procedures.
Under Delphi 7, this boolean property seems to indicate the current state
of
the XP theme:
ThemeServices.ThemesEnabled (use the Themes.pas VCL unit)
It is only True if the user is running XP and the XP theme is enabled.
As near as I can tell, it is undocumented.
-Gary
|
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Jul 14, 2003 10:41 pm Post subject: Re: Detecting if XP theme is ON |
|
|
You see, it's really much easier using TThemeServices :-)
| Quote: | 1. How to detect when theme is enabled and only THEN to display themed
graphics. And
how to detect NON WindowsXP Operating system to avoid calls to these
procedures.
2. Probably when I run component on some OS where "uxtheme.dll" not exist,
program with my component will show error. I have not check this yet, but
probably this will be result. And people who don't have WinXP will
probably
not be able to install my component.
|
Use LoadLibrary instead of declaring external functions. If LoadLibrary
fails (returns value <= 0) you know theming is not possible on this system.
When LoadLibrary succeeds, use GetProcAddress to init your procedures. This
should answer both questions. You will find many examples for LoadLibrary /
GetProcAddress using your favourite search engine (or once again take a look
a UxTheme.pas).
Jens
|
|
| Back to top |
|
 |
Boki Guest
|
Posted: Mon Jul 14, 2003 10:48 pm Post subject: Re: Detecting if XP theme is ON |
|
|
Hi Jens
I can't use this unit, because license not allow this to me, and I want to
make component to work in delphi 6
i will look more in ThemeSrv :(
Regards.
Boki
"Jens Gruschel" <no_spam (AT) pegtop (DOT) net> wrote
| Quote: | You see, it's really much easier using TThemeServices :-)
1. How to detect when theme is enabled and only THEN to display themed
graphics. And
how to detect NON WindowsXP Operating system to avoid calls to these
procedures.
2. Probably when I run component on some OS where "uxtheme.dll" not
exist,
program with my component will show error. I have not check this yet,
but
probably this will be result. And people who don't have WinXP will
probably
not be able to install my component.
Use LoadLibrary instead of declaring external functions. If LoadLibrary
fails (returns value <= 0) you know theming is not possible on this
system.
When LoadLibrary succeeds, use GetProcAddress to init your procedures.
This
should answer both questions. You will find many examples for LoadLibrary
/
GetProcAddress using your favourite search engine (or once again take a
look
a UxTheme.pas).
Jens
|
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Wed Jul 16, 2003 1:13 pm Post subject: Re: Detecting if XP theme is ON |
|
|
That's why it has been recommended to use my theme manager (together with
ThemeServices) for D6. It is exactly the same for D5/6 and the one in D7.
So following code works with Delphi 7 (without your theme manager) and
Delphi 5/6 (with your theme manager)?
uses ThemeSrv;
ThemeServices.DrawElement(...
So I can write a component that uses ThemeSrv and can tell people to use
Delphi 7 or download your theme manager?
Jens
|
|
| Back to top |
|
 |
Mike Lischke Guest
|
Posted: Wed Jul 16, 2003 5:36 pm Post subject: Re: Detecting if XP theme is ON |
|
|
Jens Gruschel wrote:
| Quote: | So I can write a component that uses ThemeSrv and can tell people to use
Delphi 7 or download your theme manager?
|
Wrap the uses clause like this:
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ImgList, ActiveX, StdCtrls, Menus, Printers,
SyncObjs // critical sections
{$ifdef ThemeSupport}
{$ifndef COMPILER_7_UP}
, ThemeSrv, TMSchema, UxTheme // Windows XP themes support. Get these units from www.delphi-gems.com.
{$else}
, Themes, UxTheme
{$endif COMPILE_7_UP}
{$endif ThemeSupport}
;
The global ThemeServices class is in both implementations.
Mike
--
www.delphi-gems.com
www.delphi-unicode.net
www.lischke-online.de
|
|
| Back to top |
|
 |
Joris Guest
|
Posted: Wed Jul 16, 2003 6:18 pm Post subject: Re: Detecting if XP theme is ON |
|
|
"Boki" <nikolic-nospam-bojan (AT) hotmail (DOT) com> wrote
| Quote: | It is unbelievable how this theming stuff is complicated
|
The benefit being that we finally got rid of standardized, intuitive and
clear user interfaces, I can see it's worth it though.
Joris
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Wed Jul 16, 2003 7:17 pm Post subject: Re: Detecting if XP theme is ON |
|
|
Vielen lieben Dank, Mike!
Jens
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|