Archive: Header image in Modern UI


Header image in Modern UI
I am using the Modern UI with the following entries in my .nsi script.

!define MUI_ICON "Messenger.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "STPMessengerTitleSmall.bmp"

The icon displays fine but I can't get get the header image to display. Am I missing something?

Also the following colors command seems to have no effect:

!define MUI_INSTFILESPAGE_COLORS "F0F0F0 000000"

Any help would be appreciated.


works just fine for me. could you plz attach your script, or an example, where it doesn't work?


Here's the whole script
; main.nsi
; Main installer script for use with NSIS Installer
;--------------------------------

;--------------------------------
; Let's use the "Modern" UI style
!include "MUI.nsh"
;--------------------------------

!define VERSION "3.2.0"
!define MUI_ICON "Messenger.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "MessengerTitleSmall.bmp"

LangString MUI_TEXT_WELCOME_INFO_TEXT ${LANG_ENGLISH} "Welcome to Messenger Install"
LangString MUI_TEXT_WELCOME_INFO_TITLE ${LANG_ENGLISH} "Messenger Install"
LangString MUI_TEXT_INSTALLING_TITLE ${LANG_ENGLISH} "Installing Messenger"


; The name of the installer
Name "Messenger version ${VERSION}"

; The file to write
OutFile "InstallMessenger_v${VERSION}.exe"

; The default installation directory
InstallDir $PROGRAMFILES\Messenger${VERSION}

;--------------------------------
; Pages
;--------------------------------
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES


; The stuff to install
Section "" ;No components page, name is not important

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put files there
File /r ..\FilesToInstall\*.*

SectionEnd ; end the section


1. The header bitmap must be extracted to a temporary location using File/ReserveFile.
2. You must specify the full path to the bitmap.

E.g.

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "$PLUGINSDIR\MessengerTitleSmall.bmp"
Function .onInit
InitPluginsDir
ReserveFile "/oname=$PLUGINSDIR\MessengerTitleSmall.bmp" "MessengerTitleSmall.bmp"
FunctionEnd


-Stu

Thanks for the reply. After making the .onInit Entry change now a welcome page which wasn't displaying before is coming up. I still don't see the bitmap. The page is completely blank. NSIS seems very tempermental.


Sorry,
ReserveFile "/oname=$PLUGINSDIR\MessengerTitleSmall.bmp" "MessengerTitleSmall.bmp"
...won't work.

You'd need to use:
SetOutPath $PLUGINSDIR
ReserveFile "MessengerTitleSmall.bmp"

-Stu


Ok, I think the problem is being caused because you are using LangString's when you aren't including any seperate languages. If you are only using English then you don't need to use LangString's. If you do, MUI just seems to fall to pieces (I have found).

Just use plain !defines rather than LangString's.

-Stu


If you do, MUI just seems to fall to pieces (I have found).
I have no trouble using language strings in my English-only MUI-based installers.

Did you remember to include the
!insertmacro MUI_LANGUAGE "English"
line in your script ?

Originally posted by pengyou
I have no trouble using language strings in my English-only MUI-based installers.

Did you remember to include the
!insertmacro MUI_LANGUAGE "English"
line in your script ?
That's the reason that I said that LangStrings are pointless in his script because he isn't including the English language!

-Stu

That's the reason that I said that LangStrings are pointless in his script because he isn't including the English language!
The script might only use English at the moment but perhaps there are plans to add more languages in the future? Adding the MUI_LANGUAGE line is an easier change than getting rid of all the language strings in the script.

Surely there is no harm in using language strings even if the script only uses one language, provided the necessary MUI_LANGUAGE line is used? Some of my installers start out as English-only and end up supporting several languages and I have found it easier to use language strings right from the start.

You need to include the English language:
!insertmacro MUI_LANGUAGE "English"

This must be put in after you insert the Page macro's and before you insert any LangStrings.

I think the reason that your installer isn't working properly is because you are currently using LangStrings specifying ${LANG_ENGLISH} when you do not have ${LANG_ENGLISH} set (using the MUI_LANGUAGE macro).

-Stu


There is absolutely no need to add that .onInit code in this topic. For a MUI header image you only need:

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "STPMessengerTitleSmall.bmp"

But an installer always needs a language, if you are only using Ennglish, you have to include the MUI_LANGUAGE macro for English.


Uninstaller header image
Hi, I have a similar problem, I am successfully displaying my bitmaps in the header using the command !define MUI_HEADERIMAGE_BITMAP but when trying to change the header image of my uninstaller the same header image as the one set by !define MUI_HEADERIMAGE_BITMAP is shown.

How would I set the uninstaller header image. I am using
!define MUI_UNHEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-uninstall.bmp" but it does not work


Use !define MUI_HEADERIMAGE_UNBITMAP "$PLUGINSDIR\file.bmp"
Also remeber it's the path to the Bitmap file on the user's computer, not yours!!!

-Stu


That's not true, the MUI will extract the file to the users system automatically.


This doesnt work for me either

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp"

I get no header image without the mui_headerimage_bitmap line i'll get the default


Did you include the language macro? Try to modify a basic example script to see whether the problem is related to your script.


!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Interface Configuration

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp"
!define MUI_ABORTWARNING

;--------------------------------
;Pages

!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Contrib\Modern UI\License.txt"

I was just modifying the basic script . I added the headerimage_bitmap line and moved the language line to the top


Please see the MUI readme. It shows you how to make a script in steps. You always insert the MUI_LANGUAGE macro after all interface configuration and MUI_PAGE macro's.

-Stu


I did have that there. The only reason I moved it was I was getting an error, which seems to be gone now interestingly enough. maybe it ws something else.