Visual Studio 2008 Beta2中的Class Designer终于支持C++了,上面是一个MFC程序的类图,可以看到已经支持扩展MFC的宏了,可惜只能看不能重构代码。尽管Class Designer这功能相当不错,但是设计师们可能还是更习惯IBM 的Rational Rose Developer for Visual Studio和UML。我用Class Designer的C#支持的时候也就是加加注释而已,重构我更习惯用DevExpress提供的工具Refactor来做,类则用XSD.exe生成,因为Class Designer生成的属性只会扔NotImplementedException异常。
Visual C++项目组在做下一个版本的市场调查,有兴趣的可以去提提要求。
打印 | 张贴于 2007-07-29 00:00:00 | Tag:暂无标签

留言反馈
BOOL CElementFinder::FindElement(IWebBrowser2* pApp, CPoint pt)
{
if(pApp == NULL)
return FALSE;
CComPtr<IDispatch> cpDispDocument;
CComQIPtr<IHTMLDocument2> cpDocument2;
pApp->get_Document(&cpDispDocument);
cpDocument2 = cpDispDocument;
if(cpDocument2 == NULL)
return FALSE;
CComPtr<IHTMLElement> cpElem;
cpDocument2->elementFromPoint(pt.x, pt.y, &cpElem);
if(cpElem == NULL)
return FALSE;
CComBSTR bstrTagName;
cpElem->get_tagName(&bstrTagName);
CString strTagName(bstrTagName);
if(strTagName == _T("FRAME") || strTagName == _T("IFRAME"))
{
CString strFrameFind;
// Offset client point to frame local point
CPoint ptLocal = pt;
//-----------------------------------------------------------------------------------
// document.body.scrollTop or scrollLeft doesn't work in IE7,
// so we should replace it with document.documentElement.scrollTop or scrollLeft.
// It means that we should use IHTMLDocuemnt3::get_documentElement::scrollTop
//-----------------------------------------------------------------------------------
CComQIPtr<IHTMLDocument3> cpDocument3 = cpDocument2;
CComPtr<IHTMLElement> cpDocumentElem;
CComQIPtr<IHTMLElement2>cpDocumentElem2;
cpDocument3->get_documentElement(&cpDocumentElem);
cpDocumentElem2 = cpDocumentElem;
long xScr = 0, yScr = 0;
cpDocumentElem2->get_scrollLeft(&xScr);
cpDocumentElem2->get_scrollTop(&yScr);
ptLocal.Offset(xScr, yScr);
CComPtr<IHTMLElement> cpChildElem = cpElem;
while(1)
{
long x = 0, y = 0;
cpChildElem->get_offsetTop(&y);
cpChildElem->get_offsetLeft(&x);
ptLocal.x -= x;
ptLocal.y -= y;
CComPtr<IHTMLElement> cpParentElem;
cpChildElem->get_offsetParent(&cpParentElem);
if(cpParentElem == NULL)
break;
cpChildElem = cpParentElem;
}
//----------------------------------------------------
// Find the children-element of the frame recursively.
//----------------------------------------------------
CString strChildFind;
if(!FindElement(CComQIPtr<IWebBrowser2>(cpElem), ptLocal))
return FALSE;
}
else
{
m_cpResult = cpElem;
}
return TRUE;
}
我是Michael, 有一个很奇怪的webbrowser control hosting问题需要请教你,因为没有你的email,所以只能留在这里了,请你原谅,希望你能看到。
我用的是CHtmlView(经过了一些bug的修改),需要根据左键点击的坐标来取得网页上的Element,当然也包括包含frame和iframe的网页,我用到了get_offsetLeft get_offsetTop get_offsetParent等方法来调整坐标到frame的client,这个方法在很多网站都工作的很好,都能够正确的取得嵌套的frame里的element,但奇怪的是,有些网站就不行了。在这些网站上,get_offsetTop get_offsetParent总是返回0,导致最终取得的element不正确。我研究了很久,一直没有找到问题所在,希望得到你的帮助。
能够正常工作的网页例如:
http://www.w3schools.com/tags/tag_iframe.asp
http://images.google.com/xxx
不能正常工作的网页例如:
http://msdn2.microsoft.com/en-us/library/aa752286.aspx
在上边MSDN的网页上,我想取得左边TREE-VIEW里边的所有链接的URL。但很奇怪,左键点击的坐标经过调整并没有发生任何改变,导致最终取得的element不是最初点击的那个,而是在它下面一段距离的一个element,这段距离和明显是iframe和主框架页面之间的offset,比如我点<A>onclick</A>但最后得到确实它下边的<A>offsetHeight</A>。 很奇怪,不知道为什么,希望得到你的帮助,谢谢。
btw: 我用的是vs2003 和 ie7
Michael
hanfeifei@gmail.com
谢谢你