MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: TryMeAddVersionKeywordAndLaunchCondition.MM[Next]: TryMeCreate[START]OfMsiFromScratch.MM
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->MAKEMSI Installs...->Samples Installed by MAKEMSI->Samples - Build New MSI/MSM->TryMeConditionDialogs.MM

TryMeConditionDialogs.MM

This is one of the MAKEMSI samples which build a new MSI/MSM. This MSI makes use of these "TryMe.MM" files:

  1. TryMe.ver
  2. TryMe.rtf

This sample shows how you can create dialogs where the flow is based on conditions as the "Dialog" command creates unconditional links between dialogs.

;----------------------------------------------------------------------------
;    MODULE NAME:   TryMeConditionDialogs.MM
;
;        $Author:   USER "Dennis"  $
;      $Revision:   1.2  $
;          $Date:   05 Nov 2008 17:29:24  $
;       $Logfile:   C:/DBAREIS/Projects.PVCS/Win32/MakeMsi/TryMeConditionDialogs.MM.pvcs  $
;
; DESCRIPTION
; ~~~~~~~~~~~
; Unlike the "TryMeWithUserDialog.MM" example, this sample is only
; demonstrating conditional display of dialogs and implements this flow:
;
;
;                                                    +---[ DialogB1 ]---+
;                                              +<<<<<< Back             |
;                                              |  +>>|             Next >>>>>+
;                                              |  |  +------------------+    |
;  +--[ Licence ]--+     +---[ DialogA ]----+  |  |                     |    +--[ Setup ]--+
;  |               |<<<<<< Back             |<<+  |                     |    |             |
;  |               |     |                  |     |                     +<<<<< Back        |
;  |          Next >>>>>>|             Next >>>>>>+                     |    |             |
;  |               |     |                  |<<+  |                     |    |             |
;  +---------------+     +------------------+  |  |                     |    +-------------+
;                                              |  +>>+---[ DialogB2 ]---+    |
;                                              |     |             Next >>>>>+
;                                              +<<<<<< Back             |
;                                                    +------------------+
;
;
; As you can see from the above we want to insert 2 new dialogs, the first
; dialog (DialogA) is always displayed and then we wish to follow that with
; either "DialogB1" or "DialogB2".
;
; This example aims to be generic and so it is more complex than any specific
; solution needs to be.  For example it handles conditional forwards dialog
; transition although the default msi wizard doesn't use it.  I could have hard
; coded the logic for the transition from "DialogA" to "DialogB" but decided
; to keep it generic and demonstrate how the existing values of the "Condition"
; and "Ordering" columns could be read and manipulated.
;----------------------------------------------------------------------------



;----------------------------------------------------------------------------
;--- Override some MAKEMSI options ------------------------------------------
;----------------------------------------------------------------------------
#define VER_FILENAME.VER                TryMe.Ver      ;;I only want one VER file for all samples!
#define UISAMPLE_DIALOGS_ID_IN_TITLE.D  Y              ;;In developer mode add dialogs ID to the titlebar


;----------------------------------------------------------------------------
;--- Include MAKEMSI support (with my customisations and MSI branding) ------
;----------------------------------------------------------------------------
#include "ME.MMH"


;----------------------------------------------------------------------------
;--- Create INSTALLDIR ------------------------------------------------------
;----------------------------------------------------------------------------
<$DirectoryTree Key="INSTALLDIR" Dir="c:\program files\TryMe (makemsi sample)\<$MAKEMSI_MM_BASENAME>" CHANGE="\" PrimaryFolder="Y">


;----------------------------------------------------------------------------
;--- Insert after which dialog? (I never have a "UserRegistrationDlg") ------
;----------------------------------------------------------------------------
#ifdef REMOVED_LicenseAgreementDlg          ;;Only exists if the dialog has been removed...
       #define InsertAfter  WelcomeDlg
#else
       #define InsertAfter  LicenseAgreementDlg
#endif
#define InsertBefore  SetupTypeDlg


;--------------------------------------------------------------------------------------
;--- The first dialog the user will see is UNCONDITIONAL, will decide 2nd user sees ---
;--------------------------------------------------------------------------------------
<$Dialog "DialogA - UNCONDITIONAL" INSERT="<$InsertAfter>-<$InsertBefore>" Dialog="DialogA">
    <$Property             "SOME" Value="1">
    <$DialogEntry Property="SOME" Label="&Show Dlg 1 or 2:"  ToolTip="1=Dialog B1, anything else Dialog B2" Max=10 Width=200>
