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

Custom action (Managed DLL), is it possible show MessageBox as modal dialog ?

Hi, everyone.

I created a simple project. To the section custom action I added managed dll, inside this dll I call "MessageBox"



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClassLibrary1
{
public class Class1
{
string message;
string param;
public Class1()
{
message = "Test";
}

public string getMessage(string param)
{
this.param = param;
MessageBox.Show("message " + message + "param " + param);
return message;
}

public void getMessage2(string param)
{
MessageBox.Show("message " + message + "param " + param);
}

}
}



But, when I install this package my Message Box appears in the toolbar. Please, check the attachments.

Does it exist the way to show it on the screen?
Labels (1)
0 Kudos
1 Reply
joshstechnij
Pilgrim

Re: Custom action (Managed DLL), is it possible show MessageBox as modal dialog ?

For a message box to parent to a window correctly, it needs a handle to the window that should be its parent. However, Windows Installer does not provide a handle to the window for the running installation. You can try to find the window with FindWindow, but this becomes quite difficult when the basic UI is displayed by MSI (the window then has a generic dialog class making it very possible that the wrong window will be found).

An alternate method of displaying a message is available through the MsiProcessMessage API when specifying the INSTALLMESSAGE_USER message type (the type can be OR'ed with message box flag values such as MB_OK). This will allow for displaying a message through MSI which eliminates the need to worry about what window to parent to. One thing to note, though, is that MsiProcessMessage will not display any messages when the installation is running silently.
0 Kudos