本文整理汇总了C#中IWin32Window.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IWin32Window.GetType方法的具体用法?C# IWin32Window.GetType怎么用?C# IWin32Window.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWin32Window
的用法示例。
在下文中一共展示了IWin32Window.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowMessageBox
/// <summary>
/// Shows a MessageBox properly linked to the given Win32Window owner.
/// </summary>
/// <param name="owner">The System.Windows.Forms.IWin32Window object who will act as this message box's parent.</param>
/// <param name="msg">A System.String value to display as a message on this message box.</param>
/// <param name="caption">A System.String value to display in the title bar of this message box.</param>
/// <param name="btns">A System.Windows.Forms.MessageBoxButtons value specifying what buttons are displayed on the message box.</param>
/// <param name="icon">A System.Windows.Forms.MessageBoxIcon value specifying what icon is displayed on the message box.</param>
/// <param name="defBtn">A System.Windows.Forms.MessageBoxDefaultButton value specifying which of the message box's buttons should be activated if the user presses the "Enter" key.</param>
public static void ShowMessageBox(IWin32Window owner, string msg, string caption, MessageBoxButtons btns, MessageBoxIcon icon, MessageBoxDefaultButton defBtn)
{
Type ownerType = owner.GetType();
PropertyInfo invokeProp = ownerType.GetProperty("InvokeRequired");
bool invokeReq = false;
if (invokeProp != null)
invokeReq = Convert.ToBoolean(invokeProp.GetValue(owner, null));
if (invokeProp == null || !invokeReq)
{
MessageBox.Show(owner, msg, caption, btns, icon, defBtn);
}
else
{
MethodInfo beginInvokeMeth = ownerType.GetMethod(((CrossThreadUI.ExecSync) ? "Invoke" : "BeginInvoke"), new Type[] { typeof(Delegate), typeof(Object[]) });
if (beginInvokeMeth != null)
{
ShowMessageBoxDelegate del = new ShowMessageBoxDelegate(CrossThreadUI.ShowMessageBox);
beginInvokeMeth.Invoke(owner, new object[] { del, new object[] { owner, msg, caption, btns, icon, defBtn } });
}
}
}