nsis 自定义页面大小 [英] nsis custom page sizes

查看:119
本文介绍了nsis 自定义页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个显示我的网站的页面 (nsWeb::ShowWebInPage).问题是,它无法显示整个页面.

I am trying to create a page that is showing my website (nsWeb::ShowWebInPage). The problem is, it can't show the whole page.

如何为此页面定义新尺寸(高 x 宽)?

How can I define new sizes (height x width) to this page?

推荐答案

这是一项艰巨的任务.以下是使其工作的步骤,以一种有点灵活的方式.

This is a big task. Here are the steps for making it work, in a somewhat flexible way.

下载资源黑客:http://www.angusj.com/resourcehacker/

然后决定是否要编辑 NSIS 的 Unicode 或 ANSI 版本.你可以两者都做,但为什么要麻烦.首先找到您的 Program Files\NSIS 文件夹.如果您为 ANSI 编译,这将是下一步中以下目录的 BASE 文件夹.如果您正在为 unicode 进行编译,请进入 Program Files\NSIS\Unicode 文件夹,这现在是您下一步的基本文件夹.

Then decide if you want to edit the Unicode or the ANSI version of NSIS. You could do both, but why bother. Find your Program Files\NSIS folder first. This will be the BASE folder for the following directories in the next step if you are compiling for ANSI. If you are compiling for unicode, then step into the Program Files\NSIS\Unicode folder, and THIS is now your base folder for the next steps.

查看 \Contrib\UIs 文件夹内部.这个文件夹存储了一堆可执行文件.根据您使用的 MUI2 配置,您需要编辑相应的文件和 modern.exe.文件的版本取决于您是否有标题图像,是否正确调整等.

Look inside the \Contrib\UIs folder. This folder stores a bunch of executable files. Depending on which configuration of MUI2 you are using you need to edit the respective file AND modern.exe. The version of the file depends on if ou have a header image, if it's adjusted right or not, etc.

例如,就我而言,我的安装程序脚本中有这些定义

For example, in my case, I had these definitions in my installer script

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT

现在,当我查看\Contrib\Modern UI 2\Interface.nsh 时,我可以很容易地确定我需要编辑哪个文件.这是我看的:

Now, when I look in \Contrib\Modern UI 2\Interface.nsh, I can figure out fairly easily which file I need to edit. Here is what I look at:

!insertmacro MUI_DEFAULT MUI_UI "${NSISDIR}\Contrib\UIs\modern.exe"
!insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE "${NSISDIR}\Contrib\UIs\modern_headerbmp.exe"
!insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE_RIGHT "${NSISDIR}\Contrib\UIs\modern_headerbmpr.exe"
!insertmacro MUI_DEFAULT MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!insertmacro MUI_DEFAULT MUI_BGCOLOR "FFFFFF"

由于我使用的是 MUI_HEADERIMAGE_RIGHT,我将编辑 modern_headerbmpr.exe 文件.

Since I'm using the MUI_HEADERIMAGE_RIGHT, I will be editing the modern_headerbmpr.exe file.

现在,打开 Resource Hacker 并加载您要编辑的文件.Resource Hacker 有一个 GUI,因此当您逐步浏览每个对话框和对话框上的每个控件时,您可以在按重新编译"后看到 GUI 更改的一面.这部分非常简单.逐步完成所有对话框(为什么不)并编辑控件和大小,包括主安装程序的控件和大小.在此文件中,只有一个,因此您还需要打开 modern.exe,其中包含进入安装程序页面的子控件.再次,逐步浏览所有对话框并更改所有大小,使每个控件看起来都不错.编译,并将文件保存回此文件夹.

Now, open Resource Hacker and load the file you want to edit. Resource Hacker has a GUI, so as you step through each dialog and each control on the dialog, you can see the GUI change side after you press 'recompile'. This part is pretty straight forward. Step through ALL the dialogs (why not) and edit the controls and sizes, including that of the main installer. In this file, there is only one, so you ALSO need to open up modern.exe, which contains the sub-controls that goes into the installer pages. Again, step through all the dialogs and change all the sizes so each control looks good. Compile, and save the files back in to this folder.

加分项:为了测试,只需覆盖原始文件.你确实备份了,对吧?对于部署,为您编辑的每个文件命名新文件,例如modern-wide.exe".稍后,我们可以通过一点魔法在这些之间动态切换.

Bonus points: For testing, just overwrite the original files. You did take a backup, right? For deployment, name the new files something like "modern-wide.exe", for each file you edit. Later, we can dynamically switch between these with a little magic.

重新编译您的安装程序,现在您应该会看到一个新大小的安装程序.

Recompile your installer, and now you should see a new size installer.

如果不这样做,请检查您实际上位于正确的 ANSI 与 UNICODE 文件夹中,否则您的更改将不起作用.

If you don't, check that you are in fact in the right ANSI versus UNICODE folder, or your changes won't work.

但是,某些屏幕会动态添加控件.例如,查看\Contrib\Modern UI 2\Pages\Welcome.nsh.

SOME of the screens, however, add controls dynamically. As an example, look at \Contrib\Modern UI 2\Pages\Welcome.nsh.

此文件在代码中添加标题标签和欢迎文本,而不是通过 exe 文件.啊,我知道!所以找到宏:

