From: Homer J Simpson on

"Ken Tucker [MVP]" <KenTuckerMVP(a)discussions.microsoft.com> wrote in message
news:6B851C22-749D-4783-A4F0-3E0B762C6DD1(a)microsoft.com...

> Hi,
>
> I tested it with the msdn home page and it worked. I did not
> try
> this with a flash site so I do not know how this will work with flash.
> Are
> you sure the document completed loading before you got the bitmap. The
> webbrowser has a documentcompleted event you should get the image then.

The only thing I've been able to do with flash is, if it supports printing,
print to PrimoPDF.



From: dgk on
On Sun, 9 Apr 2006 06:25:02 -0700, Ken Tucker [MVP]
<KenTuckerMVP(a)discussions.microsoft.com> wrote:

>Hi,
>
> Did you try saving the documentstream?
>
>Ken
>------------------
>
>"dgk" wrote:
>

Not until you mentioned it, but it works the same as DocumentText; no
images are saved.
From: dgk on
On Sat, 08 Apr 2006 21:46:39 GMT, "Homer J Simpson"
<nobody(a)nowhere.com> wrote:

>
>"dgk" <NoWhere(a)MailsAnonymous.com> wrote in message
>news:7l6g32hn31ekj4v91n7rsgqioe657ko1h0(a)4ax.com...
>
>> I know it can be done. Snagit does it, printscreen does it without any
>> granularity, so I can do it. I just need to figure out how to write a
>> function that takes a webbrowser as a parameter and returns a bitmap.
>> That sounds easy. I figured that it would take ten minutes and I've
>> been working on it on and off for three weeks.
>
>Have you looked at something like "Programming Windows with C#" by Charles
>Petzold or one of his similar books? Maybe even one for Win95/98 etc? I
>suspect you MAY be in that territory.
>
>
I fear so. I think that I might have to dust off an Appleman book that
I thought was safely locked away.
From: dgk on
On Sun, 9 Apr 2006 06:21:01 -0700, Ken Tucker [MVP]
<KenTuckerMVP(a)discussions.microsoft.com> wrote:

>Hi,
>
> I tested it with the msdn home page and it worked. I did not try
>this with a flash site so I do not know how this will work with flash. Are
>you sure the document completed loading before you got the bitmap. The
>webbrowser has a documentcompleted event you should get the image then.
>
>Ken
>----------------
>

Odd, I tried it with Google and it didn't work. I'm pretty sure the
site finished loading - I'm not keying off any WebBrowser event, I'm
doing it when the user presses a button on the form containing the
WebBrowser. I'll give it another chance when I get home.
From: BK on
This is something I found on the web a while back, I use it to print
screen shots from within my VB apps. It takes a window and converts it
to a bitmap image using BitBlt (as you mentioned above). It works
great for me and it seems like you could modify it for your purposes.
Hope this helps.

At the top of the form:

Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal hdcDest
As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal
nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr,
ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As
System.Int32) As Boolean
Private Const SRCCOPY As Integer = &HCC0020

Then, in the method where I want to print (modify this to save easily
enough), I have the following snippet:

' Copy the form's image into a bitmap.
m_PrintBitmap = GetFormImage()

' Make a PrintDocument and print.
m_PrintDocument = New PrintDocument
m_PrintDocument.Print()

And finally, the GetFormImage function (that does the heavy lifting) :

Private Function GetFormImage() As Bitmap
' Get this form's Graphics object.
Dim me_gr As Graphics = Me.CreateGraphics

' Make a Bitmap to hold the image.
Dim bm As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height,
me_gr)
Dim bm_gr As Graphics = me_gr.FromImage(bm)
Dim bm_hdc As IntPtr = bm_gr.GetHdc

' Get the form's hDC. We must do this after
' creating the new Bitmap, which uses me_gr.
Dim me_hdc As IntPtr = me_gr.GetHdc

' BitBlt the form's image onto the Bitmap.
BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, Me.ClientSize.Height,
_
me_hdc, 0, 0, SRCCOPY)
me_gr.ReleaseHdc(me_hdc)
bm_gr.ReleaseHdc(bm_hdc)

' Return the result.
Return bm
End Function

Bill