#define AW = (Defined UNICODE) ? "W" : "A"
[Setup]
AppName=VCL Styles
AppVersion=1.5
DefaultDirName={pf}\VCL Styles
Compression=none
OutputDir=.
[Languages]
Name: "RU"; MessagesFile: "compiler:Languages\Russian.isl"
[Files]
Source: "VclStylesinno.dll"; Flags: dontcopy
Source: "Amakrits.vsf"; Flags: dontcopy
[Code]
var
TestForm: TSetupForm;
Timer: TTimer;
OldProc: Longint;
procedure LoadVCLStyle(VClStyleFile: String); external 'LoadVCLStyle{#AW}@files:VclStylesinno.dll stdcall';
procedure UnLoadVCLStyles; external 'UnLoadVCLStyles@files:VclStylesinno.dll stdcall';
function GetDC(hWnd: HWND): LongWord; external 'GetDC@user32 stdcall';
function BitBlt(DestDC: LongWord; X, Y, Width, Height: Integer; SrcDC: LongWord; XSrc, YSrc: Integer; Rop: DWORD): BOOL; external 'BitBlt@gdi32 stdcall';
function ReleaseDC(hWnd: HWND; hDC: LongWord): Integer; external 'ReleaseDC@user32.dll stdcall';
function DwmIsCompositionEnabled(var pfEnabled: BOOL): Longint; external 'DwmIsCompositionEnabled@dwmapi.dll stdcall delayload';
function isWin6: boolean;var ver: TWindowsVersion;
begin
GetWindowsVersionEx(ver);
if (ver.Major >= 6) then result:=true
else result:=false;
end;
function CompositionEnabled: boolean;var r: bool;
begin
if isWin6 then
if DwmIsCompositionEnabled(r) = 0 then
result:=r else result:=false;
end;
procedure FormT(Sender: TObject);
var
FormDC, DC: LongWord;
begin
DC:= GetDC(TestForm.Handle);
FormDC := GetDC(WizardForm.Handle);
BitBlt(DC, 0, 0, WizardForm.ClientWidth, WizardForm.ClientHeight, FormDC, 0, 0, $00CC0020);
ReleaseDC(TestForm.Handle, DC);
ReleaseDC(WizardForm.Handle, FormDC);
end;
procedure FormM(Sender: TObject);
begin
if CompositionEnabled then
Timer.Enabled:= false;
end;
procedure FormR(Sender: TObject);
begin
if CompositionEnabled then
Timer.Enabled:= True;
end;
const
GWL_STYLE = -16;
WS_MAXIMIZEBOX = $10000;
GWL_WNDPROC = -4;
WM_MOVE = $3;
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
procedure OnCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Timer.Free;
SetWindowlong(TestForm.Handle, GWL_WNDPROC, OldProc);
TestForm.Free;
CanClose:= True;
end;
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('Amakrits.vsf');
LoadVCLStyle(ExpandConstant('{tmp}\Amakrits.vsf'));
if CompositionEnabled then begin
TestForm := CreateCustomForm;
with TestForm do
begin
BorderStyle:= bsSingle;
SetWindowLong(handle, GWL_STYLE, GetWindowLong(handle, GWL_STYLE)and(not WS_MAXIMIZEBOX));
Left:= -1000;
ClientWidth:= ScaleX(497);
ClientHeight:= ScaleY(363);
Caption := 'Test Form';
OnCloseQuery:= @OnCloseQuery;
Show;
end;
end;
Result := True;
end;
function MyProc(h: HWND; Msg, wParam, lParam: longint): Longint;
begin
if Msg=WM_MOVE then
begin
TestForm.Left:= WizardForm.Left;
TestForm.Top:= WizardForm.Top;
end;
Result:= CallWindowProc(OldProc, h, Msg, wParam, lParam);
end;
procedure InitializeWizard();
begin
with WizardForm do
begin
ClientWidth:= ScaleX(497);
ClientHeight:= ScaleY(363);
end;
if CompositionEnabled then begin
TestForm.Caption:= WizardForm.Caption;
TestForm.Left:= WizardForm.Left;
TestForm.Top:= WizardForm.Top;
OldProc:= SetWindowLong(WizardForm.Handle, GWL_WNDPROC, CallbackAddr('MyProc'));
Timer := TTimer.Create(MainForm);
with Timer do
begin
Interval:= 1;
OnTimer:= @FormT;
end;
Application.OnMinimize:= @FormM;
Application.OnRestore:= @FormR;
end;
end;
procedure DeinitializeSetup();
begin
UnLoadVCLStyles;
end;