NSIS 在显示详细信息后隐藏详细信息

发布于 2024-12-15 08:24:55 字数 98 浏览 0 评论 0原文

在我的安装程序中,我当前可以看到“显示详细信息”按钮,并且可以单击该按钮来获取安装详细信息。

此时有什么方法可以让“隐藏详细信息”按钮能够返回到隐藏详细信息的位置吗?

In my installer, I currently have the "Show Details" button visible, and can click that to get to the installation details.

Is there any way to get a "Hide Details" button at this point to be able to go back to where the details are hidden?

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

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

发布评论

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

评论(2

仲春光 2024-12-22 08:24:55

对此没有官方支持(按钮可能浪费了太多空间)

如果你真的想要这个功能并且你不介意黑客,你可以使用以下代码:

Outfile test.exe
RequestExecutionLevel user
!addplugindir ".\" ;http://nsis.sourceforge.net/ButtonEvent_plug-in

!include WinMessages.nsh
!include LogicLib.nsh

Page InstFiles "" PageInstShow

!define GWLP_ID -12
!define IDC_DETAILS 0x3F8
!define IDC_SHOWDETAILS 0x403
!define IDC_MYTOGGLE 0x1000

Function MyToggleClickHandler
FindWindow $9 "#32770" "" $HWNDPARENT
GetDlgItem $8 $9 ${IDC_MYTOGGLE}
GetDlgItem $7 $9 ${IDC_DETAILS}
System::Call 'user32::IsWindowVisible(ir7)i.r0'
${If} $0 = 0
    SendMessage $9 ${WM_COMMAND} ${IDC_SHOWDETAILS} 0
    SendMessage $8 ${WM_SETTEXT} 0 "STR:Hide &details"
    ShowWindow $8 1
${Else}
    SendMessage $8 ${WM_SETTEXT} 0 "STR:$(^ShowDetailsBtn)"
    ShowWindow $7 0
${EndIf}
FunctionEnd

Function PageInstShow
FindWindow $9 "#32770" "" $HWNDPARENT
GetDlgItem $8 $9 ${IDC_SHOWDETAILS}
System::Call 'user32::SetWindowLong(ir8,i ${GWLP_ID},i ${IDC_MYTOGGLE})'
GetFunctionAddress $1 MyToggleClickHandler
ButtonEvent::AddEventHandler ${IDC_MYTOGGLE} $1
System::Call '*(i,i,i,i)i.r1'
System::Call 'user32::GetWindowRect(ir8,ir1)'
System::Call 'user32::MapWindowPoints(i0,ir9,ir1,i2)'
System::Call '*$1(i,i,i,i.r6)'
GetDlgItem $7 $9 ${IDC_DETAILS}
System::Call 'user32::GetWindowRect(ir7,ir1)'
System::Call 'user32::MapWindowPoints(i0,ir9,ir1,i2)'
System::Call '*$1(i.r2,i.r3,i.r4,i.r5)'
System::Free $1
IntOp $3 $6 + 4 ; list top = button bottom + padding
IntOp $5 $5 - $3
System::Call 'user32::SetWindowPos(ir7,i,ir2,ir3,ir4,ir5,i 0)'
FunctionEnd

Section
SectionEnd

There is no official support for this (Too much space wasted by the button probably)

If you really want this feature and you don't mind hacks you can use this code:

Outfile test.exe
RequestExecutionLevel user
!addplugindir ".\" ;http://nsis.sourceforge.net/ButtonEvent_plug-in

!include WinMessages.nsh
!include LogicLib.nsh

Page InstFiles "" PageInstShow

!define GWLP_ID -12
!define IDC_DETAILS 0x3F8
!define IDC_SHOWDETAILS 0x403
!define IDC_MYTOGGLE 0x1000

Function MyToggleClickHandler
FindWindow $9 "#32770" "" $HWNDPARENT
GetDlgItem $8 $9 ${IDC_MYTOGGLE}
GetDlgItem $7 $9 ${IDC_DETAILS}
System::Call 'user32::IsWindowVisible(ir7)i.r0'
${If} $0 = 0
    SendMessage $9 ${WM_COMMAND} ${IDC_SHOWDETAILS} 0
    SendMessage $8 ${WM_SETTEXT} 0 "STR:Hide &details"
    ShowWindow $8 1
${Else}
    SendMessage $8 ${WM_SETTEXT} 0 "STR:$(^ShowDetailsBtn)"
    ShowWindow $7 0
${EndIf}
FunctionEnd

Function PageInstShow
FindWindow $9 "#32770" "" $HWNDPARENT
GetDlgItem $8 $9 ${IDC_SHOWDETAILS}
System::Call 'user32::SetWindowLong(ir8,i ${GWLP_ID},i ${IDC_MYTOGGLE})'
GetFunctionAddress $1 MyToggleClickHandler
ButtonEvent::AddEventHandler ${IDC_MYTOGGLE} $1
System::Call '*(i,i,i,i)i.r1'
System::Call 'user32::GetWindowRect(ir8,ir1)'
System::Call 'user32::MapWindowPoints(i0,ir9,ir1,i2)'
System::Call '*$1(i,i,i,i.r6)'
GetDlgItem $7 $9 ${IDC_DETAILS}
System::Call 'user32::GetWindowRect(ir7,ir1)'
System::Call 'user32::MapWindowPoints(i0,ir9,ir1,i2)'
System::Call '*$1(i.r2,i.r3,i.r4,i.r5)'
System::Free $1
IntOp $3 $6 + 4 ; list top = button bottom + padding
IntOp $5 $5 - $3
System::Call 'user32::SetWindowPos(ir7,i,ir2,ir3,ir4,ir5,i 0)'
FunctionEnd

Section
SectionEnd
再浓的妆也掩不了殇 2024-12-22 08:24:55

来自 NSIS 脚本参考文档:

4.8.1.34 ShowInstDetails

隐藏|显示|从不显示

设置是否显示安装详细信息。可以是
“隐藏”默认隐藏详细信息,允许用户查看它们,
或“show”默认显示它们,或“nevershow”以阻止用户
从见过他们开始。请注意,部分可以使用以下方式覆盖此设置
设置DetailsView。

From NSIS Scripting Reference documentation:

4.8.1.34 ShowInstDetails

hide|show|nevershow

Sets whether or not the details of the install are shown. Can be
'hide' to hide the details by default, allowing the user to view them,
or 'show' to show them by default, or 'nevershow', to prevent the user
from ever seeing them. Note that sections can override this using
SetDetailsView.

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