NSIS脚本+;跳过按钮对齐问题

NSIS脚本+;跳过按钮对齐问题,nsis,Nsis,我正在尝试NSIS脚本添加“跳过”按钮 我已经测试了下面的代码,它工作得很好,但是当我实际与主代码集成时,主代码有一个选项“后退”、“下一步”和“取消”按钮的屏幕。该跳过按钮根本不可见,它位于“取消”按钮的最右侧,几乎不可见 如何将此“跳过”按钮移向左侧 Name BtnTest Outfile test.exe Installdir "$temp" RequestExecutionLevel user BrandingText " " ;Button covers this text !inc

我正在尝试NSIS脚本添加“跳过”按钮

我已经测试了下面的代码,它工作得很好,但是当我实际与主代码集成时,主代码有一个选项“后退”、“下一步”和“取消”按钮的屏幕。该跳过按钮根本不可见,它位于“取消”按钮的最右侧,几乎不可见

如何将此“跳过”按钮移向左侧

Name BtnTest
Outfile test.exe
Installdir "$temp"
RequestExecutionLevel user
BrandingText " " ;Button covers this text
!include nsDialogs.nsh ;For WS_*
!define MUI_CUSTOMFUNCTION_GUIINIT SKIP

Function SKIP
; You are supposed to use ChangeUI (or MUI_UI) and a modified ui file to add new buttons but this example adds the button at run-time...
GetDlgItem $0 $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *$1(i.r2,i.r3,i.r4,i.r5)
IntOp $5 $5 - $3 ;height
IntOp $4 $4 - $2 ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *$1(i.r2,i.r3)
System::Free $1
IntOp $2 $2 + $4 ;x
IntOp $2 $2 + 8  ;x+padding
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Click Me",i${WS_CHILD}|${WS_VISIBLE}|${WS_TABSTOP},ir2,ir3,ir4,ir5,i $hwndparent,i 0x666,i0,i0)i.r0'
SendMessage $hwndparent ${WM_GETFONT} 0 0 $1
SendMessage $0 ${WM_SETFONT} $1 1

GetFunctionAddress $0 onmybtnclick
ButtonEvent::AddEventHandler 0x666 $0
FunctionEnd

Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd

Page Directory
Page Instfiles

Section
SectionEnd

同时,此按钮显示在所有屏幕上。如何仅在一个屏幕上显示。

在调用CreateWindowEx更改按钮位置之前更改
$2
$3
。您可以将按钮的句柄保存在CreateWindowEx之后的另一个变量中,但我在本例中仅使用了Id(0x666)


你在使用现代用户界面吗?按钮位置不一样,这可能是它最终出现在错误位置的原因。请在下次发布完整代码,此代码已丢失
!包括MUI.nsh
Function.onGuiInit
!NSIS与Windows Installer相反。标记已删除。我有自定义页面,正如您在else循环中提到的。但是else循环中的代码没有执行。。。在else循环中,我有一个自定义的“MailSetUp”“Mail”页面,其中MailSetUp是一个ini文件。在这里,它不起作用。您能帮助我吗?在邮件设置开始时呼叫ShowIt是的,我在邮件设置之前尝试了此操作,如下面的页面自定义代码段中所示,但在这种情况下,邮件设置屏幕本身不显示,按钮显示在下一个屏幕上,即DSetup屏幕中。自定义屏幕代码为-Page custom ShowIt“MailSetUp”“Mail”和Page custom“DBSetup”“Validate”当使用自定义页面时,无法将ShowIt放入页面说明中,请将“call ShowIt”添加到MailSetUp功能中…注:此代码与MUI不兼容,因为取消按钮位于窗口的另一侧。将$2设置为较小的值或使用我发布的代码@
Name BtnTest
Outfile test.exe
Installdir "$temp"
RequestExecutionLevel user
BrandingText " " ;Button covers this text
!include nsDialogs.nsh ;For WS_*
!define MUI_CUSTOMFUNCTION_GUIINIT SKIP
/**/ !include MUI2.nsh #*/
!ifndef MUI_INCLUDED
Function .onGuiInit
Call SKIP
FunctionEnd
!endif

Function SKIP
; You are supposed to use ChangeUI (or MUI_UI) and a modified ui file to add new buttons but this example adds the button at run-time...
GetDlgItem $0 $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *$1(i.r2,i.r3,i.r4,i.r5)
IntOp $5 $5 - $3 ;height
IntOp $4 $4 - $2 ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *$1(i.r2,i.r3)
System::Free $1
!ifdef MUI_INCLUDED
StrCpy $2 15 ; Whatever you feel looks good
!else
IntOp $2 $2 + $4 ;x
IntOp $2 $2 + 8  ;x+padding
!endif
System::Call 'USER32::CreateWindowEx(i0,t "Button",t "Click Me",i${WS_CHILD}|${WS_VISIBLE}|${WS_TABSTOP},ir2,ir3,ir4,ir5,i $hwndparent,i 0x666,i0,i0)i.r0'
SendMessage $hwndparent ${WM_GETFONT} 0 0 $1
SendMessage $0 ${WM_SETFONT} $1 1

GetFunctionAddress $0 onmybtnclick
ButtonEvent::AddEventHandler 0x666 $0
FunctionEnd

Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd

Function HideIt
GetDlgItem $0 $hwndparent 0x666
ShowWindow $0 0
FunctionEnd
Function ShowIt
GetDlgItem $0 $hwndparent 0x666
ShowWindow $0 1
FunctionEnd

!ifdef MUI_INCLUDED
!define MUI_PAGE_CUSTOMFUNCTION_SHOW HideIt
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowIt
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_SHOW HideIt
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
!else
Page Components "" HideIt
Page Components "" ShowIt
Page Components "" HideIt
Page Instfiles
!endif

Section
SectionEnd