在图形安装程序和 NSIS 中,标签的文本在我动态更改时重叠
With in Graphical Installer & NSIS, the text of Label overlapped when I changed it dynamically
我创建了一个自定义页面,其中包含一个标签和两个用于控制标签内容的按钮。
我想在按钮的回调中设置标签的文本,如下代码:
Function FuncShowNewFeature
; ...
; Add Controls
${NSD_CreateLabel} 0 13u 100% 12u "Show new features here"
Pop $lblContents
${GraphicalInstallerRedrawLabel} $lblContents
${NSD_CreateButton} 0 -13u 40u 13u "Prev"
Pop $btnPrev
${NSD_OnClick} $btnPrev PrevFeature ; callback
${NSD_CreateButton} -40u -13u 40u 13u "Next"
Pop $btnNext
${NSD_OnClick} $btnNext NextFeature ; callback
# Put this macro before EACH calling nsDialogs::Show to draw background properly
${GraphicalInstallerRedrawnsDialogsPage}
nsDialogs::Show
FunctionEnd
Function NextFeature
${NSD_SetText} $lblContents "To show the next tip of new-feature"
${GraphicalInstallerRedrawLabel} $lblContents ;I don't know whether this macro is necessary here
FunctionEnd
Function PrevFeature
${NSD_SetText} $lblContents "To show the previous tip of new-feature"
${GraphicalInstallerRedrawLabel} $lblContents ;I don't know whether this macro is necessary here
FunctionEnd
但是结果显示有问题,“新”文本重叠在旧文本上,就像标签在重绘之前没有refreshed/cleared。
我在我的过程中是否错过了任何必要的调用?
您缺少 GraphicalInstaller::SubclassLabel /NOUNLOAD $variable_name
正确代码:
Function FuncShowNewFeature
; ...
; Add Controls
${NSD_CreateLabel} 0 13u 100% 12u "Show new features here"
Pop $lblContents
${GraphicalInstallerRedrawLabel} $lblContents
GraphicalInstaller::SubclassLabel /NOUNLOAD $lblContents # <<< ADDED HERE
${NSD_CreateButton} 0 -13u 40u 13u "Prev"
Pop $btnPrev
${NSD_OnClick} $btnPrev PrevFeature ; callback
${NSD_CreateButton} -40u -13u 40u 13u "Next"
Pop $btnNext
${NSD_OnClick} $btnNext NextFeature ; callback
# Put this macro before EACH calling nsDialogs::Show to draw background properly
${GraphicalInstallerRedrawnsDialogsPage}
nsDialogs::Show
FunctionEnd
Function NextFeature
${NSD_SetText} $lblContents "To show the next tip of new-feature"
FunctionEnd
Function PrevFeature
${NSD_SetText} $lblContents "To show the previous tip of new-feature"
FunctionEnd
GraphicalInstaller::Subclass[CONTROL] 是的一部分
${GraphicalInstallerRedraw[CONTROL]} 宏。
这适用于类型为 RadioButton 或 CheckBox 的 [CONTROL],但它在 Label 中缺失。
我们将在下一个版本中修复此问题,对于此不一致之处,我们深表歉意。
一个简单的解决方法是在更新文本时隐藏标签:
!include nsDialogs.nsh
Page Custom gfxpage
Function onClick
Pop [=10=]
System::Call 'kernel32::GetTickCount()i.r0' ; "Arbitrary" number
ShowWindow 0
${NSD_SetText} "[=10=][=10=][=10=]"
ShowWindow 1
FunctionEnd
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\image.bmp "${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp"
FunctionEnd
Function gfxpage
nsDialogs::Create 1018
Pop [=10=]
${NSD_CreateButton} 0 -13u 100% 12u "Click me"
Pop
${NSD_OnClick} onClick
${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
Pop
SetCtlColors 000000 transparent
${NSD_CreateBitmap} 0 0 100% 12u ""
Pop
${NSD_SetBitmap} $PLUGINSDIR\image.bmp
nsDialogs::Show
${NSD_FreeBitmap}
FunctionEnd
我创建了一个自定义页面,其中包含一个标签和两个用于控制标签内容的按钮。 我想在按钮的回调中设置标签的文本,如下代码:
Function FuncShowNewFeature
; ...
; Add Controls
${NSD_CreateLabel} 0 13u 100% 12u "Show new features here"
Pop $lblContents
${GraphicalInstallerRedrawLabel} $lblContents
${NSD_CreateButton} 0 -13u 40u 13u "Prev"
Pop $btnPrev
${NSD_OnClick} $btnPrev PrevFeature ; callback
${NSD_CreateButton} -40u -13u 40u 13u "Next"
Pop $btnNext
${NSD_OnClick} $btnNext NextFeature ; callback
# Put this macro before EACH calling nsDialogs::Show to draw background properly
${GraphicalInstallerRedrawnsDialogsPage}
nsDialogs::Show
FunctionEnd
Function NextFeature
${NSD_SetText} $lblContents "To show the next tip of new-feature"
${GraphicalInstallerRedrawLabel} $lblContents ;I don't know whether this macro is necessary here
FunctionEnd
Function PrevFeature
${NSD_SetText} $lblContents "To show the previous tip of new-feature"
${GraphicalInstallerRedrawLabel} $lblContents ;I don't know whether this macro is necessary here
FunctionEnd
但是结果显示有问题,“新”文本重叠在旧文本上,就像标签在重绘之前没有refreshed/cleared。
我在我的过程中是否错过了任何必要的调用?
您缺少 GraphicalInstaller::SubclassLabel /NOUNLOAD $variable_name
正确代码:
Function FuncShowNewFeature
; ...
; Add Controls
${NSD_CreateLabel} 0 13u 100% 12u "Show new features here"
Pop $lblContents
${GraphicalInstallerRedrawLabel} $lblContents
GraphicalInstaller::SubclassLabel /NOUNLOAD $lblContents # <<< ADDED HERE
${NSD_CreateButton} 0 -13u 40u 13u "Prev"
Pop $btnPrev
${NSD_OnClick} $btnPrev PrevFeature ; callback
${NSD_CreateButton} -40u -13u 40u 13u "Next"
Pop $btnNext
${NSD_OnClick} $btnNext NextFeature ; callback
# Put this macro before EACH calling nsDialogs::Show to draw background properly
${GraphicalInstallerRedrawnsDialogsPage}
nsDialogs::Show
FunctionEnd
Function NextFeature
${NSD_SetText} $lblContents "To show the next tip of new-feature"
FunctionEnd
Function PrevFeature
${NSD_SetText} $lblContents "To show the previous tip of new-feature"
FunctionEnd
GraphicalInstaller::Subclass[CONTROL] 是的一部分 ${GraphicalInstallerRedraw[CONTROL]} 宏。
这适用于类型为 RadioButton 或 CheckBox 的 [CONTROL],但它在 Label 中缺失。
我们将在下一个版本中修复此问题,对于此不一致之处,我们深表歉意。
一个简单的解决方法是在更新文本时隐藏标签:
!include nsDialogs.nsh
Page Custom gfxpage
Function onClick
Pop [=10=]
System::Call 'kernel32::GetTickCount()i.r0' ; "Arbitrary" number
ShowWindow 0
${NSD_SetText} "[=10=][=10=][=10=]"
ShowWindow 1
FunctionEnd
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\image.bmp "${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp"
FunctionEnd
Function gfxpage
nsDialogs::Create 1018
Pop [=10=]
${NSD_CreateButton} 0 -13u 100% 12u "Click me"
Pop
${NSD_OnClick} onClick
${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
Pop
SetCtlColors 000000 transparent
${NSD_CreateBitmap} 0 0 100% 12u ""
Pop
${NSD_SetBitmap} $PLUGINSDIR\image.bmp
nsDialogs::Show
${NSD_FreeBitmap}
FunctionEnd