Click to See Complete Forum and Search --> : How can I make a screenshot?????
Neon
Jun 7th, 2000, 12:48 AM
How can I make a screenshot when my form is starting??
Fox has a deme on his site... ("http://orion.spaceports.com/~mccloud/coding/res/screenshot.zip)
Fox
Jun 7th, 2000, 02:15 AM
You forgot a quotation mark ;)
I have a demo on my site... (http://orion.spaceports.com/~mccloud/coding/res/screenshot.zip) (right-click -> Save as...)
Neon
Jun 7th, 2000, 07:07 PM
Thanks for the hints!
Neon
Neon
Jun 7th, 2000, 07:27 PM
I downloaded the Demoe made by Fox but it contained some mistakes!!
For instance there was a variable not declared so that I wasn't able to use it!!
Can just someone give me the source code, or the name under which I can search for in the help file, but I use a german VB5!! And I didn't find anything about it!
Thanks Neon
Fox
Jun 7th, 2000, 08:04 PM
I looked at the source and Option Explicit is defined so there can't be any undefined variable. Maybe because it's made in VB6, you should make a new project and add the form/module of my project to it.
(That's also a point why I linked to the HP so people see the FAQ, and not only download the demos and when having trouble dunno why...)
Fox
Jun 7th, 2000, 08:13 PM
BTW: You won't find anything in the help without having MSDN installed because
it's API stuff. And my demos are tested, they all work (or I at least hope so ;))
Anyway, here's a tutorial for YOU:
Open a new project, add a PictureBox "Buffer" to it, don't forget to set all ScaleModes
to pixel. Then add two buttons "cmdBitBlt" and "cmdStretchBlt".
Finally add this code:
'To your module
'API
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Public Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
'In the form
Private Sub cmdBitBlt_Click()
Dim DC As Long
'Get DC of desktop (=screen)
DC = GetWindowDC(GetDesktopWindow)
'BitBlt to Buffer
BitBlt Buffer.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, DC, 0, 0, vbSrcCopy
'Release DC
ReleaseDC frmMain.hwnd, DC
End Sub
Private Sub cmdStretchBlt_Click()
Dim DC As Long
'Get DC of desktop (=screen)
DC = GetWindowDC(GetDesktopWindow)
'BitBlt to Buffer
StretchBlt Buffer.hdc, 0, 0, Buffer.Width, Buffer.Height, DC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, vbSrcCopy
'Release DC
ReleaseDC frmMain.hwnd, DC
End Sub
If you want to save the file set the AutoRedraw property of the picturebox to true and
add another button with this code:
SavePicture Buffer.Image, "C:\Test.bmp" 'Or any other file
Note that you won't see the picture now unless you save it!
his demo worked fine for me.
the only demos that dont work for me is 2 ddraw demo's,
the mouse one worked, but the other 2 didnt....
Neon
Jun 7th, 2000, 09:59 PM
Ok, it might be as Fox suggested! I am using VB5 and he wrot it with VB6 as far as I could understand it.
So I'll try his code later on cause I have to do a lot for the school!!!
Thanks Neon
Fox
Jun 7th, 2000, 10:37 PM
np ;)
btw: You're german?
Neon
Jun 8th, 2000, 02:02 AM
Yes I am! Why do you ask??
What about you, where do you come from??
Neon
Fox
Jun 8th, 2000, 02:45 AM
Ich frag nur ;) Hatte auch mal das deutsche VS, aber das englische ist mir doch lieber...
Switzerland
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.