I'm working with MSHTML API lately, and I find it very inconvenient. I'm more used to WinAPI then COM programming, so maybe it's just me, but consider the following example of querying the rectangle of an element;
Expectations:
RECT rc;
hr = element2->GetElementRect(&rc);
Reality:
CComPtr<IHTMLRect> rect;
hr = element2->getBoundingClientRect(&rect);
if(FAILED(hr))
return hr;
if(!rect)
return E_FAIL;
long left, right, top, bottom;
hr = rect->get_left(&left);
if(FAILED(hr))
return hr;
hr = rect->get_right(&right);
if(FAILED(hr))
return hr;
hr = rect->get_top(&top);
if(FAILED(hr))
return hr;
hr = rect->get_bottom(&bottom);
if(FAILED(hr))
return hr;
Am I missing something?
My question: are there any wrappers for this API? Surely, smart pointers such as CComPtr
make things much easier, but still, I feel like struggling with the API.