梁某人

发展才是硬道理

导航

控件设计时的属性页定位办法

控件设计时的属性页定位办法:
取得IHtmlDocument3 就随心所欲了。

public LabelComponentEditorForm(ComponentEditorLabel designComponent)
        
{
            
this.designComponent = designComponent;
            
            
int innerLeft = Convert.ToInt32(designComponent.Style["clientX"]);
            
int innerTop = Convert.ToInt32(designComponent.Style["clientY"]);

            IDesignerHost host 
= (IDesignerHost) designComponent.Site.GetService(typeof (IDesignerHost));
            ControlDesigner labelDesigner 
= (ControlDesigner) host.GetDesigner(designComponent);
            
object parent = labelDesigner.Behavior.GetAttribute("document"false);
            IHTMLDocument2 doc 
= (IHTMLDocument2) parent;
            mshtml.IHTMLWindow3 window 
= (IHTMLWindow3) doc.parentWindow;
            
int screenLeft = window.screenLeft;
            
int screenTop = window.screenTop;
            
            
this.Location = new Point(screenLeft + innerLeft, screenTop + innerTop);

            
//
            
// Windows 窗体设计器支持所必需的
            
//
            InitializeComponent();

            
//
            
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            
//
        }

效果如下:

posted on 2006-04-26 20:51  涛仔28  阅读(296)  评论(0编辑  收藏  举报