Archive: Another Custom Page question


Another Custom Page question
I know I can change the imahe at the header of the installer using someting like this:

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "..\Sources\top.bmp"


But this will change it in all the pages of the installer.

Is it possible to change it only for one custom page?

For exampele I can change the text in the header of a custom page using !insertmacro MUI_HEADER_TEXT in the function of this custom page, but can I also change the bitmap ?


http://forums.winamp.com/showthread....hreadid=158179

http://nsis.sourceforge.net/ModernUI...stalling_files


Actually I alredy sow this, but I think its a bit too complicated and not exaclty what I'm looking for.

NSIS supports changing HEADERIMAGE in all the pages, so isn\t there some more easy way to change the HEADERIMAGE only in one custom page and not in all the pages?


if you dig a bit on these, you'll get to the point you like to go, it is too close.


If you know I'm close and you know the answer why then not tell me it?
Why do I need to waist hours looking for it if you already know the answer ?


Well, as you probably know, if I had a piece or code ready or even near ready, that'd be already posted here.
I'm just realizing that infos provided in above links, seem enough for someone who cares to start digging ;)


Well, I'm in a good temper today, plus it was more easy than expected...

!define LR_LOADFROMFILE     0x0010
!define LR_CREATEDIBSECTION 0x2000
!define IMAGE_BITMAP 0
!define sysLoadImage "user32::LoadImageA(i, t, i, i, i, i) i"
!define IMG_CHANGE "$PLUGINSDIR\win.bmp"
!define IMG_RESTORE "$PLUGINSDIR\modern-header.bmp"
!define BMP_CTL "1046"

!macro CHANGE_HEADER_IMG _IMAGE
GetDlgItem $0 $HWNDPARENT ${BMP_CTL}
System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) .r6' "${_IMAGE}"
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $6
ShowWindow $HWNDPARENT ${SW_HIDE}
ShowWindow $HWNDPARENT ${SW_RESTORE}
!macroend

!include "mui.nsh"

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

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
Page Custom custcreate custleave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

OutFile "Test.exe"
InstallDir "$EXEDIR"

Function custcreate
!insertmacro CHANGE_HEADER_IMG "${IMG_CHANGE}"

!insertmacro MUI_HEADER_TEXT "Custom Page" \
"This page should show a different image"
push $0
InstallOptions::Dialog "$PLUGINSDIR\custom.ini"
pop $0
pop $0

!insertmacro CHANGE_HEADER_IMG "${IMG_RESTORE}"
FunctionEnd

Function custleave
MessageBox MB_YESNO "Continue?" IDYES noabort
Abort
noabort:
FunctionEnd

Function .onInit
InitPluginsDir
File /oname=${IMG_CHANGE} "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
GetTempFileName $0
Rename $0 "$PLUGINSDIR\custom.ini"

WriteINIStr "$PLUGINSDIR\custom.ini" "settings" "numfields" "1"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "type" "groupbox"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "text" "I'm a GroupBox, or not..."
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "left" "10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "right" "-10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "top" "10"
WriteINIStr "$PLUGINSDIR\custom.ini" "field 1" "bottom" "-10"
FunctionEnd

Section -

SectionEnd

Yes a good temper indeed.

Thanks I will try it.


Let me know if the code works as expected on a full installer environment,
I'd like to post an example at wiki to be accessible by everyone who might need it :)


Yes it is working.
There is one small bug I still can't point when it exactly happends.

Sometimes when the logo is changing, I mean when I go to the page where the logo is suppose to change the installer window "hides" behing one of the other open windows.

I mean for example I have IE open on ful screen and then I run the installer, I see the Welcome screen, licnese ..... amd then when I hit next and suppose to see the page where the image suppose to change the setup windows "hides" behing IE window.
But the image is changing as it should.


I will try to check it on other PCs to see if its a bug in my PC or something general.


This happens because I had to to use it in the script (hide/restore window) in order to refresh it and show the changed image.
I'll check further possibilities.

EDIT:
Actually there's no need for hide/restore window!
This happened on my old tired pc in works!
Now in home everything works just fine!
You should remove the 2 lines of code inside the macro,
ShowWindow $HWNDPARENT ${SW_HIDE} -> remove it
ShowWindow $HWNDPARENT ${SW_RESTORE} -> remove it


Ok I will do it and also do more tests on more PCs and see if its ok and then let you know


Cool! thanks :)


Without these two lines the code dosn't work :(
It shows the new bitmap for a second and then it just shows white space instead of the bitmap.


Works just fine on 2 pc's I'm able to test right now (XP)