Old 12th December 2007, 08:14   #1
LuP
Junior Member
 
Join Date: Jan 2007
Location: Praha, Czech Republic
Posts: 13
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
LuP is offline   Reply With Quote
Old 12th December 2007, 09:07   #2
pospec
Senior Member
 
pospec's Avatar
 
Join Date: Jun 2007
Location: Otrokovice, Czech Republic
Posts: 308
I have tried to make it:
PHP Code:
!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$__SetTextVar1t$__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
pospec is offline   Reply With Quote
Old 12th December 2007, 15:05   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
!macro __SetText CONTROL TEXT
System::Call `user32::SetWindowText(i${CONTROL}, t${TEXT})`
!macroend
!define SetText `!insertmacro __SetText`

Stu
Afrow UK is offline   Reply With Quote
Old 12th December 2007, 15:21   #4
LuP
Junior Member
 
Join Date: Jan 2007
Location: Praha, Czech Republic
Posts: 13
... It also doesn't work.

But I found a solution elsewhere:

SendMessage $Ctl ${WM_SETTEXT} 0 STR:$Text

Thanks for replies.

LuP

Last edited by LuP; 12th December 2007 at 16:41.
LuP is offline   Reply With Quote
Old 12th December 2007, 16:31   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK 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