User interface 在NSIS中,如何在使用nsDialogs::Create 1018时设置对话框的大小?

User interface 在NSIS中,如何在使用nsDialogs::Create 1018时设置对话框的大小?,user-interface,dialog,size,controls,nsis,User Interface,Dialog,Size,Controls,Nsis,在Nsis中,我使用: ... nsDialogs::Create 1018 Pop $0 nsDialogs::Show ... 但是对话框的大小不适合我的需要。如何为此对话框指定x和y的长度?如果要调整所有内容的大小,可能最好使用Resource Hacker和ChangeUI,但您可以在运行时执行此操作: !include nsDialogs.nsh Function mypage System::Call 'user32::SetWindowPos(i$hwndparen

在Nsis中,我使用:

 ...
 nsDialogs::Create 1018
 Pop $0

 nsDialogs::Show
 ...

但是对话框的大小不适合我的需要。如何为此对话框指定x和y的长度?

如果要调整所有内容的大小,可能最好使用Resource Hacker和
ChangeUI
,但您可以在运行时执行此操作:

!include nsDialogs.nsh

Function mypage
System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 640,i 480,i 0x16)' ; Resize outer dialog
nsDialogs::Create 1018
Pop $0
System::Call 'user32::MoveWindow(i$0,i0,i0,i 600,i 200,i0)' ; Resize inner (nsDialogs) page

${NSD_CreateLabel} 0 10u 100% 10u "Hello, welcome to nsDialogs!"
Pop $0
SetCtlColors $0 0xffffff 0xff2255

nsDialogs::Show
FunctionEnd

page custom mypage

我的对话框不够高,无法容纳我要放入的所有控件

我尝试了两个Windows API,当它们工作时,安装的客户端区域重叠并覆盖了OK/Cancel按钮

我最终制定了“使用资源黑客和ChangeUI”。这比我想象的要困难得多。因此,这里有一个更详细的操作方法。我与nsDialogs而不是ModernUI有着深厚的渊源。这是nsDialogs调整窗口大小的操作指南,创建的窗口与示例中相同。上文介绍了摩德努伊

nsDialogs::创建1018

  • 从Angus获得ResourceHacker:
  • 转到您的NSIS Contrib文件夹。C:\Program Files(x86)\NSIS\Contrib\ui并将default.exe复制到与NSI脚本文件相同的文件夹中
  • 将default.exe的本地副本重命名为tall_UI.exe
  • 打开ResourceHacker,将tall_UI.exe拖到窗口中
  • 使用树状视图深入到资源105并单击1033。当你点击1033,它会显示一个预览
  • 您拥有的是代码和预览。注意第一行代码

    105 DIALOGEX 0, 0, 280, 162
    
  • 现在单击预览窗口的上边缘并拉伸它使其更高。请注意,该行中的最终数字变大了。请注意,现在窗口底部有多大的空白
  • 对话框底部边缘有四个控件:一个按钮、一个不可见框和另外两个按钮。将所有这些项向下拖动到窗口底部附近。选择每个控件时,您将注意到代码窗口中正在修改的控件的红色*标记。把它们放在你想要的地方
  • 移动水平分隔线。它很瘦,很难移动
  • 你会希望你的按钮都排成一排。要使它们精确,请移到“代码”窗口,编辑每一个控件行尾的第三个数字。要将这些更改应用于代码窗口,请单击“编译脚本”
  • 单击大灰色框进行选择,然后使用其底边点将其拉伸到所需高度
  • 调整代码或预览。我经常打电话
  • 很完美,你喜欢。最后一次点击编译
  • 单击“文件”和“保存”。它将保存您的Tall_UI.exe,并制作一个名为Tall_UI_original.exe的副本
  • 在NSIS脚本中,需要尽早添加对ChangeAll的调用

    ChangeUI all tall_UI.exe
    Page custom nsDialogsPage
    
    Function nsDialogsPage
        nsDialogs::Create 1018 
        Pop $Dialog
        ...
    
  • 那是为了我。你会做一些尝试和错误,总是点击commpile并保存在ResourceHacker中,然后重建你的NSI。您可能会注意到,您的对话框比ResourceHacker中显示的预览大或小。这是因为NSIS会根据字体大小、DPI。。。诸如此类。试着再试,直到它看起来不错

    您将注意到nsDialogs::Create 1018与资源黑客第5行中的数字匹配:

    CONTROL "", 1018, STATIC, SS_BLACKRECT | WS_CHILD | WS_GROUP, 7, 7, 266, 160  
    
    我做了一些测试后,得到了这个演示和位置和1018资源的大小确实有影响,但我不能告诉你为什么它不是黑色的

    我的演示的完整代码如下所示

    #Created with NSIS version 2.46 downloaded from SourceForge.net
    #Based on "Adding Controls" section of user docs
    # http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html#step-add
    
    !include nsDialogs.nsh
    
    Name "Launchpad"
    OutFile "Master Installer.exe"
    BrandingText " "
    Caption "Launchpad"
    RequestExecutionLevel admin
    SetFont "Arial" 10
    VIProductVersion "2.5.0.0"
    
    Var Dialog
    Var Button
    
    ChangeUI all tall_UI.exe
    Page custom nsDialogsPage
    
    Function nsDialogsPage
        nsDialogs::Create 1018 
        Pop $Dialog
    
        # It will create a new dialog in the page and return its HWND on the stack. The result must be popped from the stack to prevent stack corruption. If the result is error, the dialog couldn't be created.
        ${If} $Dialog == error
        Abort
        ${EndIf}
    
        # ${NSD_Create*} x y width height text
    
        ## Going to use $0 for y of each new control.
        StrCpy $0 "29"
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product Manual"
        Pop $Button
        ${NSD_OnClick} $Button Manual_Install_Clicked
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
        Pop $Button
        ${NSD_OnClick} $Button Product1_Install_Clicked
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 2 Installer"
        Pop $Button
        ## ${NSD_OnClick} ...
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 3 Installer"
        Pop $Button
        ## ${NSD_OnClick} ...
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 4 Installer"
        Pop $Button
        ## ${NSD_OnClick} ...
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
        Pop $Button
        ## ${NSD_OnClick} ...
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        ${NSD_CreateButton} 50% "$1u" 25% 12u "Product 1 Installer"
        Pop $Button
        ## ${NSD_OnClick} ...
        IntOp $0 $0 + 18
        IntOp $1 $0 - 2
    
        nsDialogs::Show
    FunctionEnd
    
    Function ExecInstall
        pop $0
        ExecWait $0 $1
        IfErrors 0 ExecDone
        MessageBox MB_OK|MB_IconExclamation "$1 $0 not found"
        ExecDone:
        ##Call Update_Install_Statuses
    FunctionEnd
    
    Function Manual_Install_Clicked
        ExecShell "open" "$EXEDIR\Manual\Manual.PDF"
    FunctionEnd
    
    Function Product1_Install_Clicked
        Exec "Explorer.exe $EXEDIR\Support Files"
    FunctionEnd
    
    Function Product2_Install_Clicked
        Push "$EXEDIR\Product2 Folder\Product2 Installer.exe"
        Call ExecInstall
    FunctionEnd
    
    Section
    
    SectionEnd