skullcruncha
4th December 2007 18:44 UTC
Load Textbox with contents of a textfile in InstallOptions
I have searched high and low for an example of this but I think there really is no exmple of this.
Here is the code I have written to do it, and it has a flaw - it seems only the first 1024 characters get sent to the text/edit control:
Function EULAPage
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "${MY_FORM}"
!insertmacro MUI_HEADER_TEXT "[Software] Optional Installation" "Installing this option provides ..."
# Alter the ini file before displaying
WriteINIStr $PLUGINSDIR\${MY_FORM} "Field 4" "Text" $PLUGINSDIR\${MY_IMAGE}
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "${MY_FORM}"
Loop:
IntOp $R1 $R1 + 1
${LineRead} "newEULA.txt" $R1 $0
StrCpy $1 "$1$0"
IfErrors Done Loop
Done:
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "${MY_FORM}" "Field 6" "HWND"
SendMessage $R0 ${WM_SETTEXT} 0 "STR:$1"
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
How do I read the entire contents of a text file and send that to a readonly scrollable textbox on a custom form?
pospec
4th December 2007 22:00 UTC
Here?
skullcruncha
4th December 2007 23:05 UTC
That was right on the money, perfect help. Thanks!
Minor tweaking of the code:
Function MyPage
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "${MY_FORM}"
!insertmacro MUI_HEADER_TEXT "[Software] Optional Installation" "Installing this option provides ..."
# Alter the ini file before displaying
WriteINIStr $PLUGINSDIR\${MY_FORM} "Field 4" "Text" $PLUGINSDIR\${MY_IMAGE}
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "${MY_FORM}"
!insertmacro MUI_INSTALLOPTIONS_READ $9 "${MY_FORM}" "Field 6" "HWND"
System::Call 'kernel32::CreateFile(t "$PLUGINSDIR\${LIC_NAME}", i ${GENERIC_READ}, i ${FILE_SHARE_READ}, i 0, i ${OPEN_EXISTING}, i 0, i 0) i .r0'
IfErrors exit
System::Call 'kernel32::GetFileSize(i r0, i 0) i .r1'
IntOp $1 $1 + 1 ; for terminating zero
System::Alloc $1
Pop $2
System::Call 'kernel32::ReadFile(i r0, i r2, i r1, *i .r3, i 0)'
System::Call 'kernel32::CloseHandle(i r0)'
SendMessage $9 ${WM_SETTEXT} $9 $2
System::Free $2
exit:
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
Works on Vista too!