Archive: Dynamic custom page


Dynamic custom page
I'm wondering if there is a way to dynamically alter the content, specifically text boxes on a custom screen. I've got an initial screen that detects and displays missing/installed components. When the user clicks next, it'll then install the missing components. I want the text fields to change from "not installed" to "installing" and then once ExecWait is done, "installed".

Below is the code snippet of the two screens I'm trying to modify. Suggestions?


Function VersionPage
!insertmacro MUI_HEADER_TEXT "Detected Versions" "The components shown below were detected on your system. All are required for RTO to function. Click Next to install missing components."

Call CheckNET2
Pop $NET2
${If} $NET2 == "not found"
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 3" "State" "Not Installed"
${Else}
StrCpy $NET2 $NET2 "" 1 # skip "v"
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 3" "State" "Installed $NET2"
${EndIf}

Call CheckVCRedist
Pop $VC8
${If} $VC8 != -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 5" "State" "Installed"
${EndIf}

Call CheckMSXML6
Pop $MSXML6
${If} $MSXML6 != -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 7" "State" "Installed $MSXML6"
${EndIf}

Call CheckSQLClient
Pop $SQLCLI
${If} $SQLCLI != -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 9" "State" "Installed $SQLCLI"
${EndIf}

Call CheckSQLSMO
Pop $SQLSMO
${If} $SQLSMO != -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 11" "State" "Installed"
${EndIf}

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "versionpage.ini"
FunctionEnd

Function VersionPageLeave
!insertmacro MUI_HEADER_TEXT "Installing Missing Components" "The missing components are currently being installed."
#Check for .NET 2.0
!insertmacro CheckDotNET

#Install VC++ 2005 redist
${If} $VC8 == -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 5" "State" "Installing..."
SetOutPath $PLUGINSDIR
SetOverwrite on
File App\vcredist_x86.exe
ExecWait "$PLUGINSDIR\vcredist_x86.exe"
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 5" "State" "Installed"
${EndIf}

#Installs MSXML 6.0 Parser
${If} $MSXML6 == -1
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 7" "State" "Installing..."
SetOutPath $PLUGINSDIR
SetOverwrite on
File App\msxml6_x86.msi
ExecWait '"msiexec" /i /qr $PLUGINSDIR\msxml6_x86.msi"'
!insertmacro MUI_INSTALLOPTIONS_WRITE "versionpage.ini" "Field 7" "State" "Installed"
${EndIf}

Return
FunctionEnd

I think you can write a plugin or use the system plugin to get current window handle and modifiy items on window
I don't think you can tell the installoptions plugin to 'reload' the ini file once the windows has been displayed


Alright, so looks like I need to use the functionality of WinMessages.nsh. Looking at the Refreshing labels after color change, example is basically what I need to do. But what's going on makes no sense to me. Anyone able to explain it?

How do I find specific text fields and then alter their text?


The controls on your custom page will have hWnd entries in the ini file. You can use

!insertmacro MUI_INSTALLOPTIONS_READ $0 "versionpage.ini" "Field 7" "HWND"
to get the handle for field 7, for example. These handles are put into the ini file during the dialog initialization, so they are there after calling either MUI_INSTALLOPTIONS_DISPLAY or MUI_INSTALLOPTIONS_INITDIALOG.

You use the handle to write changes to the fields like this:
ShowWindow $R0 ${SW_HIDE}
SetCtlColors $R0 00FF00 transparent
ShowWindow $R0 ${SW_SHOW}
or:
SendMessage $0 ${WM_SETTEXT} 0 "STR:Installed $MSXML6"

or like this:
GetDlgItem $0 $HWNDPARENT 0x40E
SendMessage $0 ${WM_SETTEXT} 0 "STR:$(TEXT_IO_SUBTITLE2)"

If you want to do something to the Next and Cancel buttons, they are id 1 and 2 on the dialog that $HWNDPARENT points to. This code would disable the Next button:
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 0

And this reenables it:
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1

You should be able to take it from here...

Don