首页 > 解决方案 > 如何为自定义 nsis 安装程序添加边框

问题描述

我正在 NSIS/MUI2.nsh 的帮助下开发自定义安装程序。我正在努力为安装程序添加边框。

当我处理欢迎页面和完成页面时,我只需向位图添加边框(只需绘制它)并将其设置为相应地控制 id 1044。如何将边框添加到许可证、组件或目录页面?

标签: windowsnsis

解决方案


您可以通过创建额外的窗口来添加额外的边框:

OutFile Test.exe
RequestExecutionLevel user

Page License "" onLicShow
Page InstFiles

!include nsDialogs.nsh ; WS_*
Function onLicShow
GetDlgItem $5 $hWndParent 0xFFFFFFFF
ShowWindow $5 0 ; Hide the original line
System::Call 'USER32::GetWindowRect(pr5,@r0)' ; NSIS v3+
System::Call 'USER32::MapWindowPoints(p0, p$hWndParent, pr0, i1)'
System::Call '*$0(i.r1,i.r2,i.r3,i.r4)'
IntOp $2 $2 - 2 ; Adjust a little up
System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_VISIBLE}|${WS_CHILD}, i 0, i r2, i 9999, i 4, p$hWndParent, p0, p0, p0)p.r0'
SetCtlColors $0 "" 0xff0000 ; Red

System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_VISIBLE}|${WS_CHILD}, i 0, i 0, i 4, i 9999, p$hWndParent, p0, p0, p0)p.r0'
SetCtlColors $0 "" 0x00ff00 ; Green

System::Call 'USER32::GetClientRect(p$hWndParent,@r0)' ; NSIS v3+
System::Call '*$0(i,i,i.r3,i)'
IntOp $3 $3 - 4 ; X = Window width - border width
System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_VISIBLE}|${WS_CHILD}, i $3, i 0, i 4, i 9999, p$hWndParent, p0, p0, p0)p.r0'
SetCtlColors $0 "" 0xffff00 ; Yellow

System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_VISIBLE}|${WS_CHILD}, i 0, i 0, i 9999, i 4, p$hWndParent, p0, p0, p0)p.r0'
SetCtlColors $0 "" 0xffffff ; White

FindWindow $1 "#32770" "" $hWndParent ; Find the inner dialog
System::Call 'USER32::CreateWindowEx(i0, t"STATIC", p0, i ${WS_VISIBLE}|${WS_CHILD}, i 0, i 0, i 9999, i 7, p$1, p0, p0, p0)p.r0'
SetCtlColors $0 "" 0x0000ff ; Blue
FunctionEnd

内部对话框中的窗口仅在该页面上可见,其他窗口在所有页面上可见。


推荐阅读