Search code examples
c++wixwindows-installer

How to programmatically go to the next screen in the MSI installer from a custom action?


I have a WiX custom dialog ConfigDlg with my own controls in it:

  <Fragment>    
    <UI Id="My_WixUI_Mondo">

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

    </UI>
  </Fragment>

I need to program the Next button to check what user entered in my ConfigDlg and disallow the "Next" screen if such check fails. So I changed my XML to call my idCA_NextBtn custom action as such:

  <Fragment>    
    <UI Id="My_WixUI_Mondo">

      <Publish Dialog="ConfigDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg">1</Publish>
      <Publish Dialog="ConfigDlg" Control="Next" Event="DoAction" Value="idCA_NextBtn">1</Publish>

    </UI>
  </Fragment>

where:

<Binary Id="caBinDll" SourceFile="$(var.SourceFldrBld)ca_Installer.dll" />
<CustomAction Id="idCA_NextBtn" Execute="immediate" BinaryKey="caBinDll" DllEntry="caNextButton" Return="check" />

My caNextButton function in the custom action DLL gets called, but I'm not sure how to advance to the next screen (or VerifyReadyDlg) from it:

extern "C" UINT APIENTRY caNextButton(MSIHANDLE hInstall)
{
    return ERROR_SUCCESS;
}

Or to simulate?

  <Publish Dialog="ConfigDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

Solution

  • Controls can have multiple ControlEvents (publish elements) and they are processed in order. What you do is have the custom action called first and have it set a SomeProperty to null or 1 then have two mutually exclusive events.

    publish DoAction CustomActionName Condition 1 (true/always)

    publish SpawnDialog CustomBrandedMessageBoxDialog Condition Not SomeProperty

    publish NewDialog VerifyReadyDlgCondition SomeProperty