MessageBoxes using DTF
Asked Answered
O

1

3

The MsiProcessMessage function doco on MSDN shows this example:

PMSIHANDLE hInstall;
PMSIHANDLE hRec;
MsiProcessMessage(hInstall, 
                  INSTALLMESSAGE(INSTALLMESSAGE_ERROR|MB_ABORTRETRYIGNORE|MB_ICONWARNING),
                  hRec);

How would this be done using Session.Message in DTF? The only overload takes Session.InstallMessage as an argument. I see the MessageBoxButtons enum and I convert both types to In32 and perform a logical or but I'm not sure how to get this back into the API.

Am I missing something or is DTF missing something?

Onetime answered 20/4, 2013 at 19:15 Comment(0)
B
3

I've not done much with DTF but my understanding is that you'd want something like:

Session.Message(InstallMessage.Error | 
                (InstallMessage)((int)MessageButtons.AbortRetryIgnore |
                                 (int)MessageIcon.Warning), 
                record);

Not very pretty. I've formatted the messageType agument to fit better in the text box here. Format in your code as per your coding guidelines. :)

Barta answered 20/4, 2013 at 23:5 Comment(4)
Thanks Rob, it works fine except I'm sure you meant MessageButtons and MessageIcon instead of MessageBoxButtons and MessageBoxIcon. It didn't seem like I'd be able to cast these types back to an InstallMessage type.Onetime
I don't see MessageButtons or MessageIcon defined as enums anywhere. The code above should work when the System.Windows.Forms namespace is included.Barta
MessageButtons and MessageIcons are defined in Microsoft.Deployment.WindowsInstaller. It's in the DTF help file. The help topic says it can be cast to MessageBoxButtons. It should probably also say it can be cast to InstallMessage.Onetime
Ahh, yes, they are duplicated there. It's all duplication and will work the same. However, I'll update the answer because they are better option so you don't have to pull in System.Windows.Forms.Barta

© 2022 - 2024 — McMap. All rights reserved.