2013-12-20 90 views
0

我正在關注NSIS nsDialog tutorial,目的是收集一些用戶輸入,我將稍後使用它來寫入配置文件。 NSISEclipse插件生成了一個MUI2模板,它使我啓動併成功安裝了這些文件。NSIS nsDialog禁用了後退/下一步/取消按鈕?

我已經使用了nsDialog教程產生,我想它,它得到準確發出一個對話框,但由於某些原因,「後退/下/取消」按鈕都是灰色的。我沒有看到它在啓用/禁用這些按鈕的nsDialog文檔中的位置。

這裏是我的代碼:

Var Dialog 
Var Label 
Var MyTextBox 
Section configLocationDialog 
    nsDialogs::Create 1018 
    Pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!" 
    Pop $Label 

    ${NSD_CreateText} 10% 20u 80% 12u "Hello World" 
    Pop $MyTextbox 

    nsDialogs::Show 
SectionEnd 

而且,一旦顯示的對話框:

dialog with disabled buttons

我需要做什麼改變來告訴NSIS允許BACK/NEXT /取消?

編輯更多的代碼被要求提供。這是現在存在的整個事情。

# Auto-generated by EclipseNSIS Script Wizard 
# Dec 19, 2013 3:48:34 PM 
Name SecureKeypad 

# General Symbol Definitions 
!define REGKEY "SOFTWARE\$(^Name)" 
!define VERSION 1.0.0 
!define COMPANY **COMPANY** 
!define URL http://www.**COMPANY**.com 

# MultiUser Symbol Definitions 
!define MULTIUSER_EXECUTIONLEVEL Standard 
!define MULTIUSER_INSTALLMODE_COMMANDLINE 
!define MULTIUSER_INSTALLMODE_INSTDIR $PROGRAMFILES\SecureKeypad 
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}" 
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path" 

# MUI Symbol Definitions 
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico" 
!define MUI_FINISHPAGE_NOAUTOCLOSE 
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM 
!define MUI_STARTMENUPAGE_NODISABLE 
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY} 
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup 
!define MUI_STARTMENUPAGE_DEFAULTFOLDER SecureKeypad 
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-colorful.ico" 
!define MUI_UNFINISHPAGE_NOAUTOCLOSE 

# Included files 
#!include MultiUser.nsh 
!include LogicLib.nsh 
!include nsDialogs.nsh 
!include AdvReplaceInFile.nsh 
!include Sections.nsh 
!include MUI2.nsh 

# Variables 
Var StartMenuGroup 

# Installer pages 
!insertmacro MUI_PAGE_WELCOME 
!insertmacro MUI_PAGE_DIRECTORY 
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup 
!insertmacro MUI_PAGE_INSTFILES 
!insertmacro MUI_PAGE_FINISH 
!insertmacro MUI_UNPAGE_CONFIRM 
!insertmacro MUI_UNPAGE_INSTFILES 

# Installer languages 
!insertmacro MUI_LANGUAGE English 

# Installer attributes 
OutFile setup.exe 
CRCCheck on 
InstallDir $PROGRAMFILES\${COMPANY}\SecureKeypad 
XPStyle on 
ShowInstDetails show 
VIProductVersion 1.0.0.0 
VIAddVersionKey ProductName SecureKeypad 
VIAddVersionKey ProductVersion "${VERSION}" 
VIAddVersionKey CompanyName "${COMPANY}" 
VIAddVersionKey CompanyWebsite "${URL}" 
VIAddVersionKey FileVersion "${VERSION}" 
VIAddVersionKey FileDescription "" 
VIAddVersionKey LegalCopyright "" 
InstallDirRegKey HKLM "${REGKEY}" Path 
ShowUninstDetails show 

