Skip to content
⌘ NSIS Forum Archive

How do I convert InnoSetup Functions to NSIS Functions?

6 posts

meoit#

How do I convert InnoSetup Functions to NSIS Functions?

I'm trying to convert some of InnoSetup function.

----------------Inno Setup code--------------
[code]
function Enable_Water(ParentWnd: HWND; Left, Top: integer; Bmp: HBITMAP; WaterRadius, WaterHeight: integer): BOOL; external 'enablewater@files:WaterControl.dll stdcall';
function Water_Blob(x, y: integer; radius, height: integer): BOOL; external 'waterblob@files:WaterControl.dll stdcall';
function Flatten_Water(): BOOL; external 'flattenwater@files:WaterControl.dll stdcall';
function Disable_Water(): BOOL; external 'disablewater@files:WaterControl.dll stdcall';
function Set_Water_Parent(ParentWnd: HWND): BOOL; external 'setwaterparent@files:WaterControl.dll stdcall';

var
Bmp_Image: TBitmap;

procedure InitializeWizard();
begin
ExtractTemporaryFile('MyImageBMP.bmp');
Bmp_Image := TBitmap.create;
Bmp_Image.LoadFromFile(ExpandConstant('{tmp}\MyImageBMP.bmp'));
Enable_Water(WizardForm.WelcomePage.Handle, 0, 0, Bmp_Image.Handle, 3, 50);
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpWelcome then
begin
Set_Water_Parent(WizardForm.WelcomePage.Handle);
Water_Blob(70, 198, 10, 1000);
end else
if CurPageID = wpFinished then
begin
Set_Water_Parent(WizardForm.FinishedPage.Handle);
Water_Blob(70, 198, 10, 1000);
end else
Flatten_Water();
end;

procedure DeinitializeSetup();
begin
Disable_Water();
Bmp_Image.Free;
end;
----------------Inno Setup code--------------

----------------My NSIS code--------------
Function .onInit
SetOutput $TEMP
File 'D:\Image\MyImageBMP.bmp'
Bmp_Image == TBitmap.create
Bmp_Image.LoadFromFile(ExpandConstant('$TEMP\MyImageBMP.bmp'))
System::Call "WaterControl::Enable_Water(ParentWnd: HWND; Left, Top: integer; Bmp: HBITMAP; WaterRadius, WaterHeight: integer)"
FunctionEnd

Function .onGuiEnd
System::Call "WaterControl:😁isable_Water(ParentWnd: HWND; Left, Top: integer; Bmp: HBITMAP; WaterRadius, WaterHeight: integer)"
Bmp_Image.Free
FunctionEnd

----------------My NSIS code--------------

Result it is not working.

I guess I was wrong in that call: ParentWnd, Left, Top, path of Bmp, WaterRadius, WaterHeight

So how I can define such parameters ?.

I'm bad about nsDialog.
Anders#
Originally Posted by meoit View Post
So how I can define such parameters ?.
Obviously NSIS does not use the same Pascal syntax as Inno. You need to start by reading the System plugin readme if you intend to use the plugin...
meoit#
Yes!. Thanks Anders. I'm reading System Docs.
There are things that I don't understand, you help.
stass#
Work code:

!AddPluginDir .
!include MUI.nsh
OutFile "WaterCtrl_Test.exe"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_WELCOMEFINISHPAGE_BITMAP WizModernImage-Is.bmp
!define MUI_PAGE_CUSTOMFUNCTION_PRE pre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leave
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_Pre pre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Function .onGUIEnd
SetPluginUnload manual
waterctrl::disablewater
System::Free
FunctionEnd
Function .onInit
InitPluginsDir 
SetOutPath $PLUGINSDIR
File waterctrl.dll
SetOutPath $TEMP
FunctionEnd
Function Pre
  System::Call 'user32::LoadImage(i,t,i,i,i,i,) i (0,"$PLUGINSDIR\modern-wizard.bmp",0,0,0,0x2010) .s'
Pop $R0
    System::Call '$PLUGINSDIR\waterctrl::enablewater(i,i,i,i,i,i) i ($HWNDPARENT,0,0,$R0,3,50)'
    System::Call '$PLUGINSDIR\waterctrl::setwaterparent(i $HWNDPARENT)'
    System::Call '$PLUGINSDIR\waterctrl::flattenwater()'
    System::Call '$PLUGINSDIR\waterctrl::waterblob(i,i,i,i) i (70,198,10,1000)'
FunctionEnd
Function leave
    System::Call '$PLUGINSDIR\waterctrl::disablewater()'
FunctionEnd
 Section
 SectionEnd 
download package: http://www.mediafire.com/?1v3zu3t73vcw00j
meoit#
Thanks stass for the package.

I do not understand anything about the parameters in user32::LoadImage....If you explain to me these parameters would be wonderful.
Anders#
Originally Posted by meoit View Post

I do not understand anything about the parameters in user32::LoadImage....If you explain to me these parameters would be wonderful.