I try the two methods, but it doesn't give me entire satisfaction.
I really would like to reproduce behavior of DrawToBitmap for a
WebBrowser
Control...
How can I do that ?
"Prosperz" <
[email protected]> a écrit dans le message de
[email protected]...
More generally, is there an opensource control that made this
functionality ?
I found : websnapshot and dypswebcapture but you must paid to use
them.
Any tools ?
"Piotr Dobrowolski" <Piotr.Dobrowolski@_usun_gmail.com> a écrit dans
le
message de news: (e-mail address removed)...
Dnia 29-03-2006 o 20:32:46 Prosperz <
[email protected]>
napisal:
I never used WM_PRINT and I don't know how to use it. Can you be
more
precise ?
I would like to precise that I want to make a screenshot of an
entire
web
page even if only a part is visible in the WebBrowser...
Maybe I must not use WebBroser to do that.
"Piotr Dobrowolski" <Piotr.Dobrowolski@_usun_gmail.com> a écrit dans
le
message de news: (e-mail address removed)...
Dnia 29-03-2006 o 19:18:40 Prosperz <
[email protected]>
napisa³:
Hi,
I would like to make thumbnails of web page by capture content of
a
WebBrowser. By example, capture
http://www.google.com.
I used WebBrowser control with Framework 2.0.
I try this :
*************************************************
WebBrowser w = (WebBrowser)sender;
Rectangle rec = w.Bounds;
Bitmap bitm = new Bitmap(rec.Width, rec.Height);
w.BringToFront();
w.DrawToBitmap(bitm, rec);
picScreenshot.Image = bitm;
bitm.Save(@"c:\temp.jpg");
bitm.Dispose();
*************************************************
But it doesn't work (DrawToBimap seems to be not managed by the
WebBrowser
control).
How can I do to make these kind of thumbnails ?
[PD] Theoretically you can try to play with WM_PRINT or
WM_PRINTCLIENT
message (create HDC and send it as a param of a message an then
copy
it
to
the graphics). I have done that with some controls and it works,
unfortunately I don't have any sample code now. The second, much
simpler
but also a little bit less elegant idea is to do it this way:
destinationGraphics.CopyFromScreen(
webBrowser.PointToScreen(new Point(0, 0)),
new Point(0, 0), webBrowser.Size);
Of course your control must be fully visible - if any window will
cover
it
the capture will be corupt.
[PD] WM_PRINT is a windows message - you can send it to a window to
ask
it to draw it's contents on the provided device context (hdc). You
can
create hdc (i.e. by calling GetHdc of your Graphics class instance)
and
pass it as a parameter to SendMessage, so that window will draw on
your
graphics. Look hier for sample code (I have just found it so don't
know
if it works but looks ok):
http://tommycarlier.blogspot.com/2004/12/painting-control-onto-graphics-object.html
I'm not sure if this solution is good for your problem - probably
there
are better ways to do that - look at this article, it looks valuable:
http://www.developerfusion.co.uk/show/4712/