我正在使用Nsis來安裝我的項目。我需要改變richEdit背景顏色。我嘗試SetCtlColors方法,但它沒有做任何改變。這裏是我的代碼:NSIS:如何更改RichEdit背景顏色
; handle variables
Var hCtl_FirstDialog
Var hCtl_FirstDialog_RichText1
Var hCtl_FirstDialog_Button1
; dialog create function
Function fnc_FirstDialog_Create
; === FirstDialog (type: Dialog) ===
nsDialogs::Create 1018
Pop $hCtl_FirstDialog
${If} $hCtl_FirstDialog == error
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Dialog title..." "Dialog subtitle..."
; === RichText1 (type: RichText) ===
nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 12.51u 14.77u 261.32u 92.92u ""
Pop $hCtl_FirstDialog_RichText1
; RichText1 ControlCustomScript
nsRichEdit::Load $hCtl_FirstDialog_RichText1 D:\temp\NsisProject\EULA.rtf
SetCtlColors $hCtl_FirstDialog_RichText1 ccff00 ccff00
; === Button1 (type: Button) ===
${NSD_CreateButton} 225.11u 118.77u 49.37u 14.15u "Button1"
Pop $hCtl_FirstDialog_Button1
${NSD_OnClick} $hCtl_FirstDialog_Button1 FillText
FunctionEnd
; dialog show function
Function fnc_FirstDialog_Show
Call fnc_FirstDialog_Create
nsDialogs::Show
FunctionEnd
我不知道如果Windows接受十六進制顏色這種格式。嘗試'SetCtlColors $ hCtl_FirstDialog_RichText1 0xccff00 0xccff00' – idleberg
@idleberg所以我也試過。同樣的行爲 – user2455111