Skip to content
⌘ NSIS Forum Archive

nsWindows plugin for NSIS

20 posts

zhfi#edited

nsWindows plugin for NSIS

this plugin is modified on nsDialogs, support for window in nsis.

Most of it's macro is the same with nsDialogs, you just need to replace ${NSD_macro} with ${NSW_macro} in your script.

note: if you want to create more than one window at the same time, you need nsWindows.nsh, copy nsWindows.dll to nsis's plugins Directory, and replace "nsWindows::function" with "${nsWindows}::function" in your script.

😁
zhfi#
this is the fixed version of nsWindows.
the plugins, nsh head files and some examples were compressed in the nsWindows.7z documents.

a simple nsWindows's page examples like this:

;handle to window 3
var hwindow3

Function nsWindowsPage3
IsWindow $hwindow3 Create_End
${NSW_CreateWindow} $hwindow3 "WND 3" 1018
;set window pos
; ${NSW_SetWindowPos} $hwindow3 0 0
;set window size
${NSW_SetWindowSize} $hwindow3 200 100

${NSW_CenterWindow} $hwindow3 $hwndparent

;call back function of window 3
${NSW_OnBack} OnBack3

${NSW_CreateButton} 50 -30 50 18u 'WND 1'
Pop $R0
${NSW_OnClick} $R0 nsWindowsPage1

${NSW_CreateButton} 100 -30 50 18u 'WND 2'
Pop $R0
${NSW_OnClick} $R0 nsWindowsPage2

${NSW_Show}
Create_End:
ShowWindow $hwindow3 ${SW_SHOW}
FunctionEnd

Function OnBack3
${NSW_DestroyWindow} $hwindow3
FunctionEnd
zhfi#
Some thing improved for NSIS of Ansi version.
zhfi#
Some thing improved for NSIS of Unicode version.
zhfi#
source code for the plugin is here:
dipal#
How to remove Titlebar from nsWindows??

I used nsWindows as custom messagebox, it works perfectly.

Now i want to remove the Titlebar. but not finding a way to do it.
Can anybody suggest how to achieve this..??

Please find attachment
stass#
After compiling have a message:

Variable "insWindows" not referenced or never set, wasting memory!
What does this mean and what can be done?
Anders#
Originally Posted by stass View Post
What does this mean and what can be done?
It means exactly what is says.

Remove "Var insWindows" from the code...
stass#
In my code, these variables - no. But they are in nsWindows.nsh.
What exactly should be removed there - I do not know ... Tell me please.
Here - nsWindows.nsh three options: http://www.mediafire.com/?dp3oo7427u2gptc
stass#
Originally Posted by Anders View Post
Are you calling NSW_CreateWindow?
Yes, for example:
outfile "nsWindows-test.exe"
!include "nsWindows.nsh"
Section
${NSW_SetWindowSize} $HWNDPARENT 700 300
SectionEnd
Anders#
Originally Posted by stass View Post
Yes, for example:
I said NSW_CreateWindow! That size function is just a helper function and you could look at it's code and make your own version that uses SetWindowPos if that is the only thing in that nsh that you are actually using.
Kuppy#
Create Popup Page with nsWindows

NSIS Show custom page with nsWindows

# Copyright CatsSoft
!include MUI.nsh
!include LogicLib.nsh
!include WinMessages.nsh
!include FileFunc.nsh
!include nsWindows.nsh
Name "nsWindows Welcome"
OutFile "nsWindows Welcome.exe"
Page custom "nsDialogsWelcome"
Page instfiles ""
!insertmacro MUI_LANGUAGE English
LangString ^ShowBtn ${LANG_ENGLISH} "Show ..."
LangString ^BackBtn ${LANG_ENGLISH} "Back ..."
Function .onInit
FunctionEnd
Function "nsDialogsWelcome"
  # ...:: variables ::... #
 
  var /GLOBAL Dialog
  var /GLOBAL HEADLINE
  var /GLOBAL Btn_Show
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 632,i 466,i 0x16)"
  nsDialogs::Create /NOUNLOAD 1044
  Pop $Dialog
  ${If} $Dialog == error
   Abort
  ${EndIf}
  System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 632,i 466,i0)"
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 25% 15% -130u 20u "Welcome to nsDialogs!"
  Pop $HEADLINE
  CreateFont $0 "$(^Font)" 20 500
  SendMessage $HEADLINE ${WM_SETFONT} $0 0
  # ...:: BUTTON SHOW POPUP ::... #
  nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 30% 55% 150u 35u ""
  Pop $Btn_Show
  Strcpy $1 $Btn_Show
  GetFunctionAddress $3 "nsWindowsWelcome"
  nsDialogs::onClick /NOUNLOAD $1 $3
  SendMessage $Btn_Show '${WM_SETTEXT}' '0' "STR:$(^ShowBtn)"
  CreateFont $0 "$(^Font)" 20 500
  SendMessage $Btn_Show ${WM_SETFONT} $0 0
  nsDialogs::Show
