Reputation: 527
In Nsis, I'm using:
...
nsDialogs::Create 1018
Pop $0
nsDialogs::Show
...
But the size of the dialog box doesn't fit my needs. How can I specify a length for x and y to this dialog ?
Upvotes: 0
Views: 4949
Reputation: 752
My dialog isn't tall enough for all the controls I am putting in.
I tried your two Windows API's and while they worked, the client area of the install overlapped and covered up the OK/Cancel buttons.
I eventually worked out "use resource hacker and ChangeUI". It was much harder than I thought it would be. So, here is a more detailed how-to. I was deeply entrenched with nsDialogs NOT ModernUI. So this is a how-to for nsDialogs resizing of a window created the same as in the examples. ModernUI is covered above.
nsDialogs::Create 1018
What you have a is the code and the preview. Take note of the first line of code...
105 DIALOGEX 0, 0, 280, 162
In your NSIS script, you need to add a call to ChangeAll early on.
ChangeUI all tall_UI.exe
Page custom nsDialogsPage
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
...
That did it for me. You will do some trial and error, always hit commpile and save in ResourceHacker and then rebuild your NSI. You may note that your dialog is bigger or smaller than the preview shown in ResourceHacker. That is because NSIS does scale your dialog based on font size, DPI... stuff like that. Try and retry till it looks good.
You will note that nsDialogs::Create 1018 matches the number in the 5th line of resource hacker:
CONTROL "", 1018, STATIC, SS_BLACKRECT | WS_CHILD | WS_GROUP, 7, 7, 266, 160
I did some testing after getting this demo together and the positioning and size of that 1018 resource does have an effect but I can't tell you why it isn't black.
Full code of my demo is below showing.
#Created with NSIS version 2.46 downloaded from SourceForge.net
#Based on "Adding Controls" section of user docs
# http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html#step-add
!include nsDialogs.nsh
Name "Launchpad"
OutFile "Master Installer.exe"
BrandingText " "
Caption "Launchpad"
RequestExecutionLevel admin
SetFont "Arial" 10
VIProductVersion "2.5.0.0"
Var Dialog
Var Button
ChangeUI all tall_UI.exe
Page custom nsDialogsPage
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
# It will create a new dialog in the page and return its HWND on the stack. The result must be popped from the stack to prevent stack corruption. If the result is error, the dialog couldn't be created.
${If} $Dialog == error
Abort
${EndIf}
# ${NSD_Create*} x y width height text
## Going to use $0 for y of each new control.
StrCpy $0 "29"
${NSD_CreateButton} 50% "$1u" 25% 12u "Product Manual"
Pop $Button
${NSD_OnClick} $Button Manual_Install_Clicked
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
Pop $Button
${NSD_OnClick} $Button Product1_Install_Clicked
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 2 Installer"
Pop $Button
## ${NSD_OnClick} ...
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 3 Installer"
Pop $Button
## ${NSD_OnClick} ...
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 4 Installer"
Pop $Button
## ${NSD_OnClick} ...
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
Pop $Button
## ${NSD_OnClick} ...
IntOp $0 $0 + 18
IntOp $1 $0 - 2
${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
Pop $Button
## ${NSD_OnClick} ...
IntOp $0 $0 + 18
IntOp $1 $0 - 2
nsDialogs::Show
FunctionEnd
Function ExecInstall
pop $0
ExecWait $0 $1
IfErrors 0 ExecDone
MessageBox MB_OK|MB_IconExclamation "$1 $0 not found"
ExecDone:
##Call Update_Install_Statuses
FunctionEnd
Function Manual_Install_Clicked
ExecShell "open" "$EXEDIR\Manual\Manual.PDF"
FunctionEnd
Function Product1_Install_Clicked
Exec "Explorer.exe $EXEDIR\Support Files"
FunctionEnd
Function Product2_Install_Clicked
Push "$EXEDIR\Product2 Folder\Product2 Installer.exe"
Call ExecInstall
FunctionEnd
Section
SectionEnd
Upvotes: 0
Reputation: 101666
If you want to resize everything it is probably better to use Resource Hacker and ChangeUI
but you can do it at runtime:
!include nsDialogs.nsh
Function mypage
System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 640,i 480,i 0x16)' ; Resize outer dialog
nsDialogs::Create 1018
Pop $0
System::Call 'user32::MoveWindow(i$0,i0,i0,i 600,i 200,i0)' ; Resize inner (nsDialogs) page
${NSD_CreateLabel} 0 10u 100% 10u "Hello, welcome to nsDialogs!"
Pop $0
SetCtlColors $0 0xffffff 0xff2255
nsDialogs::Show
FunctionEnd
page custom mypage
Upvotes: 3