'宣言 Public Overloads Shared Function Show( _ ByVal owner As IWin32Window, _ ByVal text As String, _ ByVal caption As String, _ ByVal buttons As MessageBoxButtons _ ) As DialogResult
public static DialogResult Show( IWin32Window owner, string text, string caption, MessageBoxButtons buttons )
Private Sub DisplayMessage(ByVal owner As IWin32Window, ByVal message As String, ByVal caption As String, ByVal buttons As MessageBoxButtons) ' If the owner is not set or the owner if the current form and it is a MDI Child, ' use the overload with the IWin32Window owner If owner IsNot Nothing Then Dim ownerForm As Form = TryCast(Form.FromHandle(owner.Handle), Form) If ownerForm IsNot Nothing AndAlso ownerForm.IsMdiChild = True Then UltraMessageBoxManager.Show(message, caption, buttons) Else UltraMessageBoxManager.Show(owner, message, caption, buttons) End If Exit Sub End If UltraMessageBoxManager.Show(message, caption, buttons) End Sub
private void DisplayMessage(IWin32Window owner, string message, string caption, MessageBoxButtons buttons) { // If the owner is not set or the owner if the current form and it is a MDI Child, // use the overload with the IWin32Window owner if (owner != null) { Form ownerForm = Form.FromHandle(owner.Handle) as Form; if (ownerForm != null && ownerForm.IsMdiChild == true) UltraMessageBoxManager.Show(message, caption, buttons); else UltraMessageBoxManager.Show(owner, message, caption, buttons); return; } UltraMessageBoxManager.Show(message, caption, buttons); }