<$/Dialog>


;-----------------------------------------------------------------------------------------
;--- The 2nd dialog the user will see is CONDITIONAL (based on "SOME" property's value ---
;-----------------------------------------------------------------------------------------
<$Dialog "DialogB1 - CONDITIONAL, got here because SOME = 1"  INSERT="!DialogA-<$InsertBefore>" Dialog="DialogB1">
<$/Dialog>
<$Dialog "DialogB2 - CONDITIONAL, got here because SOME <> 1" INSERT="!DialogA-<$InsertBefore>" Dialog="DialogB2">
<$/Dialog>


;----------------------------------------------------------------------------
;--- Now set up the conditional transitions ---------------------------------
;----------------------------------------------------------------------------
#define COND_USE_DIALOG_B1  SOME = 1
#define COND_USE_DIALOG_B2  not (<$COND_USE_DIALOG_B1>)     ;;Used "not" to be 100% sure conditions are mutually exclusive
<$Table "ControlEvent">
   ;--- Correct "Back" Link (on next dialog) first as easiest (will be unconditional) ---
   <$RowsDelete WHERE="`Dialog_` = '<$InsertBefore>' AND `Control_` = 'Back' AND `Event` = 'NewDialog'">
   #(
       <$Row Dialog_="<$InsertBefore>"  Control_="Back"  Event="NewDialog"
            Argument="DialogB1"
           Condition="<$COND_USE_DIALOG_B1>"
       >
   #)
   #(
       <$Row Dialog_="<$InsertBefore>"  Control_="Back"  Event="NewDialog"
            Argument="DialogB2"
           Condition="<$COND_USE_DIALOG_B2>"
       >
   #)


   ;--- Correct Next Link (on previous dialog, may have condition!) --------------------------
   dim CurrentNextDialogCondition : CurrentNextDialogCondition = ""
   dim CurrentNextDialogOrdering  : CurrentNextDialogOrdering  = ""
   <$Row @Where="`Dialog_` = 'DialogA' AND `Control_` = 'Next' AND `Event` = 'NewDialog'" @OK=^? > 0^ @Code="Y">
         ;--- Pick up the current values ------------------------------------
         CurrentNextDialogOrdering  = <$COLINT.ControlEvent.Ordering>
         CurrentNextDialogCondition = <$COLSTR.ControlEvent.Condition>

         ;--- If we picked up a condition, display+log it -------------------
         if CurrentNextDialogCondition <> "" and CurrentNextDialogCondition <> "1" then
            ;--- Wasn't unconditional (need to include as part of OUR condition! ---
            say "DIALOG '" & <$COLSTR.ControlEvent.Dialog_> & "' had condition : " & CurrentNextDialogCondition
         end if
   <$/Row>
   if CurrentNextDialogCondition = "" then
      CurrentNextDialogCondition = "1"              ;;Unconditional
   end if
   if CurrentNextDialogOrdering = "" then
      CurrentNextDialogOrdering = 9999             ;;Should be big enough...
   end if
   <$RowsDelete WHERE="`Dialog_` = 'DialogA' AND `Control_` = 'Next' AND `Event` = 'NewDialog'">
   dim NextCondition
   NextCondition = "<$COND_USE_DIALOG_B1 $$DQX2>"           'Need to double up quotes to produce valid VBS literal
   if CurrentNextDialogCondition <> "1" then
      NextCondition = "(" & CurrentNextDialogCondition & ") and (" & NextCondition & ")"
   end if
   #(
       <$Row Dialog_="DialogA"  Control_="Next"  Event="NewDialog"
            Argument="DialogB1"
          *Condition="NextCondition"
           *Ordering="CurrentNextDialogOrdering"
       >
   #)
   NextCondition = "<$COND_USE_DIALOG_B2 $$DQX2>"           'Need to double up quotes to produce valid VBS literal
   if CurrentNextDialogCondition <> "1" then
      NextCondition = "(" & CurrentNextDialogCondition & ") and (" & NextCondition & ")"
   end if
   #(
       <$Row Dialog_="DialogA"  Control_="Next"  Event="NewDialog"
            Argument="DialogB2"
           *Condition="NextCondition"
            *Ordering="CurrentNextDialogOrdering"
       >
   #)
<$/Table>


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: TryMeAddVersionKeywordAndLaunchCondition.MM[Next]: TryMeCreate[START]OfMsiFromScratch.MM


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.