本文整理汇总了C#中Microsoft.Office.Interop.Visio.SetWindowRect方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Visio.SetWindowRect方法的具体用法?C# Microsoft.Office.Interop.Visio.SetWindowRect怎么用?C# Microsoft.Office.Interop.Visio.SetWindowRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Visio
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Visio.SetWindowRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachWindowsForm
/// <summary>
/// Allows a windows form to be used as the UI for an anchor window
/// </summary>
public static void AttachWindowsForm(
IVisio.Window anchor_window,
System.Windows.Forms.Form the_form)
{
if (anchor_window == null)
{
throw new System.ArgumentNullException(nameof(anchor_window));
}
if (the_form == null)
{
throw new System.ArgumentNullException(nameof(the_form));
}
// Show the form as a modeless dialog.
the_form.Show();
// Get the window handle of the form.
int hwnd = the_form.Handle.ToInt32();
var hwnd_as_intptr = new System.IntPtr(hwnd);
// Set the window properties to make it a visible child window.
const int window_prop_index = Internal.Interop.NativeMethods.GWL_STYLE;
const int window_prop_value = Internal.Interop.NativeMethods.WS_CHILD | Internal.Interop.NativeMethods.WS_VISIBLE;
Internal.Interop.NativeMethods.SetWindowLong(hwnd_as_intptr, window_prop_index, window_prop_value);
// Set the anchor bar window as the parent of the form.
Internal.Interop.NativeMethods.SetParent(hwnd, anchor_window.WindowHandle32);
// Force a resize of the anchor bar so it will refresh.
int left, top, width, height;
anchor_window.GetWindowRect(out left, out top, out width, out height);
anchor_window.SetWindowRect(left, top, width - 1, height - 1);
anchor_window.SetWindowRect(left, top, width, height);
// Set the dock property of the form to fill, so that the form
// automatically resizes to the size of the anchor bar.
the_form.Dock = System.Windows.Forms.DockStyle.Fill;
// had to set to false to prevent a resizing problem (it was originally set to true)
the_form.AutoSize = true;
}