0

How to hide a Custom LABEL added on the Directory Page Dialog of the NSIS installer. The LABEL is added using the Resource Hacker and its id is 1300

How to change the text of the LABEL conditionally?

If user choses to install DEMO, then the label text should be "DEMO" , and if user choses to install UPDATE , then the label text should be "UPDATE"

I have added 2 labels, now i am hiding and showing them accordingly.Label1 ID is 1300 , Label2 ID is 1301.

# Occurs on Directory page show.
Function DirectoryShow

   ${If} $InstallType == DEMO

    GetDlgItem $5 $HWNDPARENT 1300
MessageBox MB_OK "ID of First Label is $5"  ----IT SHOWS '0' INSTEAD OF SHOWING 1300

 ${NSD_SetText} $5 "INSTALLING DEMO OF SOFTWARE!!!!!!!!!!!!!!!!!" 

GetDlgItem $6 $HWNDPARENT 1301
ShowWindow $6 ${SW_HIDE}

;GetDlgItem $1 $HWNDPARENT 2
;ShowWindow $0 ${SW_SHOW}
;ShowWindow $1 ${SW_HIDE}

 ${Else}

GetDlgItem $7 $HWNDPARENT 1300
ShowWindow $7 ${SW_HIDE}

GetDlgItem $8 $HWNDPARENT 1301
 ${NSD_SetText} $8 "UPDATING EXISTING SOFTWARE !!!!!!!!!!!!!!!!!" 

${EndIf}
FunctionEnd 

HOW DO I GET THE ID OF THESE LABELS?

Machavity
  • 30,841
  • 27
  • 92
  • 100
sqlchild
  • 8,754
  • 28
  • 105
  • 167
  • You want the label handle, not the id. 1300 is the control id, GetDlgItem will give you the (window) handle, also known as a HWND. – Anders Apr 29 '11 at 13:04

1 Answers1

5

NSIS uses a child dialog to host the actual pages:

enter image description here

You first need to get the handle to the inner dialog, then you can find the label:

FindWindow $0 "#32770" "" $HWNDPARENT ;(This is documented under section 4.9.14.6 in the help file)
GetDlgItem $5 $0 1300
Anders
  • 97,548
  • 12
  • 110
  • 164
  • @Anders : how do I set the label text according to my choice? – sqlchild Apr 29 '11 at 13:09
  • sir, what does this do -- {|} – sqlchild Apr 29 '11 at 13:10
  • You already know how to set the text, WM_SETTEXT (http://stackoverflow.com/questions/5803182/fill-directory-textbox-on-button-click-in-mui-nsi-installer-using-buttonevent-p) – Anders Apr 29 '11 at 13:17
  • 1
    ${|} is part of the syntax used by ${IfThen} and the logiclib, see http://stackoverflow.com/questions/5444785/how-do-i-capture-the-results-of-a-yesnocancel-messagebox-without-gotos-labels-in/5446798#5446798 – Anders Apr 29 '11 at 13:19
  • @Anders: sir, how do i hide the Label 1301 when 1300 is displayed? – sqlchild Apr 29 '11 at 13:36
  • 1
    Why are you making this harder than it has to be? You already have all the pieces, FindWindow+GetDlgItem+ShowWindow (http://pastebin.com/eZeBk8Kw) – Anders Apr 29 '11 at 13:41
  • For quick reference, link to the section: http://www.helpdoc-online.com/nsis_users_manual/Section4.9.html Also, +1 For the graphical explanation – BiLaL Aug 31 '14 at 12:54