如何在现有页面中创建两种类型的视图

时间:2015-08-26 06:58:05

标签: nsis

我尝试找到一个解决方案,在" Page组件中设置一个复选框。并且当选中复选框时,SectionGroup"树模型"要显示,如果未选中复选框,则为SectionGroup" normal mod"要显示。 我找到关于复选框的所有内容,是如何在自定义页面中创建它, 我试图改变我从@Anders收到的代码(如何创建一个复选框),但我所做的只是创建一个新页面来保护我的复选框,然后在那里 我不能同时做两个显示。

这是我的代码:

!include "Sections.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"

Page components
ComponentText""
SpaceTexts""

Var MyCheckbox


Function OnCheckChange
Pop $0
${NSD_GetState} $MyCheckbox $1
${If} $1 <> 0
    MessageBox mb_ok "Checked"
${Else}
    MessageBox mb_ok "Not checked"
${EndIf}
FunctionEnd

Function components ; and here I have an error, because is not a custom page, but I do not want to be
;nsDialogs::Create 1018
Pop $0

${NSD_CreateCheckBox} 10u 10u 80% 12u "The checkbox text"
Pop $MyCheckbox
${NSD_OnClick} $MyCheckbox OnCheckChange

;nsDialogs::Show
FunctionEnd 
SectionGroup /e "tree mod"
Section /o "Communications Blockset" box_BONUS2
    ;SectionIn RO
FileWrite $9 "product=Communications Blockset$\r$\n"
    AddSize 0
SectionEnd


Section /o "Communications Toolbox" box_BONUS
    ;SectionIn RO


FileWrite $9 "product=Communications Toolbox$\r$\n"
    AddSize 0
SectionEnd


Section  /o "Control System Toolbox" box_MAIN
    ;SectionIn RO
FileWrite $9 "product=Control System Toolbox$\r$\n"
    AddSize 0
SectionEnd
SectionGroupEnd

Function .OnSelChange
${If} ${SectionIsSelected} ${box_BONUS} 
${OrIf} ${SectionIsSelected} ${box_BONUS2}
    MessageBox MB_OK "simple message box"
    !insertmacro SelectSection ${box_MAIN} 
    !insertmacro SetSectionFlag ${box_MAIN} ${SF_RO}
${Else}
    !insertmacro ClearSectionFlag ${box_MAIN} ${SF_RO}
${EndIf}
FunctionEnd
SectionGroup /e "Toolbox"
Section  /o "Curve Fitting Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Curve Fitting Toolbox$\r$\n"
    AddSize 0
SectionEnd

SectionGroup /e "normal mod"
Section  /o "Curve Fitting Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Curve Fitting Toolbox$\r$\n"
    AddSize 0
SectionEnd


Section /o "Data Acquisition Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Data Acquisition Toolbox$\r$\n"
    AddSize 0
SectionEnd


Section /o "Database Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Database Toolbox$\r$\n"
    AddSize 0
SectionEnd


Section /o "Datafeed Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Datafeed Toolbox$\r$\n"
    AddSize 0
SectionEnd


Section /o "Econometrics Toolbox"
    ;SectionIn RO
FileWrite $9 "product=Econometrics Toolbox$\r$\n"
    AddSize 0
SectionEnd

SectionGroupEnd

Page instfiles

...

所以我有两个问题: 1)如何在&#34; Page组件&#34;中创建一个复选框? 2)如何通过按复选框显示两个视图?

1 个答案:

答案 0 :(得分:2)

NSIS不是为处理组件页面上的复选框而设计的。可以通过使用System插件创建复选框并使用Button event pluginWndSubclass plugin处理单击来完成它,但无论您做什么,这都将是一个黑客攻击。 / p>