# Input dialogs 
Var Dialog 
Var Label 
Var MyTextbox 
#Page custom configLocationDialog configLocationDialogLeave 
#Page custom doConfiguration 
Section configLocationDialog 
    nsDialogs::Create 1018 
    Pop $Dialog 
    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    GetFunctionAddress $0 "configLocationDialogLeave" 
    nsDialogs::OnBack $Dialog $0 
    #nsDialogs::OnNext $Dialog 

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!" 
    Pop $Label 

    ${NSD_CreateText} 10% 20u 80% 12u "Hello World" 
    Pop $MyTextbox 

    nsDialogs::Show 
SectionEnd 

Function configLocationDialogLeave 
    ${NSD_GetText} $MyTextbox $0 
    MessageBox mb_ok $0 
FunctionEnd 

# Installer sections 
Section -Main SEC0000 
    SetOutPath $INSTDIR 
    SetOverwrite on 
    File installable-content\CYBSSecurity.dll 
    File installable-content\SecureKeypad.exe 
    File installable-content\SecureKeypad.exe.config 
    File installable-content\SecureKeypad.config 
    File installable-content\SecureKeypad.frmSecureKeypad.resources 
    WriteRegStr HKLM "${REGKEY}\Components" Main 1 

    !insertmacro AdvReplaceInFile $INSTDIR\SecureKeypad.exe.config "@@[email protected]@" $INSTDIR 
SectionEnd 

Section -post SEC0001 
    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR 
    SetOutPath $INSTDIR 
    WriteUninstaller $INSTDIR\uninstall.exe 
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 
    SetOutPath $SMPROGRAMS\$StartMenuGroup 
    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe 
    !insertmacro MUI_STARTMENU_WRITE_END 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}" 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}" 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}" 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe 
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe 
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 
SectionEnd 

# Macro for selecting uninstaller sections 
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID 
    Push $R0 
    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}" 
    StrCmp $R0 1 0 next${UNSECTION_ID} 
    !insertmacro SelectSection "${UNSECTION_ID}" 
    GoTo done${UNSECTION_ID} 
next${UNSECTION_ID}: 
    !insertmacro UnselectSection "${UNSECTION_ID}" 
done${UNSECTION_ID}: 
    Pop $R0 
!macroend 

# Uninstaller sections 
Section /o -un.Main UNSEC0000 
    Delete /REBOOTOK $INSTDIR\SecureKeypad.frmSecureKeypad.resources 
    Delete /REBOOTOK $INSTDIR\SecureKeypad.exe.config 
    Delete /REBOOTOK $INSTDIR\SecureKeypad.exe 
    Delete /REBOOTOK $INSTDIR\<sensored>.dll 
    DeleteRegValue HKLM "${REGKEY}\Components" Main 
SectionEnd 

Section -un.post UNSEC0001 
    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" 
    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" 
    Delete /REBOOTOK $INSTDIR\uninstall.exe 
    DeleteRegValue HKLM "${REGKEY}" StartMenuGroup 
    DeleteRegValue HKLM "${REGKEY}" Path 
    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components" 
    DeleteRegKey /IfEmpty HKLM "${REGKEY}" 
    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup 
    RmDir /REBOOTOK $INSTDIR 
SectionEnd 

# Installer functions 
Function .onInit 
    InitPluginsDir 
FunctionEnd 

# Uninstaller functions 
Function un.onInit 
    !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup 
    !insertmacro SELECT_UNSECTION Main ${UNSEC0000} 
FunctionEnd 
+0

請出示您更多的代碼。例如,你是否宣佈了一個自定義頁面? –

+0

我試過了自定義頁面,但是得到了相同的結果。這是代替使用「Section」的第二次迭代。自定義頁面在安裝文件後運行,這不是我所希望的。 – PaulProgrammer

回答

0

在段中調用nsDialogs :: Create/Show永遠不會有效,它們只能在自定義頁面的create callback函數中調用。

某些按鈕會在instfiles頁面(已經安裝,無法取消或返回)之後被禁用,但是這是由NSIS本身,而不是nsDialogs做...

+0

我在一個自定義頁面中嘗試了這一點(請參閱完整列表中已註釋掉的「頁面定製」,僅用函數/函數EndE替換),但該對話框在安裝屏幕後運行,這不是我想要的,後退按鈕會使安裝程序崩潰。 – PaulProgrammer

