NSIS 脚本 + 跳过按钮对齐问题
NSIS script + Skip button alignment issue
我正在尝试使用 NSIS 脚本添加 "SKIP" 按钮。
我已经测试了下面的代码并且它运行良好但是当我实际与具有选项 "back" "Next" 和 "Cancel" 按钮屏幕的主代码集成时。这个跳过按钮根本不可见,它在取消按钮的最右边,几乎看不见。
如何将此 "Skip" 按钮移到左侧。
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 [=10=] $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *(i.r2,i.r3,i.r4,i.r5)
IntOp - ;height
IntOp - ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *(i.r2,i.r3)
System::Free
IntOp + ;x
IntOp + 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
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress [=10=] onmybtnclick
ButtonEvent::AddEventHandler 0x666 [=10=]
FunctionEnd
Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd
Page Directory
Page Instfiles
Section
SectionEnd
而且全屏都会出现这个按钮怎么才能只在一屏显示呢
在调用 CreateWindowEx 更改按钮位置之前更改 </code> 和 <code>
。您可以在 CreateWindowEx 之后将按钮的句柄保存在另一个变量中,但我在此示例中仅使用了 Id (0x666)。
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 [=10=] $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *(i.r2,i.r3,i.r4,i.r5)
IntOp - ;height
IntOp - ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *(i.r2,i.r3)
System::Free
!ifdef MUI_INCLUDED
StrCpy 15 ; Whatever you feel looks good
!else
IntOp + ;x
IntOp + 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
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress [=10=] onmybtnclick
ButtonEvent::AddEventHandler 0x666 [=10=]
FunctionEnd
Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd
Function HideIt
GetDlgItem [=10=] $hwndparent 0x666
ShowWindow [=10=] 0
FunctionEnd
Function ShowIt
GetDlgItem [=10=] $hwndparent 0x666
ShowWindow [=10=] 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
我正在尝试使用 NSIS 脚本添加 "SKIP" 按钮。
我已经测试了下面的代码并且它运行良好但是当我实际与具有选项 "back" "Next" 和 "Cancel" 按钮屏幕的主代码集成时。这个跳过按钮根本不可见,它在取消按钮的最右边,几乎看不见。
如何将此 "Skip" 按钮移到左侧。
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 [=10=] $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *(i.r2,i.r3,i.r4,i.r5)
IntOp - ;height
IntOp - ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *(i.r2,i.r3)
System::Free
IntOp + ;x
IntOp + 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
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress [=10=] onmybtnclick
ButtonEvent::AddEventHandler 0x666 [=10=]
FunctionEnd
Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd
Page Directory
Page Instfiles
Section
SectionEnd
而且全屏都会出现这个按钮怎么才能只在一屏显示呢
在调用 CreateWindowEx 更改按钮位置之前更改 </code> 和 <code>
。您可以在 CreateWindowEx 之后将按钮的句柄保存在另一个变量中,但我在此示例中仅使用了 Id (0x666)。
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 [=10=] $hwndparent 2 ; Find cancel button
System::Call *(i,i,i,i)i.r1
System::Call 'USER32::GetWindowRect(ir0,ir1)'
System::Call *(i.r2,i.r3,i.r4,i.r5)
IntOp - ;height
IntOp - ;width
System::Call 'USER32::ScreenToClient(i$hwndparent,ir1)'
System::Call *(i.r2,i.r3)
System::Free
!ifdef MUI_INCLUDED
StrCpy 15 ; Whatever you feel looks good
!else
IntOp + ;x
IntOp + 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
SendMessage [=10=] ${WM_SETFONT} 1
GetFunctionAddress [=10=] onmybtnclick
ButtonEvent::AddEventHandler 0x666 [=10=]
FunctionEnd
Function onmybtnclick
MessageBox mb_ok "You clicked me!"
FunctionEnd
Function HideIt
GetDlgItem [=10=] $hwndparent 0x666
ShowWindow [=10=] 0
FunctionEnd
Function ShowIt
GetDlgItem [=10=] $hwndparent 0x666
ShowWindow [=10=] 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