NSIS安装程序按钮外观在自定义页面中不起作用

问题描述

我正在为安装程序创建一个自定义页面,该页面隐藏了认按钮(返回,下一步和取消),并且仅显示一个自定义按钮(安装)。 问题是,我无法使用skinned controls plugin设置自定义按钮的背景颜色。 如果显示认按钮,则会看到通过位图应用于其的背景色。 这意味着外观将应用于认按钮,而不应用于自定义按钮。 关于我会缺少的任何指针吗?@H_404_1@

代码如下:@H_404_1@

!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 $0
    SetCtlColors $0 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 $0 "Arial" 24
  SendMessage $title ${WM_SETFONT} $0 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 $0 "Arial" 14
  SendMessage $description ${WM_SETFONT} $0 1

  ${NSD_CreateButton} 25 250 90% 15u INSTALL
  pop $button
  ;SetCtlColors $button 0x000000 0x0FFFFF
  ${NSD_AddStyle} $button ${SS_CENTER}

  GetDlgitem $0 $HWNDPARENT 3 ; Back Button
  GetDlgitem $1 $HWNDPARENT 1 ; Next/Close Button
  GetDlgitem $2 $HWNDPARENT 2 ; Cancel Button
  
  ;ShowWindow $0 ${SW_HIDE}
  ;ShowWindow $1 ${SW_HIDE}
  ;ShowWindow $2 ${SW_HIDE}


  GetDlgitem $0 $HWNDPARENT 1035
  ShowWindow $0 ${SW_HIDE}
  GetDlgitem $0 $HWNDPARENT 1036
  ShowWindow $0 ${SW_HIDE}
  GetDlgitem $0 $HWNDPARENT 1045
  ShowWindow $0 ${SW_HIDE}
  GetDlgitem $0 $HWNDPARENT 1028
  ShowWindow $0 ${SW_HIDE}
  GetDlgitem $0 $HWNDPARENT 1256
  ShowWindow $0 ${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

这是当前的用户界面(清楚地显示了带有皮肤的认按钮):

enter image description here

@H_404_1@

解决方法

这是您使用的Skinned Control插件中的错误,您需要对其进行修复。

某些较旧的版本可能已解决了此问题,但是由于未知原因,您的脚本不适用于较旧的版本,我也不记得详细的信息/版本。

我是该插件的Wiki页面中提到的 Graphical Installer http://www.graphical-installer.com/)的开发人员,我前段时间致力于SkinnedControls插件并解决了一些问题。但这差不多是10年前了。

据我所知,该插件存在一些问题,因为 我们想在图形化安装程序中使用它(该工具可以使整个安装程序皮肤化)。 但是,我们无法解决所有问题,所以我们结束了在按钮正常工作的情况下编写自定义插件的工作: Button working in GI

如果有时间,我将看一下该插件,同时您可以打开项目(我想是Visual Studio 2008 C ++项目)并进行调试。该插件应枚举所有控件,检测所有按钮(这可能是一个问题)并对它们进行外观修饰。