简体   繁体   中英

NSIS Installer button skinning not working in custom page

I'm creating a custom page for my installer which I have the default buttons (back, next and cancel) hidden and only a custom button (install) is shown. Problem is that, I'm not able to set the background color of the custom button using skinned controls plugin . If I show the default buttons, I see the background color applied to them via the bitmap. This means the skinning is getting applied for the default buttons, but not on the custom button. Any pointers on what I would be missing ?

Here is the code:

!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

And here is the current UI (which clearly shows default buttons skinned): 在此处输入图片说明

This is a bug in Skinned Control plug-in you use, you need to fix it.

There is a chance some older version had this issue fixed, but your script is not working for me with older version for unknown reasons and I do not remember the details/versions exactly.

I am developer of Graphical Installer ( http://www.graphical-installer.com/ ) mentioned in the Wiki page of that plug-in and I worked on the SkinnedControls plugin some time ago and fixed some issues. But that was almost 10 years ago.

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: 在 GI 中工作的按钮

When I have time I will look at this plug-in, meanwhile you can open the project (it is Visual Studio 2008 C++ project I suppose) and debug it. The plugin should enumerate all controls, detect all Buttons (this is probably a problem) and skin them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM