简体   繁体   English

NSIS 安装程序 MUI_HEADER_TEXT - 这一部分可以是粗体吗?

[英]NSIS Installer MUI_HEADER_TEXT - Can part of this be bold font?

Is there a way to set part of the installer's MUI_HEADER_TEXT to bold font?有没有办法将安装程序的 MUI_HEADER_TEXT 的一部分设置为粗体?

I see examples on ${NSD_CreateLabel} for font but not the header text.我在 ${NSD_CreateLabel} 上看到了字体示例,但没有看到 header 文本。

!insertmacro MUI_HEADER_TEXT "Main" "Subtext with a BOLD " !insertmacro MUI_HEADER_TEXT "主要" "带有粗体的子文本 "

I found out that this is not possible.我发现这是不可能的。

I did find a solution for adding custom fonts to labels easily without guess work.我确实找到了一种解决方案,可以轻松地将自定义 fonts 添加到标签中,而无需猜测工作。

I used this editor and pasted the script in my setup.我使用了这个编辑器并将脚本粘贴到我的设置中。 https://coolsoft.altervista.org https://coolsoft.altervista.org

Windows does not generally support different fonts in a single control. Windows 在单个控件中一般不支持不同的 fonts。 The header text is also a label ( $mui.Header.SubText in MUIv2). header 文本也是 label(MUIv2 中的$mui.Header.SubText mui.Header.SubText)。

Some people use two labels when they require parts in bold but this is a bit of a hack to get them aligned correctly and it cannot be done to the header text because MUI needs to hide/show these when you switch from Welcome/Finish style pages to "normal" pages.有些人在需要以粗体显示的部分时会使用两个标签,但这有点难以让它们正确对齐,并且无法对 header 文本执行此操作,因为当您从欢迎/完成样式页面切换时,MUI 需要隐藏/显示这些到“正常”页面。

The only control that supports partly bold text is the RichEdit control and it can be done with a bit of hacking:支持部分粗体文本的唯一控件是 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
FunctionEnd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 MUI2 用于 NSIS 时,如何修改 MUI_WELCOME_PAGE 中的文本? - How can I modify the text in the MUI_WELCOME_PAGE when using MUI2 for NSIS? 按钮插件在 MUI NSIS 安装程序中不能用于多个按钮 - button plugin not working for more than one button in MUI NSIS Installer nsis 安装程序 autoexits/ 自动关闭,我正在使用 pre 和 show 函数来显示目录 MUI 页面 - nsis installer autoexits/ closes automatically , i am using pre and show functions to show a directory MUI page Nsis 脚本:尝试编写一个脚本,从 zip 文件中提取特定目录并将其添加为安装程序的一部分(可执行文件) - Nsis script: Trying to write a script which extracts specific directory from a zip file and adds it as a part of installer(executable) wix,InnoSetup,nsis的安装程序开销 - Installer overhead of wix, InnoSetup, nsis 我可以让 NSIS 制作一个单独的安装程序来处理本地部署和系统部署吗? - Can I get NSIS to make a single installer that handles local deployment and system deployment? NSIS 连接两个字符串的一部分 - NSIS concatenating part of two strings NSIS安装程序访问引擎检查是否已安装 - NSIS installer access engine check if installed 根据选择的单选按钮有条件地隐藏 nsis 安装程序中的部分 - hide section in nsis installer conditionally on choice of radiobuttons NSIS 安装程序脚本中 AppData 的环境变量是什么? - What is the environment variable for AppData in NSIS installer script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM