[英]NSIS Directory Page without changeable Field
In the directory page of the NSIS installer I want to show the installation path but without changing it.在 NSIS 安装程序的目录页面中,我想显示安装路径但不更改它。
I makes in the Directory.nsh EnableWindow for the fields:我在 Directory.nsh EnableWindow 中为以下字段制作:
;Get control handles
FindWindow $mui.DirectoryPage "#32770" "" $HWNDPARENT
GetDlgItem $mui.DirectoryPage.Text $mui.DirectoryPage 1006
GetDlgItem $mui.DirectoryPage.DirectoryBox $mui.DirectoryPage 1020
GetDlgItem $mui.DirectoryPage.Directory $mui.DirectoryPage 1019
GetDlgItem $mui.DirectoryPage.BrowseButton $mui.DirectoryPage 1001
GetDlgItem $mui.DirectoryPage.SpaceRequired $mui.DirectoryPage 1023
GetDlgItem $mui.DirectoryPage.SpaceAvailable $mui.DirectoryPage 1024
EnableWindow $mui.DirectoryPage.Directory 0
EnableWindow $mui.DirectoryPage.BrowseButton 0
Now the fields are gray and blocked:现在这些字段是灰色的并被阻止:
But that's not what I want:但这不是我想要的:
the button should disappear按钮应该消失
The directory field should be larger and with normal brightness, ie a normal field目录字段应该更大并且具有正常亮度,即正常字段
How do I do it?我该怎么做?
As stated in the comments, this is a bad idea.正如评论中所述,这是一个坏主意。 The user can also set a different $InstDir
with /D
on the command line.用户还可以在命令行上使用/D
设置不同的$InstDir
。
You can make the edit field read-only instead of disabling it, this way the user can at least select/copy the text.您可以将编辑字段设为只读而不是禁用它,这样用户至少可以选择/复制文本。 The control might still be grayed out, it depends on the active Windows visual style/theme.该控件可能仍显示为灰色,这取决于活动的 Windows 视觉样式/主题。
You can use MUI_UI
and a custom UI file or resize the control at run-time:您可以使用MUI_UI
和自定义 UI 文件或在运行时调整控件的大小:
InstallDir "$Temp\Whatever"
!include WinMessages.nsh
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW LockDirPage
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Function LockDirPage
EnableWindow $mui.DirectoryPage.BrowseButton 0
ShowWindow $mui.DirectoryPage.BrowseButton 0
SendMessage $mui.DirectoryPage.Directory ${EM_SETREADONLY} 1 ""
System::Call 'USER32::GetWindowRect(p$mui.DirectoryPage.Directory,@r1)'
System::Call 'USER32::GetWindowRect(p$mui.DirectoryPage.BrowseButton,@r2)'
System::Call *$2(i,i,i.r2)
System::Call *$1(i.r3,i.r4,i,i.r6)
IntOp $3 $2 - $3 ; Width
IntOp $4 $6 - $4 ; Height
System::Call 'USER32::SetWindowPos(p$mui.DirectoryPage.Directory,p0,i0,i0,ir3,ir4,i0x16)'
FunctionEnd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.