Search code examples
installshieldinstallshield-2011

How to update dialog window from custom action


I have project with MSSQL perquisites. Until now sql was installing with hardcoded name of instance. Now I want to create functionality with customize this name by user during the installation process.

This is what I’ve done:

I created new dialog window with Edit control to get name of sql instance from user. When user click on “next” button than I going to start installation process (download sql installation from internet and starting silent installation). Because I want to put some feedback to user I should probably update some text control with eg “SQL is installing”. I tried to find the way how to update UI from my action but without success.

Here is my solution:

I’ve put Text control with empty Text property. In subscription tab (on this Text control) I’ve selected event ActionData and Attribute Text. In my action I tried to send a text like this:

hRecActionData = MsiCreateRecord(1);
 if( hRecActionData = NULL )then
   MessageBox( "Failed to create record.", SEVERE);
 endif;

 nRes = MsiRecordSetString( hRecActionData, 1,"Instaling SQL..." );
 if( nRes != ERROR_SUCCESS )then
  MessageBox( "SetString failed", SEVERE );
 endif;

 nRes = MsiProcessMessage( hMSI, INSTALLMESSAGE_ACTIONDATA, hRecActionData );
 if( nRes != ERROR_SUCCESS )then
  MessageBox( "ProcessMessage failed", SEVERE );
 endif;

Code was run without any errors but Text was not updated.

Is my way good or should I use other approach in my scenario? Why my code won’t works?


Solution

  • Assuming that your handle is correct, the issue is probably that the default UI handler can't find a control in your dialog called ActionText - it needs a control to display that data in, and that's the one it uses. It's not obvious to me that your record fits the format:

    http://msdn.microsoft.com/en-us/library/aa371614(v=vs.85).aspx

    Some older OS versions don't support calling MsiProcessMessage out of a control event, if your code call is from a DoAction event.

    Other than that, it occurs to me that you don't actually need any code if you're not going to supply any other info. You can just have an ActionText event on your Next button that sends that text to the ActionText control on the dialog.

    Either way, there's a lot of internal wiring in all this that involves the EventMapping table, and I don't know exactly how you tell InstallShield to handle a control subscribing to an event, because you need your control in your dialog to respond to ActionText and data messages.