Scrollheight Not Accurate



I am hosting a webbrowser ctrl and using the below code to render to a bitmap. For a large page we normally resize the wndow, then call Draw. However for an iframe (sample at http://www.howudodat.com/frame.html) the scrollHeight is being returned incorrectly. Any ideas?

Peter
CImage * CWndBrowser::GetAsBmp()
{
CRect r; GetClientRect(r);
CImage *img = NULL;

IHTMLDocument2 *document = GetDoc();
if (document) {
CComPtr<IHTMLElement> Element;
document->get_body(&Element);
CComQIPtr<IHTMLElement2> Element2(Element);
long h, w;
if (Element2 != NULL) {
Element2->get_scrollHeight(&h);
Element2->get_scrollWidth(&w);
h+= 25; w+= 25;
}
ResizeClient(w,h);

CComQIPtr<IViewObject2>View(document);
if (View != NULL) {
img = new CImage;
img->Create(w, h, 24);
CDCHandle dc (img->GetDC());
dc.FillSolidRect(0,0,w,h,RGB(255,255,255));
RECTL r = {0,0,w, h};
View->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, dc, &r, NULL, NULL, NULL);
}
document->Release();
}
ResizeClient(r.Width(), r.Height());
return img;
}
.



Relevant Pages

  • Re: Wo sieht man den Typ des Steuerelementes?
    ... CImage sondern auch in einem Array ablegen. ... GetWindowRect(handle, windowRect); ... // create a bitmap we can copy it to, ... HBITMAP hBitmap = CreateCompatibleBitmap; ...
    (microsoft.public.de.vc)
  • Re: save DC as bitmap to file
    ... You can attach the bitmap handle to a CImage object and call it's Save ... Then bitblt the content of the DC on to the screen dc (CPaintDC). ...
    (microsoft.public.vc.mfc)
  • Re: Combining CImages into one big one?
    ... CImage objects into that DC just as you did in OnPaint. ... HBITMAP, so probably you can't create a bitmap of the size you want. ... > I've got a program that draws a map in the client window. ... > them in the OnPaint function. ...
    (microsoft.public.vc.mfc)

Loading