如何更改 NSIS 中欢迎页面和完成页面中图像的宽度,使其看起来像背景?

发布于 2025-01-15 09:34:59 字数 59 浏览 4 评论 0原文

我想创建一个安装程序,其中在欢迎页面和完成页面中,而不是左侧的横幅,有一个覆盖对话框整个宽度的背景图像。

I want to create an installer in which in the welcome and finish pages instead of a banner on the left side, there is a background image that covers the whole width of the dialog.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上青苔 2025-01-22 09:34:59

欢迎和完成页面是使用 nsDialogs 创建的自定义 NSIS 页面。但是,如果您希望位图覆盖整个对话框,那么您还需要对实际的 UI 文件进行一些修改。

  1. 将 ...\NSIS\Contrib\UIs\modern.exe 复制到 myui.exe

  2. 使用资源黑客 将位图控件添加到对话框 105。

  3. 在 .nsh 的顶部,将MUI_UI定义为myui.exe的路径

  4. 使用 nsDialogs 创建自定义页面以模拟“欢迎”和“完成”页面。在调用 nsDialogs::Show 之前,您需要:

    1. 在自定义对话框句柄上调用 SetCtlColors 以使其透明。
    2. 将您的自定义 .bmp 提取到 $PluginsDir。
    3. 调用LoadAndSetImage将图像加载到您在对话框105中创建的控件中。

如果您不想自己完成所有这些操作,您可以使用 图形安装程序 第 3 方产品。

这是使用页面区域的示例:

!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyHijackWelcome
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
Page Custom MyFullBitmapPage
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_LANGUAGE English

!include nsDialogs.nsh
PEAddResource "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp" "#Bitmap" "#1337" ; Lazy way to include an image
Function MyFullBitmapPage
ShowWindow $mui.Branding.Background ${SW_HIDE}
ShowWindow $mui.Branding.Text ${SW_HIDE}
nsDialogs::Create 1044
Pop $1

${NSD_CreateLabel} 10u 25u 100% 12u "Hello world"
Pop $2
SetCtlColors $2 000000 transparent

${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $2
LoadAndSetImage /EXERESOURCE /RESIZETOFIT $2 0 0 1337 $3
nsDialogs::Show
${NSD_FreeBitmap} $3
ShowWindow $mui.Branding.Background ${SW_SHOW}
ShowWindow $mui.Branding.Text ${SW_SHOW}
FunctionEnd

Function MyHijackWelcome
SendMessage $mui.WelcomePage.Image ${STM_SETIMAGE} 0 0
${NSD_FreeBitmap} $mui.WelcomePage.Image.Bitmap
${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $mui.WelcomePage.Image
LoadAndSetImage /EXERESOURCE /RESIZETOFIT $mui.WelcomePage.Image 0 0 1337 $mui.WelcomePage.Image.Bitmap
SetCtlColors $mui.WelcomePage.Title 000000 transparent
SetCtlColors $mui.WelcomePage.Text 000000 transparent
FunctionEnd

如果您希望位图扩展到页面区域的边界之外,则必须使用我最初的建议 !define MUI_UI+GetDlgItem +加载并设置图像

The Welcome and Finish pages are custom NSIS pages created with nsDialogs. However, if you want a bitmap to cover the entire dialog then you need to do some modifications to the actual UI files as well.

  1. Copy ...\NSIS\Contrib\UIs\modern.exe to myui.exe

  2. Use Resource Hacker to add a bitmap control to dialog 105.

  3. At the top of your .nsh, define MUI_UI to the path of myui.exe

  4. Create custom pages with nsDialogs to mimic the Welcome and Finish pages. Before calling nsDialogs::Show you need to:

    1. Call SetCtlColors on the custom dialog handle to make it transparent.
    2. Extract your custom .bmp to $PluginsDir.
    3. Call LoadAndSetImage to load the image into the control you created in dialog 105.

If you don't want to do all of this yourself you can use the Graphical Installer 3rd-party product.

Here is an example using the page area:

!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyHijackWelcome
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
Page Custom MyFullBitmapPage
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_LANGUAGE English

!include nsDialogs.nsh
PEAddResource "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp" "#Bitmap" "#1337" ; Lazy way to include an image
Function MyFullBitmapPage
ShowWindow $mui.Branding.Background ${SW_HIDE}
ShowWindow $mui.Branding.Text ${SW_HIDE}
nsDialogs::Create 1044
Pop $1

${NSD_CreateLabel} 10u 25u 100% 12u "Hello world"
Pop $2
SetCtlColors $2 000000 transparent

${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $2
LoadAndSetImage /EXERESOURCE /RESIZETOFIT $2 0 0 1337 $3
nsDialogs::Show
${NSD_FreeBitmap} $3
ShowWindow $mui.Branding.Background ${SW_SHOW}
ShowWindow $mui.Branding.Text ${SW_SHOW}
FunctionEnd

Function MyHijackWelcome
SendMessage $mui.WelcomePage.Image ${STM_SETIMAGE} 0 0
${NSD_FreeBitmap} $mui.WelcomePage.Image.Bitmap
${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $mui.WelcomePage.Image
LoadAndSetImage /EXERESOURCE /RESIZETOFIT $mui.WelcomePage.Image 0 0 1337 $mui.WelcomePage.Image.Bitmap
SetCtlColors $mui.WelcomePage.Title 000000 transparent
SetCtlColors $mui.WelcomePage.Text 000000 transparent
FunctionEnd

If you want the bitmap to extend outside the bounds of the page area you have to use my initial suggestion with !define MUI_UI+GetDlgItem+LoadAndSetImage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文