【发布时间】:2015-05-17 11:45:47
【问题描述】:
基本上,在我的代码中,我将表单转换为加载事件中的工具窗口:
Dim lStyleEx As Long = win32.WS._EX_TOOLWINDOW
Call SetWindowLong(Handle, win32.GWL.__EXSTYLE, CInt(lStyleEx))
Const swpFlags As Long = _
win32.SWP._FRAMECHANGED Or _
win32.SWP._NOMOVE Or _
win32.SWP._NOSIZE Or _
win32.SWP._NOZORDER
Call SetWindowPos(Handle, CType(0, IntPtr), 0, 0, 0, 0, CType(swpFlags, win32.SetWindowPosFlags))
(我有一个包含所有常量枚举的类 win32)
现在,我想使用 IVsWindowFrame.Show() 将此工具窗口置于最前面,但我无法为我的表单获取实际的 IVsWindowFrame。在网上搜索后,我在 MSDN 论坛上找到了一个 sn-p,但在转换为 VBA 之后出现了各种问题,例如我不知道如何正确创建一个新的 ServiceProvider:
Dim shell As IVsUIShell = DirectCast(ServiceProvider.GetService(GetType(SVsUIShell)), IVsUIShell)
Dim frame As IVsWindowFrame
Dim guid As New Guid(ToolWindow.GuidList.guidToolWindowPersistanceString)
shell.FindToolWindow(CUInt(__VSFINDTOOLWIN.FTW_fForceCreate), guid, frame)
frame.Show()
任何有关查找表单的 IVsUIShell 的帮助或对此代码的解释将不胜感激!
我还尝试了一些简单的方法,例如将实际表单设置为 IVsWindowFrame:
Dim windowFrame As IVsWindowFrame = CType(Me, IVsWindowFrame)
windowFrame.Show()
但它会抛出异常:
type 'RifleSystem.scrSettings' to type 'Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame'.
顺便说一句,如果有帮助,我正在运行 64 位 VS2013。
【问题讨论】: