Old 31st August 2017, 12:06   #1
o_owd
Senior Member
 
o_owd's Avatar
 
Join Date: Feb 2003
Location: TGM, Romania
Posts: 176
Send a message via ICQ to o_owd Send a message via Yahoo to o_owd
components / image preview

Hey,

At the component selection page, is it possible to show an image in a separate window based on what component is selected?
I found on Google something similar for Inno but not for NSIS - https://i.stack.imgur.com/IPKm4.jpg

Thanks.
o_owd is offline   Reply With Quote
Old 4th September 2017, 14:40   #2
Kuppy
Junior Member
 
Join Date: Sep 2016
Posts: 34
I used the nsWindows.dll plug-in, but some malfunctions I can not fix, and whoever knows better can fix the problems.
1. Move the popup window to the main window
2. Close the popup automatically when you move the mouse to another component

PHP Code:
!define APP "My Setup"
!define INIT
!define COMPONENTS

# DETAILS #

Name "${APP}"
OutFile "${APP}.exe"
InstallDir "$TEMP\${APP}"
Caption "${APP}"

# COMPRESS #

SetCompressor /SOLID /FINAL lzma

# EXEC LEVEL #

RequestExecutionLevel 'User'

# RUNTIME SWITCHES #

ShowInstDetails hide
ShowInstDetails nevershow
ShowUnInstDetails nevershow
AutoCloseWindow true 

# INCLUDE #

!include "MUI.nsh"
!include "WinCore.nsh"
!include "nsWindows.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!insertmacro GetOptions

# STYLE #

BrandingText /TRIMRIGHT " "

# PAGE #

!define MUI_CUSTOMFUNCTION_GUIINIT "onGuiInit"
!insertmacro MUI_PAGE_WELCOME
!ifdef OPTIONS COMPONENTS
  
!define MUI_COMPONENTSPAGE_NODESC
  
!define MUI_COMPONENTSPAGE_INTERFACE
  
!define MUI_COMPONENTSPAGE_SMALLDESC
  
!insertmacro MUI_PAGE_COMPONENTS
!endif
!
insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

# LANGUAGE #

!insertmacro MUI_LANGUAGE "English"

# INIT #

Function ".onInit"
  
InitPluginsDir
  SetOverwrite 
try
  
AllowSkipFiles off
  File 
`/ONAME=$PLUGINSDIR\001.bmp` `Images\001.bmp`
  
File `/ONAME=$PLUGINSDIR\002.bmp` `Images\002.bmp`

  
# INIT
 
  
!ifdef INIT
    Call Init
  
!endif
FunctionEnd

Function "onGuiInit"

FunctionEnd

var /GLOBAL ERROR

Section 
"-${APP}Main
  Strcpy $insWindows 0
  Strcpy $hnsWindows 0

  SetDetailsPrint textonly
  DetailPrint 
`Installing ... Please wait ...`
  
SetDetailsPrint listonly
  SetDetailsView hide

  SectionIn RO

  CreateDirectory $INSTDIR
    SetOutPath 
"$INSTDIR"
     
File "Installer.nsi"

  
Goto +2
   StrCpy $ERROR 
"true"
  
SetAutoClose true
SectionEnd

!ifdef COMPONENTS
    SectionGroup 
"${APP} Select"

      
Section /"${APP} Free" Free

      SectionEnd

      Section 
/"${APP} Professional" Professional
        IfFileExists 
"$INSTDIR\${APP}.exe" "" +4
            SetOutPath 
"$INSTDIR"
                
;File "Professional\Register.dll"
      
SectionEnd

    SectionGroupEnd
!endif

Function .
onSelChange
    
!insertmacro StartRadioButtons $1
    
!insertmacro RadioButton "${Free}"
    
!insertmacro RadioButton "${Professional}"
    
!insertmacro EndRadioButtons
FunctionEnd

!ifdef INIT
    
Function Init
           
var /GLOBAL REQUIREDSIZE
        
; === Destroy size lol ===

        
StrCpy $0 0
        
${If} ${SectionIsSelected} $0
                SectionGetSize 
$${Main} $1
                SectionGetSize 
$${Free} $1
                SectionGetSize 
$${Professional} $1
            IntOp 
$$+ $1
        
${EndIf}    
        
InTop $$1024 KBytes -> Bytes
        IntOp 
