通过IHTMLSelectionObject,如何得到当前选中的元素的属性以及id。
IHTMLDocument2::get_selection(IHTMLSelectionObject**)函数可以获得HTML文件当前选定的对象的指针,但不知如何得到对象的名称(ID)及属性?
例如:
IHTMLDocument2* ih;
IHTMLSelectionObject* io;
GetDHtmlDocument(&ih);
LPOLESTR str;
ih->get_selection(&io);
io->get_type(&str);
这时str包含了当前选定的对象的类型,但不知如何得到对象的名称(ID)及属性?
采用:
IHTMLElement* pElem;
io->QueryInterface(IID_IHTMLElement,(void**)&pElem);
或者采用:
io->Invoke(0,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&di,&va,&ex,&ui);
无法返回正确性值.
请问如何处理?
还有一个小问题,IHTMLElement能不能得到自己的父对象?