/// <summary> /// Displays a Visual Studio message box. /// </summary> /// <param name="title">Title of the message</param> /// <param name="message">Message text</param> /// <param name="helpFile">Help file name</param> /// <param name="helpTopic">Help topic identifier</param> /// <param name="buttons">Buttons to show on the message box</param> /// <param name="defButton">Default message box button.</param> /// <param name="icon">Icon to display in the message box.</param> /// <param name="sysAlert">MB_SYSTEMMODAL flag</param> /// <returns> /// MessageBox result converted to DialogResult. /// </returns> private static VsxDialogResult ShowInternal(string title, string message, string helpFile, uint helpTopic, MessageBoxButton buttons, int defButton, VsxMessageBoxIcon icon, bool sysAlert) { var clsid = Guid.Empty; ErrorHandler.ThrowOnFailure(UiShell.ShowMessageBox( 0, ref clsid, title, message, helpFile, helpTopic, VsxConverter.ConvertToOleMsgButton(buttons), VsxConverter.ConvertToOleMsgDefButton(defButton), VsxConverter.ConvertToOleMsgIcon(icon), sysAlert ? 1 : 0, out var result)); return(VsxConverter.Win32ResultToDialogResult(result)); }
/// <summary> /// Converts <see cref="VsxMessageBoxIcon"/> values to corresponding /// <see cref="OLEMSGICON"/> values. /// </summary> /// <param name="icon">MessageBoxIcon value to convert</param> /// <returns> /// OLEMSGICON representation of the MessageBoxIcon input. /// </returns> public static OLEMSGICON ConvertToOleMsgIcon(VsxMessageBoxIcon icon) { switch (icon) { case VsxMessageBoxIcon.Asterisk: case VsxMessageBoxIcon.Information: return(OLEMSGICON.OLEMSGICON_INFO); case VsxMessageBoxIcon.Error: return(OLEMSGICON.OLEMSGICON_CRITICAL); case VsxMessageBoxIcon.Exclamation: return(OLEMSGICON.OLEMSGICON_WARNING); case VsxMessageBoxIcon.Question: return(OLEMSGICON.OLEMSGICON_QUERY); default: return(OLEMSGICON.OLEMSGICON_NOICON); } }
/// <summary> /// Displays a Visual Studio message box. /// </summary> /// <param name="title">Title of the message</param> /// <param name="text">Message text</param> /// <param name="buttons">Buttons to show on the message box</param> /// <param name="defaultButton">Default message box button.</param> /// <param name="icon">Icon to display in the message box.</param> /// <returns> /// Result of the MessageBox. /// </returns> public static VsxDialogResult Show(string text, string title, MessageBoxButton buttons, VsxMessageBoxIcon icon, int defaultButton) { return(ShowInternal(title, text, string.Empty, 0, buttons, defaultButton, icon, false)); }