有没有办法将安装程序的MUI_HEADER_TEXT部分设置为粗体字体?
我在${NSD_CreateLabel}上看到了字体的示例,但没有看到标题文本。
!插入带有MUI_HEADER_TEXT粗体的宏"Main“子文本
发布于 2019-11-04 17:59:09
我发现这是不可能的。
我确实找到了一种解决方案,可以轻松地将自定义字体添加到标签中,而无需猜测。
我使用了这个编辑器并在我的设置中粘贴了脚本。https://coolsoft.altervista.org
发布于 2019-11-04 20:10:39
Windows通常不支持单个控件中的不同字体。标题文本也是一个标签($mui.Header.SubText在MUIv2中)。
有些人在需要用粗体显示部件时使用两个标签,但这是一种让它们正确对齐的方法,不能对头文本执行,因为MUI需要隐藏/显示这些标签,当您从欢迎/完成样式页面切换到“正常”页面时。
唯一支持部分粗体文本的控件是RichEdit控件和带有一些黑客行为的这是可以做到的:
!define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
!include MUI2.nsh
Page Custom MyPageCreate
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
!include Util.nsh
Function MyGuiInit
!ifndef NSIS_CONFIG_LICENSEPAGE
System::Call 'KERNEL32::LoadLibrary(t "RichEd20")'
System::Call 'KERNEL32::LoadLibrary(t "RichEd32")'
!endif
StrCpy $0 $HWNDPARENT
ShowWindow $mui.Header.SubText 0
StrCpy $2 $mui.Header.SubText
System::Call 'USER32::GetWindowRect(p$2, @r1)'
${IntPtrOp} $3 $1 + 8
System::Call 'USER32::MapWindowPoints(p0,p$2,p$3,i1)'
System::Call '*$1(&i4i,&i4i,&i4i.r5,&i4i.r6)' ;w&h
System::Call 'USER32::MapWindowPoints(p0,p$0,p$1,i1)'
System::Call '*$1(&i4i.r3,&i4i.r4)' ;l&t
;Try both richedit classes
StrCpy $7 "RichEdit20A"
createRich:
System::Call 'USER32::CreateWindowEx(i ${WS_EX_TRANSPARENT},tr7,p0,\
i ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_READONLY}|${ES_MULTILINE}|${ES_WANTRETURN},\
i $3,i $4,i $5,i $6,p $0,p0,p0,p0)i.s'
pop $mui.Header.SubText
${If} $mui.Header.SubText = 0
${AndIf} $7 == "RichEdit20A"
StrCpy $7 "RichEdit"
goto createRich
${EndIf}
System::Call USER32::BringWindowToTop(p$mui.Header.SubText)
!define /IfNDef /Math EM_SETCHARFORMAT ${WM_USER} + 68
!define /IfNDef LF_FACESIZE 32
!define /IfNDef CFM_COLOR 0x40000000
; Forcing color does not work?
#System::Call '*$1(&l4,i${CFM_COLOR},i0,i,i,i0x${MUI_BGCOLOR},&i1,&i1,&i2,&m${LF_FACESIZE})'
#SendMessage $mui.Header.SubText ${EM_SETCHARFORMAT} 0 $1 $9
#SendMessage $mui.Header.SubText ${EM_SETBKGNDCOLOR} 0 0x${MUI_BGCOLOR}
SendMessage $2 ${WM_GETFONT} 0 0 $1
SendMessage $mui.Header.SubText ${WM_SETFONT} $1 1
FunctionEnd
Function MyPageCreate
!insertmacro MUI_HEADER_TEXT "Main" "{\rtf1{Subtext with a \b Bold \b0 }"
nsDialogs::Create 1018
Pop $0
nsDialogs::Show
FunctionEndhttps://stackoverflow.com/questions/58697173
复制相似问题