spiegel-keyman/developer/src/setup/CommonControls.pas

70 lines
1.7 KiB
ObjectPascal

(*
Name: CommonControls
Copyright: Copyright (C) SIL International.
Documentation:
Description:
Create Date: 4 Jun 2007
Modified Date: 23 Aug 2007
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 04 Jun 2007 - mcdurdin - Initial version
23 Aug 2007 - mcdurdin - Initial version from Desktop
*)
unit CommonControls;
interface
function InitCommonControl(CC: Integer): Boolean;
implementation
uses
Windows;
type
tagINITCOMMONCONTROLSEX = packed record
dwSize: DWORD; // size of this structure
dwICC: DWORD; // flags indicating which classes to be initialized
end;
PInitCommonControlsEx = ^TInitCommonControlsEx;
TInitCommonControlsEx = tagINITCOMMONCONTROLSEX;
var
ComCtl32DLL: THandle;
_InitCommonControlsEx: function(var ICC: TInitCommonControlsEx): Bool stdcall;
procedure InitCommonControls; external comctl32 name 'InitCommonControls';
procedure InitComCtl;
begin
if ComCtl32DLL = 0 then
begin
ComCtl32DLL := GetModuleHandle(comctl32);
if ComCtl32DLL <> 0 then
@_InitCommonControlsEx := GetProcAddress(ComCtl32DLL, 'InitCommonControlsEx');
end;
end;
function InitCommonControlsEx(var ICC: TInitCommonControlsEx): Bool;
begin
if ComCtl32DLL = 0 then InitComCtl;
Result := Assigned(_InitCommonControlsEx) and _InitCommonControlsEx(ICC);
end;
function InitCommonControl(CC: Integer): Boolean;
var
ICC: TInitCommonControlsEx;
begin
ICC.dwSize := SizeOf(TInitCommonControlsEx);
ICC.dwICC := CC;
Result := InitCommonControlsEx(ICC);
if not Result then InitCommonControls;
end;
end.