2

my code is :

; DIMM_V2 Easy NSIS GUI Script 
!include MUI2.nsh
!define MUI_CUSTOMFUNCTION_GUIINIT dimm_hide
!include "page1.nsdinc"
!include "page2.nsdinc"
!include "page3.nsdinc"
!define MUI_HEADERIMAGE #  need to load custom exe 
!define MUI_UI_HEADERIMAGE ".\dimm_beta_img.exe"  ; dimm 1018 my bmp image ! 
; !define MUI_UI_HEADERIMAGE ".\modern.exe"  ; dimm 1018 my bmp image ! 

; dimm code for switching pages is is inside of pages .nsdinc


Page custom fnc_page1_Show
Page custom fnc_page2_Show
Page custom fnc_page3_Show
 ; Page custom dimm_hide
; !insertmacro MUI_PAGE_WELCOME
; !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
; BringToFront
; Destroy a window.
!macro DestroyWindow HWND IDC
    GetDlgItem $R0 ${HWND} ${IDC}
    System::Call `user32::DestroyWindow(i R0)`
!macroend
; 106 this page is Details Page
Function dimm_hide
; dimm   hide   ; need to hide 1256  /// 1037
!insertmacro DestroyWindow  $HWNDPARENT 1045     # dimm remove line from bottom
!insertmacro DestroyWindow  $HWNDPARENT 1256     # dimm remove line from bottom
!insertmacro DestroyWindow  $HWNDPARENT 1037     # dimm remove line from bottom
!insertmacro DestroyWindow  $HWNDPARENT 1028     # dimm remove line from bottom
FunctionEnd
Section
SectionEnd

Working with the NSIS installer and i want to set a static background image on the MUI_PAGE_INSTFILES page "MUI_PAGE_INSTFILES " thx for any help.

*edit - my others pages are already full bg image, so i want to keep the same designt.

enter image description here

edit -  my others pages are already  full bg image, so i want to keep the same desight .

edit 2 : in this example it is green but it using "commctrl.nsh" and so i dont know how to build all toghether .

code :
!include "MUI2.nsh"
!include "..\CommCtrl.nsh"
Caption "List View"
OutFile example1.exe
 Page custom CreatePage
!insertmacro MUI_LANGUAGE "English"
Section Install
SectionEnd
Function CreatePage
    !insertmacro MUI_HEADER_TEXT "List view control" "A SysListView32 control created by nsDialogs plugin"
  nsDialogs::Create 1018
  Pop $0
  StrCmp $0 error 0 +2
  Abort
  ${NSD_CreateListView} 0u 0u 300u 120u "ListView"
  Pop $1
  SendMessage $1 ${LVM_SETBKCOLOR}     0 0xC7EDCC # green bg for details page
  ; Insert a new item  ${NSD_LV_InsertItem} "hWnd" "iItem" "szText"
  ${NSD_LV_InsertItem} $1 0 "Item 0"
  ${NSD_LV_InsertItem} $1 1 "Item 1"
  nsDialogs::Show
FunctionEnd
DIMM_V2
  • 105
  • 1
  • 9

2 Answers2

2

You can't use nsDialogs controls on other pages but you can use the image macros:

RequestExecutionLevel User
!include "MUI2.nsh"
!include "WinMessages.nsh"
!include "nsDialogs.nsh"

!define MUI_PAGE_CUSTOMFUNCTION_SHOW ConfigureInstFilesPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"


Function ConfigureInstFilesPage
FindWindow $1 "#32770" "" $HWNDPARENT ; Inner dialog
System::Call 'USER32::GetClientRect(pr1, @r2)'
System::Call '*$2(i.r6,i.r7,i.r3,i.r4)'
; Tweak $6, $7, $3 and $4 with IntOp and remove ${SS_CENTERIMAGE} if desired
System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_CHILD}|${WS_VISIBLE}|${SS_BITMAP}|${SS_CENTERIMAGE}, ir6, ir7, ir3, ir4, pr1, p0, p0, p0)p.r5'
File "/OName=$Pluginsdir\ifp.bmp" "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
${NSD_SetBitmap} $5 "$Pluginsdir\ifp.bmp" $6
FunctionEnd 

Section
Sleep 1234
SectionEnd

