Skip to content
⌘ NSIS Forum Archive

Shifting the default text position in NSIS installer pages

23 posts

miraz.zaidi#

Shifting the default text position in NSIS installer pages

I am using a background image for my installer pages, I have set all the other controls transparent.
There is a logo in the background image , which is overlapping with text on installer pages like the text on welcome page, license page etc.

So is it possible that I can shift the position of this text from default to the one suitable for me, so that my background logo remains visible? Please Help.

Thanks.
Afrow UK#
For all pages except the welcome and finish pages, I would recommend you modify the UI itself using Resource Hacker. The UI is Contrib\Graphics\UIs\modern.exe - copy to your script directory. You can apply it using !define MUI_UI modern_new.exe. You can just delete a load of controls that you are currently hiding. Be careful though... deleting some controls will result in a compile error so check your script still compiles when you do. For those that you cannot delete, I give them a size of 0, 0 and position them outside the dialog.

As for the welcome and finish pages, you must either resize the controls at run time using the System plug-in and SetWindowPos or you could make a copy of the MUI source code and modify that instead. In either case it's quite messy.

Stu
miraz.zaidi#
What control contains the text ? I used resource hacker but couldn't actually move the text position.
Afrow UK#
You haven't said which text you are trying to resize so my guess is as good as yours. If you modify it in Resource Hacker make sure you click Compile before saving.

Stu
miraz.zaidi#
I am trying to reposition text on Welcome page, Install directory page and Finish Page.
And I am compiling and then saving in resource hacker. But couldnt find the right controls I guess.
Afrow UK#
As I said the welcome and finish pages need to be repositioned by modifying the Modern UI source code or by moving them at run time using the SetWindowPos API. The welcome and finish pages are not standard dialogs - they are created at run time using the nsDialogs plug-in. The directory page is dialog 103 (the main text control is #1006).

Stu
miraz.zaidi#
Ok..Thanks Stu. I was able to reposition the text on $instdir page using resource hacker.
But , I am still confused about welcome/finish page.. Even if I use SetWindowPos API as you suggested, I still need to know the Handle of the control that contains the text, isnt it ? Or am I missing something here.
Afrow UK#
I'm working on a small plug-in which will make control resizing easier. It will be ready in an hour.

Stu
Afrow UK#
Sorry I ran out of time and I want to make sure it works for RTL languages.

For the welcome/finish page control handles, check Contrib\Modern UI 2\Pages\*. There are variables defined for each control.

Stu
Afrow UK#
Finished the plug-in:


You can use the nsResize::Add function to increase the size of controls using the same units as nsDialogs (pixels, dialog units or percent). I've also added an example script which increases the size of the entire NSIS installer and uninstaller UI along with all wizard pages without any hacking of the UI with Resource Hacker.

Stu
miraz.zaidi#
Hey Stu.. Many thanks for this plugin.

But I am not able to use it properly.
For example, I am trying to resize the text on Directory page so I am doing this:

nsResize::Set 1006 25 150 460 190
But the text remain unchanged on installer directory page.

Can you pls give me an example for resizing controls?
Afrow UK#
It wants a window handle rather than an id. Also I would use dialog units over pixels and I would use Add rather than Set if you just want to make a control bigger.

For example:
FindWindow $R0 `#32770` `` $HWNDPARENT
GetDlgItem $R0 $R0 1006
nsResize::Add $R0 0 0 0 20u
This will make the control 20 dialog units higher.

Stu
miraz.zaidi#
Ok. Great. It worked!!! Thanks.

And regarding the text on welcome page I checked Contrib\Modern UI 2\Pages\welcome.nsh as you suggested, the MUI_WELCOMEPAGE_TEXT is defined for text control but when I used it to resize, nothing happened.

FindWindow $R0 `#32770` `` $HWNDPARENT
GetDlgItem $R0 $R0 MUI_WELCOMEPAGE_TEXT
nsResize::Set $R0 0 200 50u 50u
Afrow UK#
That is just a compile time define for the label text. The handle is stored in $mui.WelcomePage.Text:
nsResize::Set $mui.WelcomePage.Text 0 200u 50u 50u
Stu
miraz.zaidi#
Well I tried this too earlier..but Nsis is not recognizing it, text size is not changing and this warning is showing up :

unknown variable/constant "mui.WelcomePage.Text" detected.
Has it worked for you ?
(Sorry for bugging you this much. )
miraz.zaidi#
You're right. I was using MUI1.nsh. Now I switched to MUI2.nsh , found out that it doesnt support MUI_HWND so modified the code according to MUI2 , and finally it Worked. Thanks a lot Stu.
Similarly it worked for Finish page. (Wow)
But I dont why , there are coming these same warnings, as below:

unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_BEGIN:4)
unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_BEGIN:5)
unknown variable/constant "mui.ComponentsPage.DescriptionText.Info" detected, ignoring (macro:MUI_DESCRIPTION_BEGIN:6)
unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_BEGIN:6)
unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_TEXT:6)
unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_TEXT:7)
unknown variable/constant "mui.ComponentsPage.DescriptionText" detected, ignoring (macro:MUI_DESCRIPTION_TEXT:8)
Though there is no MUI_DESCRIPTION_* in my code.
miraz.zaidi#
Yeah.. removed it and all is working fine now. A big thanks to you for all the help. 🙂
shadowpoa#
Great plugin Afrow

I do know that is an old thread, but information is always useful for someone.

To do this, i've added this piece of code:

!define /math LVM_GETCOLUMNWIDTH  ${LVM_FIRST} + 29 
 FindWindow $0 "#32770" "" $HWNDPARENT
  GetDlgItem $0 $0 1016
  SendMessage $0 ${LVM_SETCOLUMNWIDTH} 0 desiredsizeinpixels 
I´ve used WinSpy to easily get the actual size of listview.

Also it is possible to get the current column size with this define and sendmessage:
!define /math LVM_SETCOLUMNWIDTH  ${LVM_FIRST} + 30
SendMessage ListViewhWnd ${LVM_GETCOLUMNWIDTH} colummindex outvar 
stass#
shadowpoa
Did as you recommended - but does not work ... Why?
; Shifting the default text position in NSIS installer pages
OutFile "test.exe"
!include MUI2.nsh
;!define MUI_WELCOMEPAGE_TEXT "New text goes here New text goes here New text goes here"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW Shift
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

; http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
; http://www.winehq.org/pipermail/wine...er/009527.html
!define LVM_GETCOLUMNWIDTH ${LVM_FIRST} + 29
!define LVM_SETCOLUMNWIDTH ${LVM_FIRST} + 30
;!define /math LVM_SETCOLUMNWIDTH ${LVM_FIRST} + 30

Function Shift
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1202 # ID MUI_WELCOMEPAGE_TEXT

; SendMessage ListViewhWnd ${ LVM_GETCOLUMNWIDTH } colummindex outvar
SendMessage $0 ${LVM_GETCOLUMNWIDTH} 1202 $R0
SendMessage $R0 ${LVM_SETCOLUMNWIDTH} 250 211 ; my size( default 293x211 )
FunctionEnd
Afrow UK#
LVM_GETCOLUMNWIDTH/LVM_SETCOLUMNWIDTH is used for LISTVIEW controls only. If you want to resize the welcome page text, use the nsResize plug-in.

Stu