RyanWool
September 6th, 2007, 10:06 AM
Hi,
Now I have a problem with getting the IHTMLElement's position information
without webbrowser.
When I did this, I can get the right x value:
IHTMLDocument* pDoc;
spWebbrowser->get_Document(&pDoc);
pDoc->get_Body(&spBody);
spBody->get_offsetWidth(&x);
But when I load a string into a IHTMLDocument created by my self.
I got x=0. Code is below:
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
//put the code into SAFEARRAY and write it into document
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
bstr_t bsData = (LPCTSTR)csWholeFile;
hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = (BSTR)bsData;
hr = pDoc->write(psa);
hr = pDoc->close();
SafeArrayDestroy(psa);
CComPtr<MSHTML::IHTMLElement> spBody;
pDoc->get_body(&spBody);
long ox = 0;
long oy = 0;
if (spBody)
{
spBody->get_offsetHeight(&ox);
spBody->get_offsetWidth(&oy);
}
If I want to get the position information of some elements, must I put the page into one webbrowser and displayed them?
Can you help me out of this?
Is there any way to get the infor without really display them?
Thank you.
Now I have a problem with getting the IHTMLElement's position information
without webbrowser.
When I did this, I can get the right x value:
IHTMLDocument* pDoc;
spWebbrowser->get_Document(&pDoc);
pDoc->get_Body(&spBody);
spBody->get_offsetWidth(&x);
But when I load a string into a IHTMLDocument created by my self.
I got x=0. Code is below:
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
//put the code into SAFEARRAY and write it into document
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
bstr_t bsData = (LPCTSTR)csWholeFile;
hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = (BSTR)bsData;
hr = pDoc->write(psa);
hr = pDoc->close();
SafeArrayDestroy(psa);
CComPtr<MSHTML::IHTMLElement> spBody;
pDoc->get_body(&spBody);
long ox = 0;
long oy = 0;
if (spBody)
{
spBody->get_offsetHeight(&ox);
spBody->get_offsetWidth(&oy);
}
If I want to get the position information of some elements, must I put the page into one webbrowser and displayed them?
Can you help me out of this?
Is there any way to get the infor without really display them?
Thank you.