简体   繁体   中英

How to make a field Mandatory in Windows Installer custom dialog

I've recently created a setup project for my C# .NET Windows Forms Application.

In my User Interface Editor I have:

- Start
  - Welcome
  - Textboxes (A)
  - Installation Folder
  - Confirm Installation

In the Textboxes (A) dialog I have one edit field that I want to make mandatory.

How can I do that? I've downloaded the Orca editor. Is there a simple way to use that to do that?

These are the two goals I hope to achieve (goal 1 at least) :

  1. To enable/disable the next button based on edit label being non-empty
  2. Is it possible to validate the contents after hitting the next button?

Any help is appreciated.

Thanks!

Windows Installer Dialog definitions are located in CommonExtensions\\Microsoft\\VSI\\bin\\VsdDialogs folder under the IDE folder of the deployed version of VS, for example for a VS 2017 it is something like this:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\bin\VsdDialogs\

In that folder, go to 0 and 1033 folders, run orca as administrator and change the VsdCustomText1Dlg.wid file which is for Textboxes (A) .

Note 1 : You can create a new windows installer dialog by copying that file and renaming it to MyCustomDialog.wid . Then open it in orca and go to ModuleDialog table and change the DisplayName to My Custom Dialog . Make sure you copy the file in both 1033 and 0 . Then in VS, you can add an instance of this dialog using User Interface Editor of Setup project.

Note 2 : You can also edit the msi file using Orca and edit the control conditions, but if you do so, then every time you build the setup project, you need to repeat editing of the msi file. So editing .wid makes more sense.

Note 3 : Combining conditions of fields using AND and OR is possible as well. For more information, take a look at ControlCondition Table and Conditional Statement Syntax

Make a field mandatory in Windows Installer custom dialog

To make the Edit1 value mandatory and enable or disable Next button:

  1. Run orca as administrator

  2. Open the wid file which you used for adding the custom dialog.

  3. In ControlCondition , in addition to existing rows add the following rows:

     ┌──────────────┬──────────────┬──────────────┬──────────────┐ │ Dialog_ │ Control_ │ Action │ Condition │ ├──────────────┼──────────────┼──────────────┼──────────────┤ ... │ CustomTextA │ NextButton │ Disable │ EDITA1="" │ │ CustomTextA │ NextButton │ Enable │ EDITA1<>"" │ └──────────────┴──────────────┴──────────────┴──────────────┘
  4. Save the file and make sure you have the same file in both 1033 and 0 folders.

  5. Close Orca

  6. Rebuild setup project.

  7. Install it.

As a result you will see such behavior:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM