Skip to content
⌘ NSIS Forum Archive

How to dynamically update a label text on the fly

2 posts

DivyaArun#

How to dynamically update a label text on the fly

Hi,

I have a label under which I am showing a progress bar. I need to display "Validation success " in the label after successful validation or else "Validation failed" .

Below is the code snippet

${NSD_CreateLabel} 0.09u 5.54u 102.03u 14.5u "Validating process"
$myLabel

${NSD_CreateProgressBar} 0.09u 21.54u 100% 10% ""
Pop $hwnd
${NSD_AddStyle} $hwnd ${PBS_MARQUEE}

${NSD_CreateTimer} StartValidation 1000

Function StartValidation

${NSD_KillTimer} StartValidation
Call Validate
${If} ${Errors}
SendMessage $myLabel ${WM_SETTEXT} 0 "Failed"
${Else}
SendMessage $myLabel ${WM_SETTEXT} 0 "Success"
${EndIf}
SendMessage $hwnd ${PBM_SETMARQUEE} 0 0
FunctionEnd
Anders#
Sending a string in a message requires the STR: prefix

SendMessage $whatever ${WM_SETTEXT} 0 "STR:Hello"
You can also use the NSD_SetText macro.