ModernUI Mod to Display Images while installing files
Author: Vytautas (talk, contrib) |
Links
Mirror #1 Modern_Instpics.zip (2 KB) (2007-06-30)
Mirror #2 Modern_Instpics.zip (2.7 KB) (2004-02-13)
Description
I had noticed a few questions in the forums that centered around the ability to display pictures while the installer was copying files.
So I modified the ModernUI executable to add this function. The code used to actually display the images was created with a lot of help from ibartel and kichik.
First copy the modern_instpic.exe file to the NSIS\Contrib\UIs folder. Then save the following script to nsis include folder. (Recommended Name: Image.nsh)
The Script
!ifndef LR_LOADFROMFILE !define LR_LOADFROMFILE 0x0010 !endif !ifndef LR_CREATEDIBSECTION !define LR_CREATEDIBSECTION 0x2000 !endif !ifndef STM_SETIMAGE !define STM_SETIMAGE 370 !endif !ifndef IMAGE_BITMAP !define IMAGE_BITMAP 0 !endif !ifndef sysLoadImage !define sysLoadImage "user32::LoadImage(i, t, i, i, i, i) i" !endif !ifndef sysDeleteObject !define sysDeleteObject "gdi32::DeleteObject(i) i" !endif !define MUI_UI "${NSISDIR}\Contrib\UIs\modern_instpic.exe" ShowInstDetails nevershow var ImageHandle !macro DisplayImage IMG_NAME Push $0 Push $1 Push $6 !define Index "Line${__LINE__}" GetTempFileName $1 SetDetailsPrint textonly DetailPrint "Loading Image" StrCmp $6 '' "${Index}-First" StrCpy $6 $ImageHandle System::Call "${sysDeleteObject} (r6)" StrCpy $6 '' "${Index}-First:" SetDetailsPrint none File /oname=$1 "${IMG_NAME}" FindWindow $0 "#32770" "" $HWNDPARENT GetDlgItem $0 $0 2000 System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) .r6' "$1" SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $6 StrCpy $ImageHandle $6 Delete $1 SetDetailsPrint textonly !undef Index Pop $6 Pop $1 Pop $0 !macroend
Now to use the modified version of the UI all you need to do is include the image.nsh file in your script and call the DisplayImage macro in your section(s).
!include "Image.nsh" ... Section "Main" !insertmacro DisplayImage 'Image.bmp' SectionEnd
And enjoy your newly modified installer capable of displaying images while installing files.
Please note that you should not enable the details view of your installer as it WILL be displayed over the image.
Versions History
- [Update 2012-02-23 (Anders)]
- Unicode fix (Did not update zip file)
- [Update 2004-02-13]
- Removed dumpstate command used for debugging. Must of been asleep when posting the initial code.
- [Update 2003-12-04]
- Fixed problem with image getting erased when the window was redrawn.
Vytautas