This is the context:
//Form
//Popup modal Form
//Messagebox
The MessageBox
code:
DialogResult oResult = AppMessageBox.Show(this, "Replace the existing codes?",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
The AppMessageBox
class is nothing special:
public class AppMessageBox
{
private static String _strName;
private static String strName
{
get
{
if (_strName == null)
{
_strName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
}
return _strName;
}
}
public static DialogResult Show(String strMessage, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information)
{
return MessageBox.Show(strMessage, strName, buttons, icon);
}
public static DialogResult Show(IWin32Window hWndOwner, String strMessage, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information)
{
return MessageBox.Show(hWndOwner, strMessage, strName, buttons, icon);
}
}
The code displaying the message box is called from the form's button handler. Yet, it is displaying central to the screen and not central to the inner form. Why?
I thought that if I passed "this" it would center it to the current form.