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;
           }

  • 相关阅读:
    CF D. Ehab and the Expected XOR Problem 贪心+位运算
    luogu 1903 [国家集训队]数颜色 / 维护队列 带修改莫队
    Test 1 T2 B 线段树合并
    CF812C Sagheer and Nubian Market 二分+贪心
    CF804B Minimum number of steps
    CF796D Police Stations BFS+染色
    CF796C Bank Hacking 细节
    k8s节点NotReady问题处理
    Elastic-Job快速入门
    Elastic-Job介绍
  • 原文地址:https://www.cnblogs.com/MysticBoy/p/1507877.html
Copyright © 2011-2022 走看看