0

的NSISEclipse插件生成了大量的代碼,其中包括一組執行各種頁面顯示的宏:

# Installer pages 
!insertmacro MUI_PAGE_WELCOME 
!insertmacro MUI_PAGE_DIRECTORY 
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup 
!insertmacro MUI_PAGE_INSTFILES 
!insertmacro MUI_PAGE_FINISH 
!insertmacro MUI_UNPAGE_CONFIRM 
!insertmacro MUI_UNPAGE_INSTFILES 

訣竅是在正確的步驟插入頁面調用。

# Installer pages 
!insertmacro MUI_PAGE_WELCOME 
!insertmacro MUI_PAGE_DIRECTORY 
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup 
Page custom configLocationDialog configLocationDialogLeave 
!insertmacro MUI_PAGE_INSTFILES 
!insertmacro MUI_PAGE_FINISH 
!insertmacro MUI_UNPAGE_CONFIRM 
!insertmacro MUI_UNPAGE_INSTFILES 
0

如果你把你要nsDialogs:Create通話的部分將運行在安裝程序安裝文件和這樣的。在這種狀態下,您將無法繼續瀏覽安裝程序中的頁面,並且卡住了。

你有關在安裝後,你的自定義頁面運行的通知確實是什麼,你應該嘗試修復,而不是貶爲錯誤的方式(這是唯一的方法)。 NSIS腳本在很多方面都很簡單。例如,頁面按照它們聲明的順序加載。所以當你聲明你想要MUI_PAGE_WELCOME,MUI_PAGE_DIRECTORY和其他你也設置它們的順序。

# Installer pages 
!insertmacro MUI_PAGE_WELCOME         # First page 
!insertmacro MUI_PAGE_DIRECTORY        # Second page 
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup # Third page 
!insertmacro MUI_PAGE_INSTFILES        # Etc 
!insertmacro MUI_PAGE_FINISH 
!insertmacro MUI_UNPAGE_CONFIRM 
!insertmacro MUI_UNPAGE_INSTFILES 

所以,如果你再儘量保持所有的代碼一起,並添加自定義頁面旁邊是處理它的功能,它無疑是在爲了最後一頁。

# Installer pages 
!insertmacro MUI_PAGE_WELCOME         # First page 
!insertmacro MUI_PAGE_DIRECTORY        # Second page 
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup # Third page 

... 

# Input dialogs 
Var Dialog 
Var Label 
Var MyTextbox 
Page custom configLocationDialog configLocationDialogLeave # Last page 
Section configLocationDialog 
    nsDialogs::Create 1018 
    Pop $Dialog 

所以爲了說明這一點,我把你的代碼和釀造到基本上你想要的網頁。

# Included files 
!include LogicLib.nsh 
!include nsDialogs.nsh 
!include Sections.nsh 
!include MUI2.nsh 

# Installer pages 
!insertmacro MUI_PAGE_WELCOME         # First page 
Page custom configLocationDialog configLocationDialogLeave # Second page! 
!insertmacro MUI_PAGE_FINISH         # Last page 

# Installer languages 
!insertmacro MUI_LANGUAGE English 

# Input dialogs 
Var Dialog 
Var Label 
Var MyTextbox 

Function configLocationDialog 
    nsDialogs::Create 1018 
    Pop $Dialog 
    ${If} $Dialog == error 
    Abort 
    ${EndIf} 

    GetFunctionAddress $0 "configLocationDialogLeave" 
    nsDialogs::OnBack $Dialog $0 

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!" 
    Pop $Label 

    ${NSD_CreateText} 10% 20u 80% 12u "Hello World" 
    Pop $MyTextbox 

    nsDialogs::Show 
FunctionEnd 

Function configLocationDialogLeave 
    ${NSD_GetText} $MyTextbox $0 
    MessageBox mb_ok $0 
FunctionEnd 

Section -Main SEC0000 

SectionEnd