|
-
Sep 18th, 2000, 03:15 PM
#1
This will take a picture of the screen.
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
Public Function SaveScreen(ByVal theFile As String) As Boolean
On Error Resume Next
'To get the Entire Screen
Call keybd_event(vbKeySnapshot, 1, 0, 0)
'To get the Active Window
'Call keybd_event(vbKeySnapshot, 0, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), theFile
SaveScreen = True
Clipboard.Clear
Exit Function
End Function
Usage:
Call SaveScreen("C:\Windows\Desktop\ss.bmp")
-
Sep 19th, 2000, 05:33 AM
#2
Thx, but it uses the clipboard, all previous data is lost if you use this code
-
Sep 19th, 2000, 06:25 AM
#3
So copy the previous data to a variable or something and re-copy it.
Code:
Public Function SaveScreen(ByVal theFile As String) As Boolean
On Error Resume Next
prevclip = Clipboard.GetText()
'To get the Entire Screen
Call keybd_event(vbKeySnapshot, 1, 0, 0)
'To get the Active Window
'Call keybd_event(vbKeySnapshot, 0, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), theFile
SaveScreen = True
Clipboard.Clear
Clipboard.SetText prevclip
Exit Function
End Function
Usage:
Call SaveScreen("C:\Windows\Desktop\ss.bmp")
-
Sep 19th, 2000, 12:52 PM
#4
Fanatic Member
This code copys the screen to Picture1:
Code:
Picture1.Autoredraw = True
Dim ScreenDC as long
ScreenDC = GetDC(0&)
BitBlt Picture1.hdc,0,0,1024,768,ScreenDC,0,0,SRCCopy
Picture1.Refresh
Note: 1024=The screenwidth (pixels)
768=The screenheight(pixels)
Don't forget to add the API Declarations, I can't include them, because I don't have VB here.
-
Sep 19th, 2000, 12:56 PM
#5
Fanatic Member
The smiley screwed up the code :-(
-
Sep 19th, 2000, 01:45 PM
#6
Thx guys, this works
-
Oct 19th, 2000, 07:19 AM
#7
New Member
Great !!!
It works......
Spezial thanks from Germany......
-
Nov 4th, 2001, 09:55 PM
#8
New Member
I get an error
I tried this code
Picture1.Autoredraw = True
Dim ScreenDC as long
ScreenDC = GetDC(0&)
BitBlt Picture1.hdc,0,0,1024,768,ScreenDC,0,0,SRCCopyPicture1.Refresh
I get the error sub or function not declared on GetDC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|