NSIS was never designed to support full background images. The best option is probably to use Graphical Installer but it is possible to hack something up yourself:

RequestExecutionLevel User
!include "MUI2.nsh"
!include "WinMessages.nsh"
!include "nsDialogs.nsh"


#!define MUI_HEADER_TRANSPARENT_TEXT ; Set this if you don't want header text
!define MUI_TEXTCOLOR 000066
!define MUI_BGCOLOR 667788
!define TEXTCOLOR 0x${MUI_TEXTCOLOR}
#!define BGCOLOR "0x${MUI_BGCOLOR}"
!define BGCOLOR Transparent ; Setting this to "Transparent" only works partially and requires some hacks...

!define MUI_CUSTOMFUNCTION_GUIINIT GuiInit
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ConfigureInstFilesPage
Page custom fnc_page1_Create
!insertmacro MUI_PAGE_INSTFILES
Page custom fnc_page1_Create
!insertmacro MUI_LANGUAGE "English"
BrandingText " "

Function GuiInit
GetDlgItem $0 $HWNDPARENT 0x4E8
ShowWindow $0 0
GetDlgItem $0 $HWNDPARENT 0x404
ShowWindow $0 0
GetDlgItem $0 $HWNDPARENT 0x40b
ShowWindow $0 0
GetDlgItem $0 $HWNDPARENT 0x40c
ShowWindow $0 0
ShowWindow $mui.Header.Background 0
ShowWindow $mui.Header.Image 0
StrCpy $1 $HWNDPARENT
System::Call 'USER32::GetClientRect(pr1, @r2)'
System::Call '*$2(i.r6,i.r7,i.r3,i.r4)'
System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_CHILD}|${WS_VISIBLE}|${SS_BITMAP}|${WS_CLIPSIBLINGS}, ir6, ir7, ir3, ir4, pr1, p0, p0, p0)p.r5'
File "/OName=$Pluginsdir\ifp.bmp" "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
LoadAndSetImage /STRINGID /RESIZETOFIT $5 0 0x10 "$Pluginsdir\ifp.bmp" $6
!if ${BGCOLOR} == Transparent
    ${NSD_AddExStyle} $mui.Header.Text ${WS_EX_TRANSPARENT}
    ${NSD_AddExStyle} $mui.Header.SubText ${WS_EX_TRANSPARENT}
!endif
FunctionEnd

!macro FixTransparentText
!if ${BGCOLOR} == Transparent
    System::Call 'USER32::RedrawWindow(p$HWNDPARENT,p0,p0,i4|1|512|128)'
!endif
!macroend

!macro PageInit
SetCtlColors $mui.Header.Text ${TEXTCOLOR} ${BGCOLOR}
SetCtlColors $mui.Header.SubText ${TEXTCOLOR} ${BGCOLOR}
FindWindow $1 "#32770" "" $HWNDPARENT ; Inner dialog
SetCtlColors $1 ${TEXTCOLOR} transparent
!insertmacro FixTransparentText
!macroend


