Archive: adjusting height


adjusting height
Is there a way to adjust the height of the install dialog? I looked through the documentation for "width" and "dimension" and searched the board for the words also, but it doesn't seem anyone has needed this before. I just want to make my branded picture fit, I am putting it on the left but I want to use a picture that is taller than the installer.

Anyone know how I might do this?


The best method is to use a custom UI. There are several examples located in Contrib\UIs of the NSIS folder. You can edit the existing ones with a program like "Resource Hacker", or compile your own. Inside your script you simply set the ChangeUI attribute to the location of your new UI and the compiler will do the rest. For example, the following will set your dialog to use the new modern UI dialog.

Name "test"
OutFile "test.exe"
ChangeUI all "${NSISDIR}\Contrib\UIs\modern.exe"

Section ""
SectionEnd


Thanks for the reply.

I've since played with the ModernUI and tried adding a branding image but it seems to ignore me completely. Is this something that will be fixed with the Modern UI? If not, is there some tutorial on how to add an image to the modern ui? I could see using resource hacker to make space but I don't know how I'd go about loading something into that spot through the scripting language.


theres a couple ways you can do it. first it comes down to what type of branding image you want to add. NSIS has a souple functions which will allow you to add an image to the inner dialog. Use the AddBrandingImage and the SetBrandingImage functions. If this doesn't do what you need then we can go to the next step which is using resource hacker.


Well I found out that if you want to add a branding image to the MODERN_UI using all those fancy macros ;) you have to put it after the !insertmacro MUI_SYSTEM.

This makes space for the image but I am unable to find a function where I can load it from.

By adding another page I was able to get a function to load the image:
Page directory dirImage

But there are two problems with this. First of all I don't want to add the Image after I've gone through all the other pages the MODERN_UI macros have created. Secondly, the image appeared too low and off to the right, clearly not lined up with the borders of the dialog as it should be. I'm pretty sure this last one is a bug, but if I find a better function to load the branding image from perhaps this problem will go away.


This is what I do for my installer. I have a full screen graphic so I have to add an additional control to the outer dialog. I modify dialog 105 in the modern.exe UI file (I user resource hacker for this). I add the following line right below the "{" symbol.

CONTROL "",1001,STATIC,SS_BITMAP|WS_CHILD|WS_VISIBLE|WS_GROUP,0,0,0,0

I then recompile the page and save the exe. In my code I add the following.

Function .onGUIInit
GetTempFileName $R0
File "/oname=$R0" "background.bmp"
SetBrandingImage /IMGID=1001 "$R0"
Delete $R0
FunctionEnd

This will load the graphic into the control. You might have to play around with the ording in the modern.exe but that's basically it.

Hope this helps.


This almost works but I get the error:
Function: ".onGUIInit"
Error: Function named ".onGUIInit" already exists.
Error in script "eMule.nsi" on line 57 -- aborting creation process

Is this already defined by the MODERN_UI macro?

I tried putting that code in the .onInit function but while it compiled it did nothing.


MUI does have the GUIInit already used but we should be able to get around it. In your script you should have the following line.

!insertmacro MUI_SYSTEM

replace it with the following.

!insertmacro MUI_INTERFACE
!insertmacro MUI_FUNCTIONS_PAGES
Function .onGUIInit
GetTempFileName $R0
File "/oname=$R0" "background.bmp"
SetBrandingImage /IMGID=1001 "$R0"
Delete $R0
!insertmacro MUI_GUIINIT
FunctionEnd
!insertmacro MUI_FUNCTIONS_ABORTWARNING
!insertmacro MUI_UNBASIC

give it a try


An easier way of using a customized GUIInit function will be added to the next version of the Modern UI.


Ah-ha, thanks dselkirk that did the trick. :D I'm so close... however I still have a problem getting the image in the right spot/size.

If I use "AddBrandingImage left 164" it will place the branding image down and to the right (and it takes a little more space than I told it to), instead of in the top left corner. Is there a way to tell the image to be at 0,0 after adding the branding image?

If I add it using reshacker I don't know how much space I'd need since 164 units is not the same as 164 pixels... and don't these units change with system font sizes?


The addbrandingimage function adds the image to the inner dialog. the inner dialog is that grey square you see if you edit dialog 105 of the modern.exe. Thats why I add the bitmap control to the ui using resource hacker, it allows me to place the graphic where I want. Also, in resource hacker 164 translates to 110. This shouldn't matter though. The graphic should automatically resize. Why don't you describe how you want it to look and then we can go form there.


Yet another UI "modern3". Hope it helps
This is a modified version of the basic "modern2.exe" UI. You can load it in ResourceHacker and see the location of the image. This is a rough cut :)

- Shantanu


sorry, forgot to attach the file
here is the file

- Shantanu


Hey dselkirk, thanks for the clarification on the AddBrandingImage issue. I still think it would be nice to be able to add a branding image with some sort of automatic macro into the MODERN_UI, however resource hacker worked fine.

I think this is the last problem, when I run the uninstaller it doesn't seem to call .onGUIInit so the branding image doesn't get set. Again, I'd say this is a bug but perhaps it's just ignorance on my behalf. :igor: Do you have a clever way of working around this too?

@shantanu_gadgil, thanks for the new layout but I got what I needed as far as layout goes.


The uninstaller uses un.onGUIInit, but you should also insert some macro's manually because the Modern UI basic macro inserts un.onGUIInit.


Well this causes a new problem, the branding image takes up 2x the space now. Is there someway to fix this? It won't let me mix "un." function calls with regular "." functions so I can't see a way around this.


...or perhaps there is a way to use another gui, like say modern.exe, for the uninstaller so I don't have that big space there?

I tried ChangeUI with IDD_UNINST but that only changes the inner dialog.


There seems to be 2 issues here. I'm not sure whats happening with the branding image size. It almost sounds like 2 images are being added. As for mixing the functions, the only way to do this is to use macros. To do this simply add the following code before any of the !insertmacro I showed you in the previous post.

!macro MY_GUIINIT
GetTempFileName $R0
File "/oname=$R0" "background.bmp"
SetBrandingImage /IMGID=1001 "$R0"
Delete $R0
!insertmacro MUI_GUIINIT
!macroend

Now replace all the code inside the .onGUIInit and un.onGUIInit functions with the following.

!insertmacro MY_GUIINIT

This will insert the same code in both functions.


I was unclear.

The problem is the image is twice in the installer executable! The installer has two copys of same image compressed seperatly. I add branding image and I gain 100k to installer, then I add branding image to un.onGUIInit and now installer gains 200k!


Ahh. Basically the reason is that the uninstall is a seperate executable that is compiled at the same time as your installer. That is why nsis is so seperated in the script. Why there's "." and "un.". The only thing you can do is either make a silent uninstall (ie. no graphic need then) or optimize your graphic (index the color). Wish I had a better answer for you. Sorry


well if you say they are seperate executables, isn't there a way for me to change which UI it uses for the uninstaller? I'd be happy if it just used the modern.exe ui...


They are not separate executables, just separate data blocks.


is it possible to have a common data block? This can be for graphics and functions which are common to both install and uninstall?


I'll check.


cool, thx


Common data block? I'd be very much interested in this, would be a useful feature.