Wix:如何在Wix中添加浏览按钮

时间:2011-08-08 09:04:52

标签: wix

是否有一种简单的方法可以在Wix中添加浏览按钮。我通过修改WixUI_InstallDir.wxs创建了一个自定义。此浏览按钮位于另一个对话框中(与查找安装路径的对话框不同)。此浏览按钮将用于指定放置将在安装期间创建的日志文件的路径。

修改

对“代码下方”的混淆感到抱歉。我打算最初显示代码,但上述答复的空间有限。我在这里添加了代码。我设法现在显示“浏览”对话框,但我需要能够更改路径,使其与安装路径的浏览对话框路径(_BrowseProperty)不同。我下面的代码是使用_LogBrowseProperty,但我不知道如何正确定义它以及我应该在哪里定义它。使用下面的代码将生成2819错误。你能帮忙看看这里有什么问题吗?非常感谢。

CUSTOMDIR在Product.wxs中定义

 <Property Id='CUSTOMDIR' Value="TARGETDIR"></Property>

以下是MyWixUI_InstallDir.wxs

   <Control Id="LogFolderLabel" Type="Text" X="20" Y="160" Width="290" Height="30" NoPrefix="yes"
                     Text="Folder Label" />
            <Control Id="LogFolder" Type="PathEdit" X="20" Y="200" Width="320" Height="18" Property="CUSTOMDIR"
                     Indirect="yes" />
            <Control Id="ChangeFolder" Type="PushButton" X="20" Y="220" Width="56" Height="17"
                     Text="Change Folder" />

...

  <Publish Dialog="myDlg" Control="ChangeFolder" Property="_LogBrowseProperty" Value="[CUSTOMDIR]" Order="1">1</Publish>
  <Publish Dialog="myDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>


  <Property Id="_LogBrowseProperty" Value="TARGETDIR" />

2 个答案:

答案 0 :(得分:3)

我正在寻找一段时间尝试做同样的事情,并修改了Wix BroseDlg对话框来实现这一目标。

在父控件中,我有以下路径编辑和按钮控件:

<Control Id="LogFilePathValue" Type="PathEdit" X="50" Y="205" Width="215" Height="18" Property="LOGFILE_PATH"/>
    <Control Id="LogFilePathButton" Type="PushButton" X="270" Y="205" Width="50" Height="17" Text="!(loc.LogFilePathButton_Text)">
      <Publish Property="LOGFILE_PATH_TEMP" Value="[LOGFILE_PATH]" Order="1">1</Publish>
      <Publish Event="SpawnDialog" Value="MyLogFileDialog" Order="2">1</Publish>
    </Control>
</Control>

MyLogFileDialog然后看起来像这样:

<Dialog Id="MyLogFileDialog" Width="370" Height="270" Title="!(loc.MyLogFileDialog_DialogTitle)">
    <Control Id="PathEdit" Type="PathEdit" X="25" Y="202" Width="320" Height="18" Property="LOGFILE_PATH_TEMP" />
    <Control Id="OK" Type="PushButton" X="240" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUIOK)">
      <Publish Property="LOGFILE_PATH" Value="[LOGFILE_PATH_TEMP]" Order="1">1</Publish>
      <Publish Event="EndDialog" Value="Return" Order="2">1</Publish>
    </Control>
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
      <Publish Event="EndDialog" Value="Return">1</Publish>
    </Control>
    <Control Id="ComboLabel" Type="Text" X="25" Y="58" Width="44" Height="10" TabSkip="no" Text="!(loc.BrowseDlgComboLabel)" />
    <Control Id="DirectoryCombo" Type="DirectoryCombo" X="70" Y="55" Width="220" Height="80" Property="LOGFILE_PATH_TEMP" Fixed="yes" Remote="yes">
      <Subscribe Event="IgnoreChange" Attribute="IgnoreChange" />
    </Control>
    <Control Id="WixUI_Bmp_Up" Type="PushButton" X="298" Y="55" Width="19" Height="19" ToolTip="!(loc.BrowseDlgWixUI_Bmp_UpTooltip)" Icon="yes" FixedSize="yes" IconSize="16" Text="!(loc.BrowseDlgWixUI_Bmp_Up)">
      <Publish Event="DirectoryListUp" Value="0">1</Publish>
    </Control>
    <Control Id="NewFolder" Type="PushButton" X="325" Y="55" Width="19" Height="19" ToolTip="!(loc.BrowseDlgNewFolderTooltip)" Icon="yes" FixedSize="yes" IconSize="16" Text="!(loc.BrowseDlgNewFolder)">
      <Publish Event="DirectoryListNew" Value="0">1</Publish>
    </Control>
    <Control Id="DirectoryList" Type="DirectoryList" X="25" Y="83" Width="320" Height="98" Property="LOGFILE_PATH_TEMP" Sunken="yes" TabSkip="no" />
    <Control Id="PathLabel" Type="Text" X="25" Y="190" Width="320" Height="10" TabSkip="no" Text="!(loc.BrowseDlgPathLabel)" />
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.BrowseDlgBannerBitmap)" />
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
    <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.MyLogFileDialog_TitleBody)" />
    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.MyLogFileDialog_TitleMain)" />
  </Dialog>

然后,您必须确保在调用此父窗体之前设置了属性LOGFILE_PATH。在我的情况下,我使用自己的UI_Mondo版本,所以我在用户选择安装类型后设置属性:

  <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Property="LOGFILE_PATH" Value="[COMPONENTINSTALLFOLDER]\Logs" Order="1">1</Publish>
  <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="ParentDialogWithLogLocationControls" Order="2">1</Publish>

答案 1 :(得分:1)

尝试更仔细地检查WiXUIExtension,尤其是WixUI_InstallDir.wxs和InstallDirDlg.wxs。了解控件和对话框的设置方式,以便正确处理目录浏览并尝试根据您的需要进行调整。

来自InstallDirDlg.wxs:

<Control Id="Folder" Type="PathEdit" X="20" Y="100" Width="320" Height="18" Property="WIXUI_INSTALLDIR" Indirect="yes" />
<Control Id="ChangeFolder" Type="PushButton" X="20" Y="120" Width="56" Height="17" Text="!(loc.InstallDirDlgChange)" />

来自WixUI_InstallDir.wxs:

<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
...
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>