2013-06-03 46 views
0

(我很抱歉,我不能拿出一個更好的標題)插入自定義頁面2之間

我有以下的部分代碼:

!insertmacro MUI_PAGE_COMPONENTS 
!insertmacro MUI_PAGE_INSTFILES 
Page Custom nsDialogsPage nsDialogsPageLeave 

section Section1 
#do something 
sectionEnd 

section Section2 
#do something else 
sectionEnd 

Function nsDialogsPage 
#do something 
FunctionEnd 

Function nsDialogsPageLeave 
#do something else 
FunctionEnd 

但是,現在我想自定義頁面顯示在Section1之後和Section2之前(我在第二部分中使用的自定義頁面中輸入一些信息)。我應該怎麼做呢? (我總是可以在MUI_PAGE_INSTFILES之前放置自定義頁面,但對於用戶來說這看起來很奇怪。)

+0

安裝程序在開始對系統進行更改的實際安裝步驟之前收集儘可能多的信息很常見,爲什麼您認爲將安裝進度分解爲這樣是一個好主意? – Anders

回答

2

所有部分都在instfiles頁面上執行,但可能有多個instfiles頁面。爲了防止所有部分執行兩次,您需要使用sections.nsh中的幫助宏打開/關閉正確的部分,或將某些狀態存儲在全局變量中,並將所有部分代碼放入if塊中,例如:${If} $installstep = 0。您可能還需要使用SetAutoClose ...

+0

謝謝,我試過全局變量的想法,它的工作!但是代碼看起來非常混亂:) –

0

我用PRE功能選擇/取消選擇部分:

!insertmacro MUI_PAGE_COMPONENTS 

    !define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection 
    !insertmacro MUI_PAGE_INSTFILES 
    Page Custom nsDialogsPage nsDialogsPageLeave 
    !define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection 
    !insertmacro MUI_PAGE_INSTFILES 

    Var SkipSection 

    section Section1 
    #do something 
    StrCpy $SkipSection 1 
    sectionEnd 

    section Section2 
    #do something else 
    sectionEnd 

    Function nsDialogsPage 
    #do something 
    FunctionEnd 

    Function nsDialogsPageLeave 
    #do something else 
    FunctionEnd 

Function checkSkipSection 

    ${If} $SkipSection = "" 
     SectionSetFlags ${Section1} ${SF_SELECTED} 
     SectionSetFlags ${Section2} 0 

    ${ElseIf} $SkipSection = 1 
     SectionSetFlags ${Section2} ${SF_SELECTED} 
     SectionSetFlags ${Section1} 0 

    ${EndIf} 

FunctionEnd 

所以在第一MUI_PAGE_INSTFILES,只有SECTION1運行,而第2節在第2輪MUI_PAGE_INSTFILES頁面。

+0

或者如果您不想使用SkipSection變量,請爲自定義頁面使用兩個單獨的函數checkSkipSection1和2,並在每個函數中相應地設置標誌。 –