Archive: Picture on custom MUI


Picture on custom MUI
First let me start by saying that I am very new to this. I use VB, C++, HTML, and VBS, so I am not completely code retarded... just confused at the moment.

I have gone through the different help pages, both NSIS and MUI. There is something vital that I am missing. I am trying to place an image into a custom page. This is not unlike the example in the GFX.NSI. However, I am overwhelmed, at the moment, with what appears to be all of todo involved with simply placing an image on the side. Am I correct in assuming that the image along the left side is the branding image? I have yet came across a diagram describing exactly what/where these things will appear on the page (understanding, of course, that some can be moved around). I have no problem 'playing' with the different settings, but I cannot get anything, other than the HEADER image, to appear, so that I can play with it. I get bounced at compile time with any number o messages that do not indicate, to me, what I did wrong. For that matter, the message could just say, "nope, try again".

I'm stumped. Therefore I am risking a flogging for something that seems to be easy to everyone else. Also, is there a 'cheat sheet' of what elements should appear in Sections and which should appear in Functions? Eventually, I am to train some monkeys lower on the ladder than myself, so I was hoping there was a 'rule of thumb'.

Thanks all!

TM


You can put the same elements in both Functions and Sections.

As for adding a branding image:

I used one in an installer a few years ago. The code might have changed now, but here's the general idea...

# goes at top of script (compile time)
AddBrandingImage left 150 0

# put in pre function for custom page
File "/oname=$PLUGINSDIR\image.bmp" "local_image.bmp"
SetBrandingImage "$PLUGINSDIR\image.bmp"

-Stu


I am creating an NSI file that is not only supposed to work, but serve as a functional example for others and for a quick reference for myself. I am trying to use the basic functions all in one app. Here is what I have, and following is the error that I get.

The following is my TEMPLATE.INI file:
--------------------------------------
; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=1

[Field 1]
Type=Bitmap
Flags=RESIZETOFIT
Left=18
Right=126
Top=14
Bottom=110
--------------------------------------

I have renamed my image to "image.bmp" and placed it into the c:\Program Files\NSIS\Plugins\ directory and into the \Contrib\Graphics\ directory to cover some bases. I will clean up later as soon as I find out what is wrong.

The following is my NSI code:
--------------------------------------
!include "MUI.nsh"
Name "Demo"
OutFile "NSIS_Demo.exe"
BrandingText "Branding Test"
AddBrandingImage left 150 0

!define MUI_WELCOMEPAGE_TITLE "MUI_WELCOMEPAGE_TITLE"
!define MUI_WELCOMEPAGE_TEXT "MUI_WELCOMEPAGE_TEXT"

!insertmacro MUI_PAGE_WELCOME
Page custom Template
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

ReserveFile "Template.ini"

!insertmacro MUI_LANGUAGE "English"

Section "Section Title" SectionName
;Section code here
SectionEnd

LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Langstring Title"
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "Langstring Subtitle"

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "Template.ini"
FunctionEnd

Function Template
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "Template.ini"
File "/oname=$PLUGINSDIR\image.bmp" "c:\Program Files\NSIS\Contrib\Graphics\image.bmp"
SetBrandingImage "$PLUGINSDIR\image.bmp"
FunctionEnd
--------------------------------------
ERROR
--------------------------------------
SetBrandingImage:
Error: no branding image found in chosen UI!

Can someone help with this? I do ont understand why it cannot see the image on the UI? Is there a labelling that I'm missing?

Thanks all!
TM


The MUI changes the UI and therefore removes the branding image. If you put the AddBrandingImage command after the page macros, it should work.


OK... that worked... kind of.

I now have a space reserved on the side for what looks to be where the image is to be displayed, just no image. When I select <NEXT>, the same 'gap' is present with no image. Now... if I select <BACK>, the image is now there. Selecting <NEXT> will, likewise, now show the image.

Any idea?

Thanks,
TM


Well, you are setting the image after the InstallOptions call returns, which is when the second page is destroyed.

Reading your original post again, it seems that branding image is not what you are looking for. You said you wanted to show a picture just in the custom page, not on all pages. For this, you have to define a image field (Type=Bitmap) and set the text value to the path of the image (Text=$PLUGINSDIR\image.bmp). Note that since $PLUGINSDIR is never the same, you should dynamically write this value (before you call MUI_INSTALLOPTIONS_DISPLAY).