-
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")
-
Thx, but it uses the clipboard, all previous data is lost if you use this code :(
-
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")
-
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.
-
The smiley screwed up the code :-(
-
-
Great !!!
It works......
Spezial thanks from Germany......
-
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