Function fnc_page1_Create
nsDialogs::Create 1018
Pop $0
${If} $0 == error
Abort
${EndIf}
SetCtlColors $0 ${TEXTCOLOR} transparent
${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
Pop $0
SetCtlColors $0 ${TEXTCOLOR} transparent
${NSD_CreateText} 0 13u 100% 30u "Type something here..."
Pop $0
!insertmacro MUI_HEADER_TEXT "Blah" "Blah blah blah"
!insertmacro PageInit
nsDialogs::Show
FunctionEnd


Function ConfigureInstFilesPage
!insertmacro PageInit
SetCtlColors $mui.InstFilesPage.Text ${TEXTCOLOR} ${BGCOLOR}
FunctionEnd


Section
DetailPrint Hello
Sleep 1234
SectionEnd

Section "-LastSectionToFixRedrawBug"
!insertmacro MUI_HEADER_TEXT "" ""
!insertmacro FixTransparentText
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • thx for your reply , please see my post i have uploaded second picture , for showing my actual state , and i want to keep the same thing on next page. – DIMM_V2 Apr 06 '23 at 20:25
  • I was on the point of buying graphical designer for nsis, but i have found some bugs, when you hover mouse on text buttons or radio buttons so that is huge bug for payed version I can tell you more this is bug is present even in installer"GraphicalInstaller-NSIS-2022.2-Trial.exe",so it is not very cool for a payed version . So i will build something myself free & working,and yes it is possible , im already at 80 % at Success. – DIMM_V2 Apr 07 '23 at 07:34
  • WS_CLIPSIBLINGS - im using it already in dialog designer , if i apply your solution my labels "Page 1 and Page 2 " are gone , because it's using "WS_CLIPSIBLINGS" how to deal with it ? and the same question for details page when you click "show details" - it is possible to make it transparent ? – DIMM_V2 Apr 07 '23 at 18:38
  • I don't know how to make the InstFIles page log window transparent. – Anders Apr 07 '23 at 19:36
  • !define MUI_INSTFILESPAGE_COLORS "transparent 77CCEB" ;Two colors – DIMM_V2 Apr 09 '23 at 16:37
  • @Andrers, it is possible to have some function ( transparent page) but for "MUI_PAGE_Directory" i have one of working but it is fot mui and not for mui2 , thx – DIMM_V2 Apr 10 '23 at 14:55
  • There should not be a big difference for the dir page with MUI 1 and 2 – Anders Apr 11 '23 at 11:06
  • warning the command "/RESIZETOFIT" can render your image very ugly .some times it's better to remove this switch . – DIMM_V2 Apr 22 '23 at 19:04
  • @DIMM_V2 Yes, or at least just fit the width or the height, not both. – Anders Apr 22 '23 at 19:44
0

Working examle for "Directory Page" Full Transparent

;working examle for "Directory Page" Full Transparent /// DIMM_V2
!include "MUI2.nsh"
; Local bitmap path.
!define BITMAP_FILE res.bmp
; --------------------------------------------------------------------------------------------------
; Installer Settings
; --------------------------------------------------------------------------------------------------
Name "Background Bitmap"
OutFile "bgbitmap.exe"
ShowInstDetails show
; --------------------------------------------------------------------------------------------------
; Modern UI Settings
; --------------------------------------------------------------------------------------------------

; !define MUI_UI ".\dimm_beta_img.exe" ;The interface file with the dialog resources. Change this if you have made your own customized UI.


; !define MUI_HEADERIMAGE #  это отвечает за большое окно  
; !define MUI_UI_HEADERIMAGE ".\dimm_beta_img.exe" # измененный ехе     ; dimm 1018 my bmp image ! 
!define MUI_DIRECTORYPAGE_BGCOLOR CDCDCD  # gray color of Destination Folder
!define BGCOLOR Transparent ; Setting this to "Transparent" only works partially and requires some hacks...
!define MUI_CUSTOMFUNCTION_GUIINIT MyGUIInit
!define MUI_TEXTCOLOR ffffff #  white : ffffff
!define MUI_BGCOLOR Transparent # back upper side must be transparent
DirText "$\r" # псевдо затирание!   /// hide text in directory page 
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Install Folder"
; --------------------------------------------------------------------------------------------------
; Definitions
  InstallDir "$temp"
; --------------------------------------------------------------------------------------------------
Var hBitmap
; --------------------------------------------------------------------------------------------------
; Pages
; --------------------------------------------------------------------------------------------------
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryPageShow
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
 ; --------------------------------------------------------------------------------------------------
; Macros
; --------------------------------------------------------------------------------------------------
; Destroy a window.
!macro DestroyWindow HWND IDC
  GetDlgItem $R0 ${HWND} ${IDC}
  System::Call `user32::DestroyWindow(i R0)`
!macroend

; Give window transparent background.
!macro SetTransparent HWND IDC
    GetDlgItem $R0 ${HWND} ${IDC}
    SetCtlColors $R0 0x444444 transparent
!macroend


!macro setwhite HWND IDC
  GetDlgItem $R0 ${HWND} ${IDC}
  SetCtlColors $R0 ffffff transparent  # set text color here  ==> white -  ffffff   gray ,  transparent
!macroend
 
 
; Refresh window.
!macro RefreshWindow HWND IDC
  GetDlgItem $R0 ${HWND} ${IDC}
  ShowWindow $R0 ${SW_HIDE}
  ShowWindow $R0 ${SW_SHOW}
!macroend
 ; --------------------------------------------------------------------------------------------------
; Macros
; --------------------------------------------------------------------------------------------------
 
; --------------------------------------------------------------------------------------------------
; Functions
; --------------------------------------------------------------------------------------------------
 
Function MyGUIInit
  ; Extract bitmap image.
  InitPluginsDir
  ReserveFile `${BITMAP_FILE}`
  File `/ONAME=$PLUGINSDIR\bg.bmp` `${BITMAP_FILE}`
  System::Call `user32::GetClientRect(i $HWNDPARENT, i R0)`
  System::Free $R0
  ; Create bitmap control.
  System::Call `kernel32::GetModuleHandle(i 0) i.R3`
  System::Call `user32::CreateWindowEx(i 0, t "STATIC", t "", i ${SS_BITMAP}|${WS_CHILD}|${WS_VISIBLE}, i 0, i 0, i R1, i R2, i $HWNDPARENT, i,i R3, i 0) i.R1`
  System::Call `user32::SetWindowPos(i R1, i , i 0, i 0, i 0, i 0, i })`
  ; Set the bitmap.
  System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\bg.bmp", i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) i.s`
  Pop $hBitmap
  SendMessage $R1 ${STM_SETIMAGE} ${IMAGE_BITMAP} $hBitmap
FunctionEnd
; Refresh parent window controls.
; Has to be done for some controls if they have a transparent background.
Function RefreshParentControls
  !insertmacro RefreshWindow $HWNDPARENT 1020
  !insertmacro RefreshWindow $HWNDPARENT 1019
  !insertmacro RefreshWindow $HWNDPARENT 1256
  !insertmacro RefreshWindow $HWNDPARENT 1024
  !insertmacro RefreshWindow $HWNDPARENT 1023
FunctionEnd

; from page dir
; DirectoryPage "#32770" "" $HWNDPARENT
; DirectoryPage.Text $mui.DirectoryPage               1006
; DirectoryPage.DirectoryBox $mui.DirectoryPage       1020
; DirectoryPage.Directory $mui.DirectoryPage          1019
; DirectoryPage.BrowseButton $mui.DirectoryPage       1001
; DirectoryPage.SpaceRequired $mui.DirectoryPage      1023
; DirectoryPage.SpaceAvailable $mui.DirectoryPage     1024
  

; For directory page.
Function DirectoryPageShow
SetCtlColors $mui.DirectoryPage.title 0xFFFFFF transparent # Set Transparent page bg
;Set transparent backgrounds.
FindWindow $0 "#32770" "" $HWNDPARENT
!insertmacro setwhite $0 1256 # SpaceRequired 
!insertmacro setwhite $0 1023  # SpaceRequired  
!insertmacro SetTransparent $0 1001 # dimm this is working
!insertmacro SetTransparent $0 1008 # dimm this is working
!insertmacro SetTransparent $0 1001
!insertmacro setwhite $0 1024 # space availbe  
!insertmacro SetTransparent $0 1008
!insertmacro SetTransparent $0 1006  # middle bg 
; !insertmacro SetTransparent $0 1020  # this is label of Dest. Folder
SendMessage $R0 ${WM_SETTEXT} 0 STR: # hide label "Directory Folder"


; Remove unwanted controls.
!insertmacro DestroyWindow $HWNDPARENT 1023 # remove line here  working 
!insertmacro DestroyWindow $HWNDPARENT 1020 # remove line here  working 
!insertmacro DestroyWindow $HWNDPARENT 1256 # remove line here  working 
!insertmacro DestroyWindow $HWNDPARENT 1028 # remove line here  working
!insertmacro DestroyWindow $HWNDPARENT 1039 # remove line here working


 
; Refresh controls.
Call RefreshParentControls
FunctionEnd
 

; Free loaded resources.
Function .onGUIEnd
  ; Destroy the bitmap.
  ; System::Call `gdi32::DeleteObject(i s)` $hBitmap
FunctionEnd
 
; --------------------------------------------------------------------------------------------------
; Dummy section
; --------------------------------------------------------------------------------------------------
 
Section "Dummy Section"
SectionEnd

enter image description here

DIMM_V2
  • 105
  • 1
  • 9