2017-10-28 6 views
0

InstallOptionsEx検証に関するヘルプが必要です。 InstallOptionsでは、通知=フラグを使用して、我々は、関数でNSIS InstallOptionsEx Validate

ReadINIStr $0 "$PLUGINSDIR\test.ini" "Settings" "State" 
    StrCmp $0 0 validate ; Next button? 
    StrCmp $0 2 supportx ; "Install support for X"? 
    StrCmp $0 9 clearbtn ; "Clear" button? 
    StrCmp $0 11 droplist ; "Show|Hide" drop-list? 
    Abort ; Return to the page 

をこのようなsomehtingをした。しかしInstallOptionsExに彼らは新しい方法の賛成で、それを離れていたと言います。

これはInstallOptionsEx Readmeファイルから次のとおりです。

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 $0 "" 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ファイル

[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 $0 
    InstallOptionsEx::show 
    Pop $0 
FunctionEnd 


#Old Method 
/* 
Function LeaveCustom 
    ReadINIStr $0 "$PLUGINSDIR\pagesetup.ini" "Settings" "State" 
    StrCmp $0 0 validate ; Next button? 
    StrCmp $0 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 

答えて

0

まあ、私はついにそれを考え出したと私は包み投稿するでしょうが他の人が必要とする:ここでは

はiniファイルとコードファイルです。

私はこれでした:

Function ShowCustom 
    InstallOptionsEx::initDialog "$PLUGINSDIR\pagesetup.ini" 
    Pop $0 
    InstallOptionsEx::show 
    Pop $0 
FunctionEnd 

をそして、それは、このされている必要があります:(例がありましたべきではありません)

Function ShowCustom 
    InstallOptions::initDialog "$PLUGINSDIR\pagesetup.ini" 
    Pop $0 
    InstallOptions::show 
    Pop $0 
FunctionEnd 

それからちょうど

ReadINIStr $0 "$PLUGINSDIR\test.ini" "Settings" "State" 
    StrCmp $0 0 validate ; Next button? 
    StrCmp $0 2 supportx ; "Install support for X"? 
    StrCmp $0 9 clearbtn ; "Clear" button? 
    StrCmp $0 11 droplist ; "Show|Hide" drop-list? 
    Abort ; Return to the page 
をチェックするための電流を使用