2011-10-06 62 views
1

我有一個包含文本框的自定義對話框頁面。當用戶點擊「下一步」按鈕時,我想確保在允許安裝繼續之前文本框中有文本。在繼續之前驗證文本框輸入

這怎麼辦?我嘗試在nsDialogsPageLeave中添加一個檢查,如果驗證失敗,我會調用nsDialogsPage,但這不起作用...頁面底部的按鈕在重新加載後無效。

Var Dialog 
Var Text 
Var Text_State 

Page custom nsDialogsPage nsDialogsPageLeave 



Function nsDialogsPage 

nsDialogs::Create 1018 
Pop $Dialog 

${If} $Dialog == error 
    Abort 
${EndIf} 

${NSD_CreateText} 0 0 50% 12u $Text_State 
Pop $Text 

nsDialogs::Show 

FunctionEnd 



Function nsDialogsPageLeave 

${NSD_GetText} $Text $Text_State 

FunctionEnd 

回答

3

我已經處理這種情況的方法是,以驗證在離開功能的文本,以便您的代碼就變成了:

Function nsDialogsPage 

    nsDialogs::Create 1018 
    Pop $Dialog 

    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    ${NSD_CreateText} 0 0 50% 12u $Text_State 
    Pop $Text 

    nsDialogs::Show 

FunctionEnd 

Function nsDialogsPageLeave 

    ${NSD_GetText} $Text $Text_State 

    ${If} $Text_State == "" 
     MessageBox MB_OK "Please enter some text" 
     Abort 
    ${EndIf} 

FunctionEnd 

通過這種方式,用戶可以單擊下一步按鈕,但他們會如果沒有輸入文本,則會收到錯誤消息,中止將停止安裝程序移至下一頁。