This file adds the title label and welcome text in code, and NOT via the exe files. Argh, I know! So locate the Macro:

!macro MUI_FUNCTION_WELCOMEPAGE PRE LEAVE

还有这几行代码:

${NSD_CreateBitmap} 0u 0u 109u 193u ""
...
${NSD_CreateLabel} 120u 10u 195u ${MUI_WELCOMEPAGE_TITLE_HEIGHT}u "${MUI_WELCOMEPAGE_TITLE}"
...
${NSD_CreateLabel} 120u ${MUI_WELCOMEPAGE_TEXT_TOP}u 195u 130u "${MUI_WELCOMEPAGE_TEXT}"

如您所见,此处的单位是 X Y WIDTH HEIGHT,因此现在您可以修改这些控件.当然,如果您不使用欢迎页面,请不要打扰.但是您可能需要以这种方式编辑对您不起作用的页面.

As you can see, the units here are X Y WIDTH HEIGHT, so now you get to modify these controls. Of course, if you don't use the welcome page, don't bother. But you may need to edit the pages that doesn't work for you in this manner.

您可以覆盖原始文件,或者再次保存文件,并在文件名后附加-wide".

You can overwrite the original, or again, save the file with "-wide" appended to the filename.

现在,你基本上完成了!

Now, your basically done !

现在,为了使切换更容易,我假设您已保存:

Now, to make this MUCH easier to switch, I will assume you saved:

welcome.nsh as welcome-wide.nsh
modern.exe as modern-wide.exe 
and let's say modern_headerbmpr.exe as modern_headerbmpr-wide.exe

现在,在您的安装程序中,添加此 !define BEFORE 包括 MUI2.nsh:

Now, in your installer, add this !define BEFORE including MUI2.nsh:

!define MUI_ALTERNATE_SIZE_EXT "-wide" 

在 interface.nsh 中,将代码更改为:

in interface.nsh, change the code to this:

!ifdef MUI_ALTERNATE_SIZE_EXT
    !insertmacro MUI_DEFAULT MUI_UI "${NSISDIR}\Contrib\UIs\modern${MUI_ALTERNATE_SIZE_EXT}.exe"
    !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE "${NSISDIR}\Contrib\UIs\modern_headerbmp.exe"
    !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE_RIGHT "${NSISDIR}\Contrib\UIs\modern_headerbmpr${MUI_ALTERNATE_SIZE_EXT}.exe"
    !insertmacro MUI_DEFAULT MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
    !insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
    !insertmacro MUI_DEFAULT MUI_BGCOLOR "FFFFFF"
!else
    !insertmacro MUI_DEFAULT MUI_UI "${NSISDIR}\Contrib\UIs\modern.exe"
    !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE "${NSISDIR}\Contrib\UIs\modern_headerbmp.exe"
    !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE_RIGHT "${NSISDIR}\Contrib\UIs\modern_headerbmpr.exe"
    !insertmacro MUI_DEFAULT MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
    !insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
    !insertmacro MUI_DEFAULT MUI_BGCOLOR "FFFFFF"
!endif

当您将 MUI_ALTERNATE_SIZE_EXT 定义为-wide"时,这实际上将您的安装程序从常规切换到-wide".请注意我是如何将 ${MUI_ALTERNATE_SIZE_EXT} 直接添加到我更改的文件的文件名中的,当然您应该对开始时最终更改的文件执行此操作.

This essentially switches your installer from regular to "-wide" when you define MUI_ALTERNATE_SIZE_EXT as "-wide". Note how I added the ${MUI_ALTERNATE_SIZE_EXT} directly to the file name include of the files I changed, and you should of course do this for the files YOU ended up changing when you started.

现在,您还需要在 MUI2.NSH 文件中执行此操作,如下所示:

Now, you will also need to do this in the MUI2.NSH file, like so:

!ifdef MUI_ALTERNATE_SIZE_EXT
    !include "Pages\Components.nsh"
    !include "Pages\Directory.nsh"
    !include "Pages\Finish.nsh"
    !include "Pages\InstallFiles.nsh"
    !include "Pages\License.nsh"
    !include "Pages\StartMenu.nsh"
    !include "Pages\UninstallConfirm.nsh"
    !include "Pages\Welcome${MUI_ALTERNATE_SIZE_EXT}.nsh"
!else
    !include "Pages\Components.nsh"
    !include "Pages\Directory.nsh"
    !include "Pages\Finish.nsh"
    !include "Pages\InstallFiles.nsh"
    !include "Pages\License.nsh"
    !include "Pages\StartMenu.nsh"
    !include "Pages\UninstallConfirm.nsh"
    !include "Pages\Welcome.nsh"
!endif

当您编辑更多文件时,您只需在单独的文件名中保留您创建的每个新 UI 的一个版本,现在您只需使用一个定义即可切换安装程序的 UI 样式.您可以随意命名文件,并将此方案扩展到您可能遇到问题的其他领域.

As you edit more files, you simply keep a version of each new UI you create in separate filenames, and now you can switch the UI style of your installer with just the one definition. You can name files as you wish, and expand this scheme to other areas where you may run into trouble.

这不是一件容易的事,但可以做到.

Not an easy task to do this, but it can be done.

这篇关于nsis 自定义页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