views:

130

answers:

1

Hi again :)

I think subject tells everything ...

I need this method only. No need to waste about 6Mb of included unit if only thing I need is one method from that unit ( Themes ) ...

I was thinking of UxTheme unit, but it did not contain proper function. What Windows DLL do I need to import and what API function this method stands for?

Thanks.

P.S. Question is intended to cover not only this particular method, but others too as I will need to do same in MSXML and MM units ...

+1  A: 

@HX_unbanned, apparently you're a little confused. because adding the themes unit to your project only increment the size of the exe in 321 kb aprox. anyway if you want to check if you application is themed (themesEnabled) manually you must follow the next steps.

1) check the version of the comctl32.dll library (must be major or equal to 6)

2) load the uxtheme.dll library

3) import the IsThemeActive and IsAppThemed functions.

4) check the values of theses functions (both must be true)

check this sample

function  ThemesEnabled :Boolean;
const
  ComCtlVersionIE6 = $00060000;
var
  ThemeLib        : THandle;
  IsThemeActive   : function: Boolean; stdcall;
  IsAppThemed     : function: Boolean; stdcall;
begin
  Result:=GetFileVersion('comctl32.dll')>=ComCtlVersionIE6;
  if not Result then exit;
  ThemeLib := LoadLibrary('uxtheme.dll');
  try
    if ThemeLib > 0 then
    begin
        IsAppThemed   := GetProcAddress(ThemeLib, 'IsAppThemed');
        IsThemeActive := GetProcAddress(ThemeLib, 'IsThemeActive');
        Result:=IsAppThemed and IsThemeActive;
    end
    else
    Result:=False;
  finally
   FreeLibrary(ThemeLib);
  end;
end;
RRUZ
Hmmm. Okay, that would be right solution, but - actually adding UxThemes unit to project increments size by ~ 321kb ... if I add Themes unit, there is additional ~ 6,5 MB to compiled exe.Btw - is there any way to find delphi function in corresponding Windows DLL ( API call ) ?
HX_unbanned
Thanks. I will test it asap ;)
HX_unbanned
Yes, HX. Simply search the source code. The Delphi function will call the API function, so when you find either one, you will find the other nearby.
Rob Kennedy
Rob, I was asking it to be more generalized question to, for example, use same approach on MSXML interfaces ... ;)
HX_unbanned