Search code examples
installationnsis

How to change custom page label text on the fly in nsis?


I have written a custom page where i want to change the label text on the fly .I tried following code but some how I could not bale to change the text .

    Function Maintainance 
    nsDialogs::Create 1018
        Pop $Dialog
        ${If} $Dialog == error
            Abort
        ${EndIf}


        ${NSD_CreateLabel} 0 0 100% 12u "The $CurrentVersion complete installation folder is available at the below link"
        Pop $Label
    FindWindow $0 "#32770" "" $HWNDPARENT
     GetDlgItem $1 $0 1006


    SendMessage $1 ${WM_SETTEXT} 0 "STR:new value 111111"
    nsDialogs::Show
FunctionEnd

Any pointer on this will be a help.


Solution

  • The custom page is not visible until you call nsDialogs::Show. Any dynamic action has to happen after that with a timer or in response to a user action:

    Page Custom MyPageCreate
    Page InstFiles
    
    !include nsDialogs.nsh
    
    var mylabel
    
    Function MyPageCreate
    nsDialogs::Create 1018
    Pop $0
    ${NSD_CreateLabel} 0 0 100% 12u "Hello"
    Pop $mylabel
    ${NSD_CreateButton} 0 50% 50% 12u "Change"
    Pop $0
    ${NSD_OnClick} $0 ChangeIt
    nsDialogs::Show
    FunctionEnd
    
    Function ChangeIt
    System::Call kernel32::GetTickCount()i.r0
    SendMessage $mylabel ${WM_SETTEXT} 0 "STR:World! $0"
    FunctionEnd