zoukankan      html  css  js  c++  java
  • VS2005中得到 Web页面 或 窗体的 IDesignerHost

    private IDesignerHost GetDesignerHost(Window window)
           {
               // In most instances, the IDesignerHost can be retrieved
               // directly off of the window object.
               IDesignerHost designerHost = window.Object as IDesignerHost;
               if (designerHost != null)
                   return designerHost;

               // webform designer though, is a special case
               HTMLWindow htmlWindow = window.Object as HTMLWindow;
               if (htmlWindow != null)
               {
                   // make sure current tab is the designer tab
                   htmlWindow.CurrentTab = vsHTMLTabs.vsHTMLTabsDesign ;
                   IOleServiceProvider oleSP = (IOleServiceProvider)htmlWindow.CurrentTabObject;
                   Microsoft.VisualWebDeveloper.Interop.WebDeveloperPage.DispDesignerDocument d = htmlWindow.CurrentTabObject as Microsoft.VisualWebDeveloper.Interop.WebDeveloperPage.DispDesignerDocument;
                   Guid guidVsMDDDesigner = new Guid("7494682A-37A0-11d2-A273-00C04F8EF4FF");
                   IntPtr ptr;
                   oleSP.QueryService(ref guidVsMDDDesigner, ref guidVsMDDDesigner, out ptr);
                   if (ptr != IntPtr.Zero)
                   {
                       IServiceProvider dotnetSP = (IServiceProvider)Marshal.GetObjectForIUnknown(ptr);
                       Marshal.Release(ptr);
                       designerHost = (IDesignerHost)dotnetSP.GetService(typeof(IDesignerHost));
                   }
               }
               return designerHost;
           }

  • 相关阅读:
    Python 标准库 BaseHTTPServer 中文翻译
    DBA Scripts
    cordova开发自己定义插件
    ASUS主板ALC887声卡,RTL81XX网卡,黑苹果驱动安装
    com.apple.installer.pagecontroller 错误 -1 pkg安装错误
    Apple 远程推送APNS 服务
    bitbucket git push 项目503失败
    在xcode5下利用Source Control 做 git 项目管理
    iOS设备定位服务开启判定
    has been modified since the precompiled header地图错误
  • 原文地址:https://www.cnblogs.com/MysticBoy/p/1507877.html
Copyright © 2011-2022 走看看