Skip to content

Commit

Permalink
Added hook for support bitmap checkmarks (resource 110)
Browse files Browse the repository at this point in the history
  • Loading branch information
RRUZ committed Nov 5, 2015
1 parent 72b5888 commit 0746554
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 6 deletions.
4 changes: 2 additions & 2 deletions NSIS plugin/Scripts/Modern UI/Basic.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ SectionEnd
Function .onInit
InitPluginsDir
;Get the skin file to use
File /oname=$PLUGINSDIR\AmethystKamri.vsf "..\..\Styles\AmethystKamri.vsf"
File /oname=$PLUGINSDIR\VCLStyle.vsf "..\..\Styles\Auric.vsf"
;Load the skin using the LoadVCLStyle function
NSISVCLStyles::LoadVCLStyle $PLUGINSDIR\AmethystKamri.vsf
NSISVCLStyles::LoadVCLStyle $PLUGINSDIR\VCLStyle.vsf
FunctionEnd

78 changes: 78 additions & 0 deletions NSIS plugin/Vcl.Styles.NSIS.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

interface

{$DEFINE HookFileDialogs}

uses
System.Types,
System.SysUtils,
Expand Down Expand Up @@ -129,6 +131,7 @@ implementation
Winapi.CommCtrl,
DDetours,
Winapi.CommDlg,
Vcl.Styles.Utils.Graphics,
Vcl.Styles.Utils.SysControls;

type
Expand Down Expand Up @@ -612,6 +615,8 @@ procedure TThemedNSISControls.RemoveHook;
end;
end;

{$IFDEF HookFileDialogs}

const
commdlg32 = 'comdlg32.dll';

Expand Down Expand Up @@ -680,8 +685,75 @@ procedure UnHookFileDialogs;
InterceptRemove(@TrampolineGetSaveFileNameA);
end;

{$ENDIF}

var

Trampoline_LoadBitmapA : function (hInstance: HINST; lpBitmapName: PAnsiChar): HBITMAP; stdcall;


function Detour_LoadBitmapA(hInstance: HINST; lpBitmapName: PAnsiChar): HBITMAP; stdcall;
var
LBitMap : TBitmap;
LRect : TRect;
LSize : TSize;
begin
if IS_INTRESOURCE(PChar(lpBitmapName)) then
case Integer(lpBitmapName) of
110 : begin

LBitMap:=TBitmap.Create;
try
//LBitmap.Handle := Result;
LBitMap.SetSize(16 * 6, 16);
LBitMap.PixelFormat := pf8bit;
StyleServices.GetElementSize(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxUncheckedNormal), TElementSize.esMinimum, LSize);
if (LSize.Width>=16) or (LSize.Height>=16) then
LBitMap.Canvas.Brush.Color:= StyleServices.GetSystemColor(clWindow)
else
LBitMap.Canvas.Brush.Color:=clFuchsia;

//LBitMap.TransparentColor := clFuchsia;

LRect := Rect(0, 0, LBitMap.Width, LBitMap.Height);
LBitMap.Canvas.FillRect(LRect);


LRect := Rect(0, 1, 16, 15);
OffsetRect(LRect, 16, 0);
DrawStyleElement(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxUncheckedNormal), LRect);

OffsetRect(LRect, 16, 0);
DrawStyleElement(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxCheckedNormal), LRect);

OffsetRect(LRect, 16, 0);
DrawStyleElement(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxCheckedDisabled), LRect);

OffsetRect(LRect, 16, 0);
DrawStyleElement(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxUncheckedDisabled), LRect);

OffsetRect(LRect, 16, 0);
DrawStyleElement(LBitMap.Canvas.Handle, StyleServices.GetElementDetails(tbCheckBoxCheckedDisabled), LRect);

//LBitMap.SaveToFile(Format('C:\Dephi\github\vcl-styles-plugins\NSIS plugin\Scripts\Modern UI\check_%dx%d.bmp', [LSize.Width, LSize.Height]));

Exit(LBitMap.Handle);
finally
LBitmap.ReleaseHandle;
LBitMap.Free;
end;
end;
end;

Result:= Trampoline_LoadBitmapA(hInstance, lpBitmapName);
end;



initialization
{$IFDEF HookFileDialogs}
HookFileDialogs;
{$ENDIF}
NSIS_IgnoredControls := TList<HWND>.Create;
TSysStyleManager.OnBeforeHookingControl := @BeforeNSISHookingControl;
TSysStyleManager.OnHookNotification := @HookNotificationNSIS;
Expand All @@ -690,9 +762,15 @@ initialization
if StyleServices.Available then
ThemedNSISControls := TThemedNSISControls.Create;

@Trampoline_LoadBitmapA := InterceptCreate(user32, 'LoadBitmapA', @Detour_LoadBitmapA);


finalization
{$IFDEF HookFileDialogs}
UnHookFileDialogs;
{$ENDIF}
Done;
NSIS_IgnoredControls.Free;
InterceptRemove(@Trampoline_LoadBitmapA);

end.
Binary file modified NSIS plugin/VersionInfoANSI.RES
Binary file not shown.
4 changes: 2 additions & 2 deletions NSIS plugin/VersionInfoANSI.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 VERSIONINFO
FILEVERSION 1,0,4,5
FILEVERSION 1,0,5,1
PRODUCTVERSION 1
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
Expand All @@ -10,7 +10,7 @@
BEGIN
VALUE "CompanyName","The Road To Delphi\000"
VALUE "FileDescription","VCL Styles for NSIS Ansi\000"
VALUE "FileVersion","1.0.4.5\000"
VALUE "FileVersion","1.0.5.1\000"
VALUE "InternalName","NSISVCLStyles\000"
VALUE "LegalCopyright","The Road To Delphi Copyright 2014\000"
VALUE "LegalTrademarks","The Road To Delphi\000"
Expand Down
Binary file modified NSIS plugin/VersionInfoUNICODE.RES
Binary file not shown.
4 changes: 2 additions & 2 deletions NSIS plugin/VersionInfoUNICODE.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 VERSIONINFO
FILEVERSION 1,0,4,5
FILEVERSION 1,0,5,1
PRODUCTVERSION 1
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
Expand All @@ -10,7 +10,7 @@
BEGIN
VALUE "CompanyName","The Road To Delphi\000"
VALUE "FileDescription","VCL Styles for NSIS Unicode\000"
VALUE "FileVersion","1.0.4.5\000"
VALUE "FileVersion","1.0.5.1\000"
VALUE "InternalName","NSISVCLStyles\000"
VALUE "LegalCopyright","The Road To Delphi Copyright 2014\000"
VALUE "LegalTrademarks","The Road To Delphi\000"
Expand Down

0 comments on commit 0746554

Please sign in to comment.