Prev: converting ansi to utf8 format - is there anything wrong with it ? urgently requires help
From: Homer J Simpson on 9 Apr 2006 14:42
"Ken Tucker [MVP]" <KenTuckerMVP(a)discussions.microsoft.com> wrote in message
> I tested it with the msdn home page and it worked. I did not
> this with a flash site so I do not know how this will work with flash.
> 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 9 Apr 2006 16:51
On Sun, 9 Apr 2006 06:25:02 -0700, Ken Tucker [MVP]
> Did you try saving the documentstream?
Not until you mentioned it, but it works the same as DocumentText; no
images are saved.
From: dgk on 9 Apr 2006 16:53
On Sat, 08 Apr 2006 21:46:39 GMT, "Homer J Simpson"
>"dgk" <NoWhere(a)MailsAnonymous.com> wrote in message
>> 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 10 Apr 2006 12:51
On Sun, 9 Apr 2006 06:21:01 -0700, Ken Tucker [MVP]
> 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.
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 10 Apr 2006 13:56
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
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,
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)
' Return the result.