好的,我已经为Visio制作了一个VSTO,它使用AnchorBarAddon窗口。
创建窗口的代码如下:
if (parent == null || windowstates == null || Assigned) return false;
Window = null;
Window = parent.Windows.Add(
bstrCaption: Caption,
nFlags: windowstates,
nType: (object)Visio.VisWinTypes.visAnchorBarAddon,
nWidth: _content.Size.Width,
bstrMergeID: _guid,
bstrMergeClass: "",
nMergePosition: 0
);
int windowHandle = _content.Handle.ToInt32();
Win32.SetWindowLongW(windowHandle, Win32.GWL_STYLE, Win32.WS_CHILD | Win32.WS_VISIBLE);
Win32.SetParent(windowHandle, Window.WindowHandle32);
_content.Dock = DockStyle.Fill;
Window.GetWindowRect(out int left, out int top, out int width, out int height);
Window.SetWindowRect(left, top, width + addWidth, height + addHeight);