NSIS InstallOptionsEx 验证
NSIS InstallOptionsEx Validate
需要有关 InstallOptionsEx 验证的帮助。在 InstallOptions 中我们使用 Flags=Notify 然后我们在函数
中做了这样的事情
ReadINIStr [=10=] "$PLUGINSDIR\test.ini" "Settings" "State"
StrCmp [=10=] 0 validate ; Next button?
StrCmp [=10=] 2 supportx ; "Install support for X"?
StrCmp [=10=] 9 clearbtn ; "Clear" button?
StrCmp [=10=] 11 droplist ; "Show|Hide" drop-list?
Abort ; Return to the page
但在 InstallOptionsEx 中,他们说他们取消了它以支持新方法。
这来自 InstallOptionsEx 自述文件:
Step 5: Validate the Output
If you want to validate the input on the page, for example, you want to check whether the user has filled in a textbox, use the leave function of the Page command and Abort when the validation has failed:
Function ValidateCustom
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
StrCmp [=11=] "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your name."
Abort
FunctionEnd
Step 6: Return Value
After you have called the DLL, InstallOptionsEx adds one string to the stack, with one of the following values:
success - The user has pressed the Next button
back - The user has pressed the Back button
cancel - The user has pressed the Cancel button
error - An error has occurred, the dialog cannot be displayed.
Usually, you don't need to check this value, but you still have to remove it from the stack (have a look at the example above).
You only have to check this value if you need something really special, such as doing something when the user pressed the Back button.
谁能帮我想出新方法?如果您查看下面的代码文件,就会有一个新旧部分,在新部分中您会看到我正在尝试做什么。需要有关代码的帮助。
这是一个ini文件和代码文件:
ini 文件
[Settings]
NumFields=5
[Field 1]
Type=Label
Left=160
Right=235
Top=9
Bottom=18
Text="DropDown 1"
txtAlign=Center
[Field 2]
Type=DROPLIST
ListItems=Option 1a|Option 1b|Option 1c
State=
Flags=
Left=160
Right=235
Top=18
Bottom=25
[Field 3]
Type=Label
Left=240
Right=295
Top=9
Bottom=18
Text="DropDown 2"
txtAlign=Center
[Field 4]
Type=DROPLIST
ListItems=Option 2a|Option 2b|Option 2c
State=
Flags=
Left=240
Right=295
Top=18
Bottom=28
[Field 5]
Type=Button
Flags=NOTIFY
State=
Text="More Info"
Left=200
Right=250
Top=125
Bottom=140
txtAlign=Center
代码文件
!include WinVer.nsh
!include LogicLib.nsh
!include x64.nsh
!include FileFunc.nsh
!include MUI2.nsh
!include WinMessages.nsh
!include InstallOptions.nsh
!include Sections.nsh
!include nsDialogs.nsh
!define MUI_HEADERIMAGE
!define TEMP1 $R0 ;Temp variable
Page custom ShowCustom LeaveCustom ;Custom page. InstallOptions gets called in SetCustom.
!insertmacro MUI_LANGUAGE "English"
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\pagesetup.ini "pagesetup.ini"
FunctionEnd
Function ShowCustom
InstallOptionsEx::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=13=]
InstallOptionsEx::show
Pop [=13=]
FunctionEnd
#Old Method
/*
Function LeaveCustom
ReadINIStr [=13=] "$PLUGINSDIR\pagesetup.ini" "Settings" "State"
StrCmp [=13=] 0 validate ; Next button?
StrCmp [=13=] 5 Infobtn ;
Abort ; Return to the page
Infobtn
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Infobtn Pressed"
Abort ; Return to the page
validate:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Next Pressed"
#Some Code to check if Field 2 and Field 4 have something selected
Abort
FunctionEnd
*/
#New Method
Function LeaveCustom
#Not sure correct code
#If Back Btn Pressed goto backbtn
#If Cancel Btn Pressed goto cancelbtn
#If Next Btn Pressed goto nextbtn
#If Info btn Press goto infobtn
backbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Backbtn Pressed"
Abort
cancelbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Cancelbtn Pressed"
Abort
nextbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Nextbtn Pressed"
Abort
infobtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Infobtn Pressed"
Abort
FunctionEnd
Section
SectionEnd
好吧,我终于弄明白了,虽然我会 post 以防其他人需要。
我有这个:
Function ShowCustom
InstallOptionsEx::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=10=]
InstallOptionsEx::show
Pop [=10=]
FunctionEnd
它应该是这样的:(Ex 不应该在那里)
Function ShowCustom
InstallOptions::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=11=]
InstallOptions::show
Pop [=11=]
FunctionEnd
那就用电流检查一下
ReadINIStr [=12=] "$PLUGINSDIR\test.ini" "Settings" "State"
StrCmp [=12=] 0 validate ; Next button?
StrCmp [=12=] 2 supportx ; "Install support for X"?
StrCmp [=12=] 9 clearbtn ; "Clear" button?
StrCmp [=12=] 11 droplist ; "Show|Hide" drop-list?
Abort ; Return to the page
需要有关 InstallOptionsEx 验证的帮助。在 InstallOptions 中我们使用 Flags=Notify 然后我们在函数
中做了这样的事情 ReadINIStr [=10=] "$PLUGINSDIR\test.ini" "Settings" "State"
StrCmp [=10=] 0 validate ; Next button?
StrCmp [=10=] 2 supportx ; "Install support for X"?
StrCmp [=10=] 9 clearbtn ; "Clear" button?
StrCmp [=10=] 11 droplist ; "Show|Hide" drop-list?
Abort ; Return to the page
但在 InstallOptionsEx 中,他们说他们取消了它以支持新方法。
这来自 InstallOptionsEx 自述文件:
Step 5: Validate the Output
If you want to validate the input on the page, for example, you want to check whether the user has filled in a textbox, use the leave function of the Page command and Abort when the validation has failed:
Function ValidateCustom
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
StrCmp [=11=] "" 0 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please enter your name."
Abort
FunctionEnd
Step 6: Return Value
After you have called the DLL, InstallOptionsEx adds one string to the stack, with one of the following values:
success - The user has pressed the Next button
back - The user has pressed the Back button
cancel - The user has pressed the Cancel button
error - An error has occurred, the dialog cannot be displayed.
Usually, you don't need to check this value, but you still have to remove it from the stack (have a look at the example above).
You only have to check this value if you need something really special, such as doing something when the user pressed the Back button.
谁能帮我想出新方法?如果您查看下面的代码文件,就会有一个新旧部分,在新部分中您会看到我正在尝试做什么。需要有关代码的帮助。
这是一个ini文件和代码文件:
ini 文件
[Settings]
NumFields=5
[Field 1]
Type=Label
Left=160
Right=235
Top=9
Bottom=18
Text="DropDown 1"
txtAlign=Center
[Field 2]
Type=DROPLIST
ListItems=Option 1a|Option 1b|Option 1c
State=
Flags=
Left=160
Right=235
Top=18
Bottom=25
[Field 3]
Type=Label
Left=240
Right=295
Top=9
Bottom=18
Text="DropDown 2"
txtAlign=Center
[Field 4]
Type=DROPLIST
ListItems=Option 2a|Option 2b|Option 2c
State=
Flags=
Left=240
Right=295
Top=18
Bottom=28
[Field 5]
Type=Button
Flags=NOTIFY
State=
Text="More Info"
Left=200
Right=250
Top=125
Bottom=140
txtAlign=Center
代码文件
!include WinVer.nsh
!include LogicLib.nsh
!include x64.nsh
!include FileFunc.nsh
!include MUI2.nsh
!include WinMessages.nsh
!include InstallOptions.nsh
!include Sections.nsh
!include nsDialogs.nsh
!define MUI_HEADERIMAGE
!define TEMP1 $R0 ;Temp variable
Page custom ShowCustom LeaveCustom ;Custom page. InstallOptions gets called in SetCustom.
!insertmacro MUI_LANGUAGE "English"
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\pagesetup.ini "pagesetup.ini"
FunctionEnd
Function ShowCustom
InstallOptionsEx::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=13=]
InstallOptionsEx::show
Pop [=13=]
FunctionEnd
#Old Method
/*
Function LeaveCustom
ReadINIStr [=13=] "$PLUGINSDIR\pagesetup.ini" "Settings" "State"
StrCmp [=13=] 0 validate ; Next button?
StrCmp [=13=] 5 Infobtn ;
Abort ; Return to the page
Infobtn
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Infobtn Pressed"
Abort ; Return to the page
validate:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Next Pressed"
#Some Code to check if Field 2 and Field 4 have something selected
Abort
FunctionEnd
*/
#New Method
Function LeaveCustom
#Not sure correct code
#If Back Btn Pressed goto backbtn
#If Cancel Btn Pressed goto cancelbtn
#If Next Btn Pressed goto nextbtn
#If Info btn Press goto infobtn
backbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Backbtn Pressed"
Abort
cancelbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Cancelbtn Pressed"
Abort
nextbtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Nextbtn Pressed"
Abort
infobtn:
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "Infobtn Pressed"
Abort
FunctionEnd
Section
SectionEnd
好吧,我终于弄明白了,虽然我会 post 以防其他人需要。
我有这个:
Function ShowCustom
InstallOptionsEx::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=10=]
InstallOptionsEx::show
Pop [=10=]
FunctionEnd
它应该是这样的:(Ex 不应该在那里)
Function ShowCustom
InstallOptions::initDialog "$PLUGINSDIR\pagesetup.ini"
Pop [=11=]
InstallOptions::show
Pop [=11=]
FunctionEnd
那就用电流检查一下
ReadINIStr [=12=] "$PLUGINSDIR\test.ini" "Settings" "State"
StrCmp [=12=] 0 validate ; Next button?
StrCmp [=12=] 2 supportx ; "Install support for X"?
StrCmp [=12=] 9 clearbtn ; "Clear" button?
StrCmp [=12=] 11 droplist ; "Show|Hide" drop-list?
Abort ; Return to the page