Adding custom labels in NSIS dialog pages, showing and hiding labels in NSIS MUI Directory pages conditionally, how to get the ids of labels

折月煮酒 提交于 2019-12-13 05:16:55

问题


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?


回答1:


NSIS uses a child dialog to host the actual pages:

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


来源:https://stackoverflow.com/questions/5831920/adding-custom-labels-in-nsis-dialog-pages-showing-and-hiding-labels-in-nsis-mui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!