How can I make a screenshot when my form is starting??
Printable View
How can I make a screenshot when my form is starting??
You forgot a quotation mark ;)
I have a demo on my site... (right-click -> Save as...)
Thanks for the hints!
Neon
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
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...)
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:
If you want to save the file set the AutoRedraw property of the picturebox to true andCode:'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
add another button with this code:
Note that you won't see the picture now unless you save it!Code:SavePicture Buffer.Image, "C:\Test.bmp" 'Or any other file
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....
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
np ;)
btw: You're german?
Yes I am! Why do you ask??
What about you, where do you come from??
Neon
[german]
Ich frag nur ;) Hatte auch mal das deutsche VS, aber das englische ist mir doch lieber...
[/german]
Switzerland