FunctionEnd
Var Dlg
Var Btn_Back
Function "nsWindowsWelcome"
  IsWindow $Dlg Show.Warning.Page
  IsWindow $Dlg 0 Warning.Page
  ShowWindow $Dlg ${SW_SHOW}
  Abort
  Warning.Page:
  IsWindow $3 0 List.Page
  IntOp $2 $2 + 1
  List.Page:
  Strcpy $insWindows 0
  Strcpy $hnsWindows 0
  nsWindows::Create /NOUNLOAD $HWNDPARENT $${ExStyle} 0x80000000 "" 1018
  Pop $Dlg
  StrCpy $3 $Dlg
  ShowWindow $Dlg ${SW_HIDE}
  System::Call user32::SetWindowPos(i$Dlg,i0,i0,i0,i632,i466,i0x0002)
  ShowWindow $HWNDPARENT ${SW_HIDE}
  nsWindows::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 25% 15% -130u 20u "Welcome to nsWindows!"
  Pop $HEADLINE
  CreateFont $0 "$(^Font)" 20 500
  SendMessage $HEADLINE ${WM_SETFONT} $0 0
  # ...:: BACK ::... #
  nsWindows::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 30% 55% 150u 35u ""
  Pop $Btn_Back
  Strcpy $1 $Btn_Back
  GetFunctionAddress $3 "On.Click.Back"
  nsWindows::onClick /NOUNLOAD $1 $3
  SendMessage $Btn_Back '${WM_SETTEXT}' '0' "STR:$(^BackBtn)"
  CreateFont $0 "$(^Font)" 20 500
  SendMessage $Btn_Back ${WM_SETFONT} $0 0
  Push $R0
  System::Call /NOUNLOAD "*(i, i, i, i) i.s"
  Pop $R0
  System::Call /NOUNLOAD "User32::GetWindowRect(i, i) i ($Dlg, R0)"
  System::Call /NOUNLOAD "*$R0(i .s, i .s, i .s, i .s)"
  Pop $0
  Pop $1
  Pop $2
  Pop $3
  IntOp $R1 $2 - $0
  IntOp $R2 $3 - $1
  System::Call /NOUNLOAD "User32::GetWindowRect(i, i) i ($HWNDPARENT, R0)"
  System::Call /NOUNLOAD "*$R0(i .s, i .s, i .s, i .s)"
  System::Free $R0
  Pop $0
  Pop $1
  Pop $2
  Pop $3
  IntOp $R3 $2 - $0
  IntOp $R4 $3 - $1
  IntOp $R3 $R3 - $R1
  IntOp $R3 $R3 / 2
  IntOp $R4 $R4 - $R2
  IntOp $R4 $R4 / 2
  IntOp $R3 $0 + $R3
  IntOp $R4 $1 + $R4
  System::Call user32::SetWindowPos(i$Dlg,i0,i$R3,i$R4,i0,i0,i0x0001)
  Pop $R0
  nsWindows::Show
  Show.Warning.Page:
  ShowWindow $Dlg ${SW_SHOW}
  Return
FunctionEnd
# ...:: RETURN MAIN PAGE ::... #
Function "On.Click.Back"
  EnableWindow $hwndparent 1
  ShowWindow $HWNDPARENT ${SW_SHOW}
  BringToFront
  System::Call user32::DestroyWindow(i$Dlg)
  Return
FunctionEnd
Section
  SetAutoClose False
SectionEnd 
zhfi#
updated on 2011/04/13
fixed some problem in nsWindows.nsh
ahmett#
@zhfi,
I just wondering that why you add below code into the header file?

So after I faced some plugins directory problems, I just removed the code below and replaced ${nsWindows} with NSWindows and it works fine with natural plugin directory that comes with NSIS3.0.3.

Thank you for this excellent plugin.

  ;
!echo "Generating nsWindows temp plugins..."
!ifndef nsWindows_warning
!warning "Note: nsWindows.dll must be put in NSIS's Plugins Directory!"
!define nsWindows_warning
!endif
!system 'md "${NSISDIR}\Plugins\nsWindows.tmp\"'
!system 'copy /B /-Y "${NSISDIR}\Plugins\nsWindows.dll" "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"'
!echo "Generating finished!"
;
!AddPluginDir "${NSISDIR}\Plugins\nsWindows.tmp\"
ReserveFile "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"
Anders#
I have no idea why a plug-in header would have crazy copy code like that. Header file code should not write to ${NSISDIR}, it could be read-only for non-admins!