NSIS 安装程序按钮皮肤在自定义页面中不起作用
NSIS Installer button skinning not working in custom page
我正在为我的安装程序创建一个自定义页面,我隐藏了默认按钮(返回、下一步和取消)并且只显示了一个自定义按钮(安装)。
问题是,我无法使用 skinned controls plugin 设置自定义按钮的背景颜色。
如果我显示默认按钮,我会看到通过位图应用到它们的背景颜色。
这意味着皮肤将应用于默认按钮,但不会应用于自定义按钮。
关于我会遗漏什么的任何指示?
代码如下:
!include "logiclib.nsh"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!include "InstallOptions.nsh"
;--------------------------------
;General
;Name and file
Name "Custom App"
OutFile "custom_installer.exe"
;Default installation folder
InstallDir "$LOCALAPPDATA\Custom Test"
RequestExecutionLevel user
;Remove default branding text of Nullsoft
;BrandingText " "
var title
var description
var button
Var ImageCtrl
Var BmpHandle
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
!define Black "814EFA"
!define LightRed "FFFFFF"
!define MUI_CUSTOMFUNCTION_GUIINIT myGUIInit
XPStyle off
;--------------------------------
;Functions
Function .onInit
InitPluginsDir
; Extract bitmaps for buttons
File "/oname=$PLUGINSDIR\button.bmp" "${NSISDIR}\Contrib\SkinnedControls\skins\button_background.bmp"
FunctionEnd
Function myGUIInit
DetailPrint "myGUIInit"
; start the plugin
; the /disabledtextcolor, /selectedtextcolor and /textcolor parameters are optionnal
SkinnedControls::skinit /NOUNLOAD \
/disabledtextcolor=808080 \
/selectedtextcolor=000080 \
/textcolor=000000 \
"/button=$PLUGINSDIR\button.bmp"
FunctionEnd
Function Start
nsDialogs::Create 1044
Pop [=10=]
SetCtlColors [=10=] 222425 FBFBFB
SetCtlColors $HWNDPARENT 222425 FBFBFB
${NSD_CreateLabel} 0 150 100% 24u "Welcome to Custom App"
pop $title
SetCtlColors $title 0x000000 0xFBFBFB
${NSD_AddStyle} $title ${SS_CENTER}
CreateFont [=10=] "Arial" 24
SendMessage $title ${WM_SETFONT} [=10=] 1
${NSD_CreateLabel} 0 190 100% 28u "By clicking install you agree to the terms of the End $\r$\n User License Agreement"
pop $description
SetCtlColors $description 0x000000 0xFBFBFB
${NSD_AddStyle} $description ${SS_CENTER}
CreateFont [=10=] "Arial" 14
SendMessage $description ${WM_SETFONT} [=10=] 1
${NSD_CreateButton} 25 250 90% 15u INSTALL
pop $button
;SetCtlColors $button 0x000000 0x0FFFFF
${NSD_AddStyle} $button ${SS_CENTER}
GetDlgItem [=10=] $HWNDPARENT 3 ; Back Button
GetDlgItem $HWNDPARENT 1 ; Next/Close Button
GetDlgItem $HWNDPARENT 2 ; Cancel Button
;ShowWindow [=10=] ${SW_HIDE}
;ShowWindow ${SW_HIDE}
;ShowWindow ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1035
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1036
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1045
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1028
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1256
ShowWindow [=10=] ${SW_HIDE}
nsDialogs::Show
${NSD_FreeBitmap} $BmpHandle
FunctionEnd
;--------------------------------
;Pages
Page custom Start
!insertmacro MUI_PAGE_COMPONENTS
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
SetOutPath "$INSTDIR"
SectionEnd
这里是当前的 UI(清楚地显示了默认按钮皮肤):
这是Skinned Control的一个bug plug-in你用的,需要修复它
有可能一些旧版本修复了这个问题,但由于未知原因,您的脚本对我来说不适用于旧版本,我不记得 details/versions 确切。
我是 Graphical Installer (http://www.graphical-installer.com/) 的开发者,在 plug-in 的 Wiki 页面中提到过,前段时间我在开发 SkinnedControls 插件并修复了一些问题。但那是将近 10 年前的事了。
As far as I remember there were some issues with this plug-in because
we wanted to use it in Graphical Installer (tool that allows to skin the whole installer).
However we could not solve all issues so we ended writing custom plugin where the buttons are working fine:
有时间我会看看这个plug-in,同时你可以打开项目(我想是Visual Studio 2008 C++项目)并调试它。该插件应枚举所有控件,检测所有按钮(这可能是一个问题)并为它们设置皮肤。
我正在为我的安装程序创建一个自定义页面,我隐藏了默认按钮(返回、下一步和取消)并且只显示了一个自定义按钮(安装)。 问题是,我无法使用 skinned controls plugin 设置自定义按钮的背景颜色。 如果我显示默认按钮,我会看到通过位图应用到它们的背景颜色。 这意味着皮肤将应用于默认按钮,但不会应用于自定义按钮。 关于我会遗漏什么的任何指示?
代码如下:
!include "logiclib.nsh"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!include "InstallOptions.nsh"
;--------------------------------
;General
;Name and file
Name "Custom App"
OutFile "custom_installer.exe"
;Default installation folder
InstallDir "$LOCALAPPDATA\Custom Test"
RequestExecutionLevel user
;Remove default branding text of Nullsoft
;BrandingText " "
var title
var description
var button
Var ImageCtrl
Var BmpHandle
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
!define Black "814EFA"
!define LightRed "FFFFFF"
!define MUI_CUSTOMFUNCTION_GUIINIT myGUIInit
XPStyle off
;--------------------------------
;Functions
Function .onInit
InitPluginsDir
; Extract bitmaps for buttons
File "/oname=$PLUGINSDIR\button.bmp" "${NSISDIR}\Contrib\SkinnedControls\skins\button_background.bmp"
FunctionEnd
Function myGUIInit
DetailPrint "myGUIInit"
; start the plugin
; the /disabledtextcolor, /selectedtextcolor and /textcolor parameters are optionnal
SkinnedControls::skinit /NOUNLOAD \
/disabledtextcolor=808080 \
/selectedtextcolor=000080 \
/textcolor=000000 \
"/button=$PLUGINSDIR\button.bmp"
FunctionEnd
Function Start
nsDialogs::Create 1044
Pop [=10=]
SetCtlColors [=10=] 222425 FBFBFB
SetCtlColors $HWNDPARENT 222425 FBFBFB
${NSD_CreateLabel} 0 150 100% 24u "Welcome to Custom App"
pop $title
SetCtlColors $title 0x000000 0xFBFBFB
${NSD_AddStyle} $title ${SS_CENTER}
CreateFont [=10=] "Arial" 24
SendMessage $title ${WM_SETFONT} [=10=] 1
${NSD_CreateLabel} 0 190 100% 28u "By clicking install you agree to the terms of the End $\r$\n User License Agreement"
pop $description
SetCtlColors $description 0x000000 0xFBFBFB
${NSD_AddStyle} $description ${SS_CENTER}
CreateFont [=10=] "Arial" 14
SendMessage $description ${WM_SETFONT} [=10=] 1
${NSD_CreateButton} 25 250 90% 15u INSTALL
pop $button
;SetCtlColors $button 0x000000 0x0FFFFF
${NSD_AddStyle} $button ${SS_CENTER}
GetDlgItem [=10=] $HWNDPARENT 3 ; Back Button
GetDlgItem $HWNDPARENT 1 ; Next/Close Button
GetDlgItem $HWNDPARENT 2 ; Cancel Button
;ShowWindow [=10=] ${SW_HIDE}
;ShowWindow ${SW_HIDE}
;ShowWindow ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1035
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1036
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1045
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1028
ShowWindow [=10=] ${SW_HIDE}
GetDlgItem [=10=] $HWNDPARENT 1256
ShowWindow [=10=] ${SW_HIDE}
nsDialogs::Show
${NSD_FreeBitmap} $BmpHandle
FunctionEnd
;--------------------------------
;Pages
Page custom Start
!insertmacro MUI_PAGE_COMPONENTS
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
SetOutPath "$INSTDIR"
SectionEnd
这里是当前的 UI(清楚地显示了默认按钮皮肤):
这是Skinned Control的一个bug plug-in你用的,需要修复它
有可能一些旧版本修复了这个问题,但由于未知原因,您的脚本对我来说不适用于旧版本,我不记得 details/versions 确切。
我是 Graphical Installer (http://www.graphical-installer.com/) 的开发者,在 plug-in 的 Wiki 页面中提到过,前段时间我在开发 SkinnedControls 插件并修复了一些问题。但那是将近 10 年前的事了。
As far as I remember there were some issues with this plug-in because we wanted to use it in Graphical Installer (tool that allows to skin the whole installer). However we could not solve all issues so we ended writing custom plugin where the buttons are working fine:
有时间我会看看这个plug-in,同时你可以打开项目(我想是Visual Studio 2008 C++项目)并调试它。该插件应枚举所有控件,检测所有按钮(这可能是一个问题)并为它们设置皮肤。