LuP
12th December 2007 08:14 UTC
How to set control text
Hello,
New to NSIS... I'm trying to set control text to "AAA". I'm doing this in the following way:
...
!include LogicLib.nsh
!include nsDialogs.nsh
!macro __SetText CONTROL VAR
System::Call user32::SetWindowText(i.${CONTROL}, t.'AAA')
!macroend
!define SetText `!insertmacro __SetText`
...
(In a callback:)
${SetText} $Ctl "BBB"
But it doesn't work. I tried to change prefixes in SetWindowText (i ... t), but no success. See the attachment.
Any idea?
Thanks.
LuP
pospec
12th December 2007 09:07 UTC
I have tried to make it:
!macro __SetText CONTROL VARIABLE
!ifndef __SetTextVars
!define __SetTextVars
Var /GLOBAL __SetTextVar1
Var /GLOBAL __SetTextVar2
!endif
StrCpy $__SetTextVar1 `${VARIABLE}`
StrCpy $__SetTextVar2 `${CONTROL}`
messagebox mb_ok `$__SetTextVar1 $__SetTextVar2`
System::Call user32::SetWindowText(i$__SetTextVar1, t$__SetTextVar2)
!macroend
>!define SetText `!insertmacro __SetText`
...and call:
StrCpy $0 'AAA'
${SetText} $EDIT $0
But it doesn't work. I know, where is problem - because I don't understand that
i., t., i, t tricks
Afrow UK
12th December 2007 15:05 UTC
!macro __SetText CONTROL TEXT
System::Call `user32::SetWindowText(i${CONTROL}, t${TEXT})`
!macroend
!define SetText `!insertmacro __SetText`
Stu
LuP
12th December 2007 15:21 UTC
... It also doesn't work.
But I found a solution elsewhere:
SendMessage $Ctl ${WM_SETTEXT} 0 STR:$Text
Thanks for replies.
LuP
Afrow UK
12th December 2007 16:31 UTC
Sorry, would need to ensure that the text is surrounded by quotes:
System::Call `user32::SetWindowText(i${CONTROL}, t"${TEXT}")`
WM_SETTEXT with SendMessage will work as well.
Stu