Daniel Enetoft
Daniel Enetoft

Reputation: 422

Check if MaskedEdit control contains text

Hi I'm working with wix to create an installation. I need a custom dialog to let the user define a port. The dialog have a control that is of type MaskedEdit where he should write the port. The property connected to the control have a default value defined. The problem is that when the user presses the next button, I would like to make sure that the port field have a value or else show him a warning. The code for the control looks like this:

<Property Id="DataStoragePort">4323</Property>

  <Dialog Id="DataStoragePortConfig" Width="370" Height="270" Title="CellaVision DM1 Setup">
    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
    </Control>
    <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back">
    </Control>
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
      <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
    </Control>

    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Data Storage Configuration" />
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
    <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="DSDescription" Type="Text" X="20" Y="60" Width="250" Height="13" NoPrefix="yes" Text="Enter the port that the Data Storage Service should run on" />
    <Control Id="DSPort" Type="Text" X="20" Y="80" Width="20" Height="13" NoPrefix="yes" Text="Port:" />
    <Control Id="DSText" Type="MaskedEdit" Text="#####" X="45" Y="78" Width="70" Height="14" Property="DataStoragePort" />
  </Dialog>

and the handling of click on the next button look like this:

      <Publish Dialog="DataStoragePortConfig" Control="Back" Event="NewDialog" Value="CustomizeDlg">1</Publish>
  <Publish Dialog="DataStoragePortConfig" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

but on the next click I would like to make sure that the property DataStoragePort is not a empty string. Any suggestions? Regards Daniel

Upvotes: 3

Views: 2708

Answers (2)

Mike
Mike

Reputation: 1

I created VBS custom action to remove spaces.

 PropertyValue = Session.Property("PROPERTYNAME")
 PropertyValue = Replace(PropertyValue," ","") 
 Session.Property("PROPERTYNAME") = PropertyValue

I then added the action to the next button control on the dialog:
Publish Event="DoAction" Value="CA_RemoveSpaces">1"

The custom action:
CustomAction Id="CA_RemoveSpaces" BinaryKey='CustomActionsScript' Execute='immediate' Return='ignore' VBScriptCall="RemoveSpaces" Impersonate="no" />"

Upvotes: 0

Cosmin
Cosmin

Reputation: 21426

An empty masked edit control sets its property to the template string with spaces instead of "#" and "?". For example, if "Text" is set to "#####" the empty value is

"     "
If "Text" is set to "###-###" the empty value is
"   -   "

In your case you can use this condition:

DataStoragePort <> "     "

Upvotes: 2

Related Questions