cancel
Showing results for 
Search instead for 
Did you mean: 
alanrickman
Pilgrim

Help setting a property from a custom dialog (Installscript MSI)

Hi there,

I've created a custom dialog which all seems to work as expected however i've now hit a bit of wall.

What I want to do is take the values the user enters into an edit box and sets a property equal to the value entered. Am I right in thinking that this should be done using MsiSetProperty?

I've attached the code im using for the custom dialog, any help would be greatly appreciated.

Cheers,
Alan

#define EDIT1 1309
#define EDIT2 1310

prototype NUMBER CustomDialog();

function NUMBER CustomDialog()
NUMBER nReturn, nCtrl;
BOOL bDone;
STRING svEdit1, svEdit2;
begin

EzDefineDialog(
"Custom",
ISUSER,
"Custom",
NULL);

// call waitondialog until an event occurs.
while (!bDone)

//wait for interaction with a control
nCtrl = WaitOnDialog("Custom");

//switch statements handles the various controls on the dialog
switch (nCtrl)

case SD_PBUT_OK:
//next button clicked
CtrlGetText ("Custom", EDIT1, svEdit1);
CtrlGetText ("Custom", EDIT2, svEdit2);
nReturn = SD_PBUT_OK;
bDone = TRUE;

case SD_PBUT_BACK:
//back button clicked
nReturn = SD_PBUT_BACK;
bDone = TRUE;

case SD_PBUT_CANCEL:
//cancel button clicked
Do(EXIT);
bDone = TRUE;

endswitch;

endwhile;

EndDialog("Custom");
ReleaseDialog("Custom");

if nCtrl = SD_PBUT_OK then
//Just a test....
MessageBox (svEdit1 + "\n" + svEdit2, INFORMATION);

//If dialog closed with next button, set installer properties based on user responses.
MsiSetProperty(hMSI, "PropertyName1", svEdit1);
MsiSetProperty(hMSI, "PropertyName2", svEdit2);

endif;

return nReturn;

end;
Labels (1)
0 Kudos
3 Replies
Highlighted
Flexera MichaelU
Flexera

Re: Help setting a property from a custom dialog (Installscript MSI)

The calls to MsiSetProperty look reasonable, except the properties should probably be public (all upper-case) I don't know where your hMSI is coming from. In general, however, rather than directly changing properties as part of the dialog code, the suggested InstallScript style tends to favor returning the values in byref parameters, and allowing the code that invoked the dialog to store the properties. This is more flexible, but arguably more work at each call site.

This would look something like the following in e.g. OnFirstUIBefore (pardon any syntax errors):
Dlg_Mine:
nResult = MyDialogHere(szTitle, szMsg, szRet1, szRet2);
if (nResult = BACK) goto Dlg_Prev;
endif;
MsiSetProperty(ISMSI_HANDLE, "PROP1", szRet1);
MsiSetProperty(ISMSI_HANDLE, "PROP2", szRet2);
Dlg_Next:
0 Kudos
Not applicable

Re: Help setting a property from a custom dialog (Installscript MSI)

What's the actual issue you're encountering? The code by itself looks ok, but I'm just kinda wondering what you're getting at.
0 Kudos
alanrickman
Pilgrim

Re: Help setting a property from a custom dialog (Installscript MSI)

The problem I was encountering was that the project would not build due to me using hMSI (I'm not too sure where I got this from either...) rather than using ISMSI_HANDLE in the call to MsiSetProperty.

Thanks for the general advice about changing properties, I shall move the code to change properties out of the code for the dialog box.

For the time being I have changed my code within the dialog and the properties are being set as expected, thanks very much! :)
0 Kudos