Archive: Could I Change "CAPTION" at run-time?


Could I Change "CAPTION" at run-time?
Sorry, my English is very very poor.

I want to show "current run windows version" inside "Main Install Window Title".

Unfortunally, "Caption" & "SubCaption" & "NAME" could not exist inside a function.

I do want to change Main Install Window Title at run-time phase.

Does anyone known any other way to do that?

Thank you very much.


Use the System plug-in to call this API:

http://msdn.microsoft.com/library/de...WindowText.asp


Thanks for replay. I tried this:


OutFile "NewWinverTest.exe"
Name "NewWinverTest"
Caption "New Winver Test"
XPStyle "on"

Section "-bbo" b2
Sectionin RO
;
SectionEnd

Function ".onInit"
StrCpy $1 "$windir"
IfFileExists "$1\winver.exe" +2
StrCpy $1 "$sysdir"
GetDllVersion "$1\winver.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "Ver is $R2.$R3.$R4.$R5"
System::Call 'USER32::SetWindowTextA(i $HWNDPARENT, *t r0) i r1'
messagebox mb_ok "Ver = $R2.$R3.$R4.$R5"
Quit
FunctionEnd


And the Window Caption still not changed.

Is there something wrong from my code?

After a deep search to this forum, I got some poor idea from this article.
==
First part: Main Install Program

Thanks to "rsegal", it really worked. And you find it's limit, too.

So I must add pre_page_call to every pages.


Page license ResetCaption
Page directory ResetCaption
Page components ResetCaption
Page instfiles ResetCaption
UninstPage uninstConfirm un.ResetCaption
UninstPage instfiles un.ResetCaption

!macro ResetCaption InstPhase
Function "${InstPhase}ResetCaption"
SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:$RunTimeCaption"
FunctionEnd
!macroend

!insertmacro ResetCaption ""
!insertmacro ResetCaption "un."

==
Second part: MessageBOX

Looks like there is no way to got a HWND with MessageBOX.

So I must use Win32API to handle all MessageBOX through SYSTEM Plug-in.

!include "${NSISDIR}\Contrib\System\System.nsh"
!include "WinMessages.nsh"

Var MsgButton

!define MessageBOX "!insertmacro MessageBOX"

!macro MessageBox MyButton MyBoxIcon MyContent MyCaption
push $1
StrCpy $1 '${MyBoxIcon}'
StrCmp $1 '' 0 +2
StrCpy $1 '${MB_OK}'
IntOP $1 ${MyButton} + $1
System::Call 'user32::MessageBoxA(i $HWNDPARENT, t "${MyContent}", t "${MyCaption}", i "$1") i .s'
pop $MsgButton
pop $1
!macroend


Useage:
${MessageBOX} "Buttons" "icons" "Window Text here" "Window Title hehe"

Return (inside $MsgButton):
1 = ok
2 = cancel
3 = abort
4 = retry
5 = ignore
6 = yes
7 = no

Ex. changed from NSIS MessageBOX.
Before: MessageBox MB_OK|MB_ICONEXCLAMATION "$(MSG_POSTINST)"
After: ${MessageBox} "${MB_OK}" "${MB_ICONEXCLAMATION}" "$(MSG_POSTINST)" "Run-time Caption Here"
==
That's all poor idea from me.

If you got a better way to do it, please post it to forum, thank you.

Remove Icons, rename Buttons to Styles, as you can combine the styles naturally with NSIS MessageBox command, and change position of Caption with Message, as generally messages are big, and you can see where to write the caption.

I should work on doing macros for System plugin calls, but now I'm working on another very special beaulty for NSIS right now... (What's the surprise?)