2013-10-30 100 views
0

我在定製NSIS卸載程序頁面上做了一些research,並且在Welcome和Finish頁面取得了一些成功。自定義NSIS卸載程序確認頁面

但是,我在使用確認頁面的歡迎頁面上使用相同的模板時遇到了問題。如果我的add any control using nsDialogs值爲非零值height,則確認頁面上的所有現有控件(除標題和按鈕外)都將消失。

這裏是我的代碼(它成功地更新按鈕的名稱,但會刪除該網頁上的所有其他控件)

!include MUI2.nsh 

OutFile "CustomUninstaller.exe" 
InstallDir "C:\Program Files (x86)\NSIS\Examples\CustomFinish" 

!define APPNAME "Testing" 
Name "${APPNAME}" 

!insertmacro MUI_PAGE_INSTFILES 

!insertmacro MUI_UNPAGE_WELCOME 

!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnConfirm ; My custom function for the Confirm page 
!insertmacro MUI_UNPAGE_CONFIRM 

!insertmacro MUI_UNPAGE_INSTFILES 
!insertmacro MUI_UNPAGE_FINISH 
!insertmacro MUI_LANGUAGE "English" 

Function un.ModifyUnConfirm 
    # Change "Uninstall" button to say "Continue" on uninstaller confirmation page 
    GetDlgItem $0 $HWNDPARENT 1 
    SendMessage $0 ${WM_SETTEXT} 0 "STR:Continue" 

    # Add new label. If these three lines are commented out, I see the regular controls of this page show up. 
    # The position, color and background of the label don't seem to matter 
    ${NSD_CreateLabel} 50% 50% 100% 10u "Testing!!!" 
    Pop $0 
    SetCtlColors $0 "" ${MUI_BGCOLOR} 
FunctionEnd 

Section TestUninstaller 
    WriteUninstaller "$INSTDIR\unCustomUninstaller.exe" 
    ExecWait "$INSTDIR\unCustomUninstaller.exe" 
Sectionend 

問題:

  1. 有誰知道爲什麼控件會消失?
  2. 如何成功地將控件添加到此頁面需要做什麼?

回答

2

MUI_UNPAGE_CONFIRM不是nsDialogs頁面!

要更改此對話框,您可以使用ChangeUI命令。 您也可以在運行時添加控件,但只有通過系統插件:

Function un.ModifyUnConfirm 
    FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog 
    System::Call 'USER32::CreateWindowEx(i${__NSD_Label_EXSTYLE},t"${__NSD_Label_CLASS}",t "Testing!!!",i${__NSD_Label_STYLE},i 50,i 100,i 400, i 25,i$1,i0,i0,i0)i.s' 
    Pop $0 
    SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1 
    SendMessage $0 ${WM_SETFONT} $1 1 
    SetCtlColors $0 "" ${MUI_BGCOLOR} ; This is the wrong color to use... 
FunctionEnd 
+0

我看到 - 我不知道該頁面不被認爲是nsDialgos頁。很高興知道。再次感謝安德斯。 – diaho