$$1000000
        IntOp 
$$1000000
        StrCpy 
$$2 2 0
        IntOp 
$$1048576
        IntOp 
$$1048576
        StrCpy 
$$4 2 0
        SectionSetSize 
$${Main"0" ;use ($1,$2 MB) ;or ($3,$4 MB)
        
Strcpy $REQUIREDSIZE '$3,$4 MB'
        
SectionSetSize $${Main0
        SectionSetSize 
$${Free"0"
        
SectionSetSize $${Professional"0"

        
; === Other actions ===
        
StrCpy $${Free}
    
FunctionEnd
!endif

Function 
ShowPictFreeVersion
  
var /GLOBAL FREE
  
var /GLOBAL BGImage

  nsWindows
::Create /NOUNLOAD $HWNDPARENT $${ExStyle0x80000000 "" 1018
  Pop $FREE

  System
::Call user32::SetWindowPos(i$FREE,i0,i0,i0,i497,i322,i0x0002)

  
# Background

  
nsWindows::CreateControl /NOUNLOAD STATIC 0x10000000|0x40000000|0x04000000|0x0000000E 0 0 0 100100""
  
Pop $BGImage
  Push 
$0
  Push $R0
  StrCpy $R0 $BGImage
  System
::Call "user32::LoadImage(i 0, ts, i 0, i0, i0, i0x0010) i.r0" "$PLUGINSDIR\001.bmp"
  
SendMessage $R0 0x0172 0 $0
  Pop $R0
  Exch 
$0

  nsWindows
::Show

FunctionEnd

Function ShowPictProVersion
  
var /GLOBAL PRO

  nsWindows
::Create /NOUNLOAD $HWNDPARENT $${ExStyle0x80000000 "" 1018
  Pop $PRO

  System
::Call user32::SetWindowPos(i$PRO,i0,i0,i0,i497,i322,i0x0002)

  
# Background

  
nsWindows::CreateControl /NOUNLOAD STATIC 0x10000000|0x40000000|0x04000000|0x0000000E 0 0 0 100100""
  
Pop $BGImage
  Push 
$0
  Push $R0
  StrCpy $R0 $BGImage
  System
::Call "user32::LoadImage(i 0, ts, i 0, i0, i0, i0x0010) i.r0" "$PLUGINSDIR\002.bmp"
  
SendMessage $R0 0x0172 0 $0
  Pop $R0
  Exch 
$0

  nsWindows
::Show

FunctionEnd

# MOUSE

Function '.onMouseOverSection'
        
FindWindow $R0 "#32770" "" $HWNDPARENT
        GetDlgItem $R0 $R0 1043 
description item
        
${If} $== -1
              CreateFont 
$"Arial" 9 500 create the font for the default description

              SetCtlColors $R0 0x5f5f61 0xF0F0F0
              SendMessage $R0 
${WM_SETFONT} $1 0
              EnableWindow $R0 0
                  SendMessage $R0 
${WM_SETTEXT"STR:Position your mouse over a component to see its description."
           
System::Call user32::DestroyWindow(i$FREE)
           
System::Call user32::DestroyWindow(i$PRO)
        ${Else}
            
CreateFont $"Arial" 9 400 create the font for mouse over descriptions

        SetCtlColors $R0 0x5f5f61 0xF0F0F0
            SendMessage $R0 
${WM_SETFONT} $1 0
            EnableWindow $R0 1
        
${If} $== 0
              SendMessage $R0 
${WM_SETTEXT"STR:Select components for this program"

        
${ElseIf} $== 1

              SendMessage $R0 
${WM_SETTEXT"STR:Select components for this program"

        
${ElseIf} $== 2
            System
::Call user32::DestroyWindow(i$PRO)
            
Call ShowPictFreeVersion
              SendMessage $R0 
${WM_SETTEXT"STR:Install ${APP} Free Version"

        
${ElseIf} $== 3
            System
::Call user32::DestroyWindow(i$FREE)
            
Call ShowPictProVersion
              SendMessage $R0 
${WM_SETTEXT"STR:Install ${APP} Pro Version"

        
${ElseIf} $== 4

        
${EndIf}

        ${EndIf}
FunctionEnd 
Attached Files
File Type: 7z Installer.7z (58.3 KB, 19 views)
Kuppy is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump