Archive: Need help with UI Mod


Need help with UI Mod
I'm trying to modify one page in Modern UI. I have added an extra control to the required dialog. I just need a hint of how to modify the contents of it from the installer itself.

Any help will be greatly appreaciated.

Vytautas :)


First use command:
ReserveFile "my_page.ini"
then in .onInit function use :
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "my_page.ini"
then from your script modify "my_page.ini" before call your custom page, like this:
!insertmacro MUI_INSTALLOPTIONS_WRITE "my_page.ini" "Field #" "Value Name" "Value"


I think that you misunderstood me. I am trying to add an image control below the progress bar in the install page. I used a resource hacker to add the control however I cannot seem to be able to specify the image file for the control. I have tried the 'SetBrandingImage' command but it does not seem to function as I expected.

Vytautas


SetBrandingImage doesn't work for the inner dialog. For that you have to call LoadImage and send STM_SETIMAGE yourself.


I tried this code but there seems to be some error as it does not work :cry:

  StrCpy $1 "C:\Program Files\NSIS\Contrib\Graphics\Header\modern-header.bmp"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 "1028"
System::Call "user32::LoadImage(i 0, t r1, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i .r5"
dumpstate::debug
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $5
It's probably somethink extremely simple that I just overlooked but I just can't seem to be able to figgure this out.

NOTE: dumpstate shows that $0 contains the required info but $5 is always '0'

Vytautas

Add the ?e switch to System::Call to find out what the error is. For example:

System::Call "user32::SetWindowText(i 0, i 0) ?e"
Pop $0
DetailPrint $0

should print out 1400 which is the error code ERROR_INVALID_WINDOW_HANDLE. You can get the description for the error code from WinError.h or using this program. There is also the program that comes with VC.


Thanks although my installer generates error 2. Which was because I did not check to see if the file was there. After fixing that problem the error code is 0, but the image still won't display.

Vytautas

PS. If you would like I can attach a copy of the modified UI file.


Does $0 have the right value? Try setting its background color to make sure.


If this is the code to change the background color to white then it did not work. BTW where should I put this code, PRE / SHOW functions or in a section itself?

SetCtlColors $0 FFFFFF FF0000
Vytautas

The show function.


OK, so it seems that its not getting the right HWND. How do I fix that? I used a couple of resource editors and they both say that the bitmap control is there. I have changed the control ID and tried the script again. Then the script used a different ID that the one in the exe file $0 was '0' but when I changed the script to match the ID it showed up a normal value.

Are you sure that one can change the background color of an image control?

Vytautas


Hello,

i recently had the same problem. This is my working macro (looks kinda similiar to yours):


!define LR_LOADFROMFILE 0x0010
!define LR_CREATEDIBSECTION 0x2000
!define STM_SETIMAGE 370
!define IMAGE_BITMAP 0
!define sysLoadImage "user32::LoadImageA(i, t, i, i, i, i) i"
!define sysDeleteObject "gdi32::DeleteObject(i) i"

!macro DisplayImage IMG_NAME
Push $0
Push $1
GetTempFileName $1
File /oname=$1 "${IMG_NAME}"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1100
System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) .r6' "$1"
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $6
System::Call "${sysDeleteObject} (r6)"
Delete $1
Pop $1
Pop $0
!macroend


hope this helps.

kind regards,
Ingo Bartel

Are you sure that one can change the background color of an image control?
Yes. I have just tested it again on the MUI welcome page and it worked.

thanks ibartel, you macro worked for me. Just a note though you should Push & Pop $6

kickik what is the best way to modify the UI exe file. I noticed that some of the Modern UI mods are only for that particular page and they do not seem to modify the main UI file. How do I do that?

Vytautas :D


OK, just spotted a little problem with this approach. It appears that the image get wiped out if the installer loses focus, e.g. get minimised and restored or another windows dragged over the top of it.

Any ideas on how to fix this?

Vytautas :eek:

OT: I just noticed that some topics have a black dot on the icon, what's that all about?


You can modify just certain dialogs and then load them in using ChangeUI IDD_LICENSE | IDD_DIR | IDD_SELCOM | etc. instead of loading all of them.

The image is probably wiped because you delete the image object before its usage has finished. Delete it after you replace it, not after you set it.

The black dot signifies threads you've posted in.


Yep that was the probl;em with the disapearing images, working on a modified macro to fix this problem.

Vytautas


Macro Updated, see the archive page.

Should I use ChangeUI if using MUI and if so do I need to delete the other dialogs from the exe file since it did not work for me.

Vytautas


Well, the MUI has some defines to change the UI, but none change only the instfiles page. I think it would be best if you tell the user to put ChangeUI IDD_INSTFILES at the end of the script, or at least after the page macros.


Sorry to revisit an old thread, but I was wondering if there was a similar command that allowed to specify a JPEG rather than a BMP file.

Bitmaps are rather large and it seems a waste of space when it could be smaller as a JPEG. Unless i'm way off track JPEGs have better compression than BMPs compressed with normal compression algorithms like BZIP2 or LZMA.

Vytautas