|
-
Oct 14th, 2001, 09:35 AM
#1
Thread Starter
Junior Member
How can I capture the desktop screen!
I would like to know the code to capture the current desktop screen and paste the picture in a picturebox in my form. Does anyone know how to do this? Help me if you can please!
This is our world now, The world of the pop-trunk and the switch.
The beauty of my Broad :-)
We wage wars, murder, cheat, lie to our women and make them believe its for their own good. And we're the criminals.
My crime is but of pimpology.
I am a Pimp, and this is my manefesto!
-
Oct 14th, 2001, 09:47 AM
#2
VB Code:
Private Declare Function GetDesktopWindow _
Lib "user32" () As Long
Private Declare Function GetDC _
Lib "user32" ( _
ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Private 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
Private Sub CaptureDesktop()
Dim hWindow As Long
Dim hDContext As Long
[b]Picture1[/b].AutoRedraw = True
hWindow = GetDesktopWindow()
hDContext = GetDC(hWindow)
BitBlt [b]Picture1[/b].hDC, 0, 0,
Screen.Width \ Screen.TwipsPerPixelsX, _
Screen.Height \ Screen.TwipsPerPixelsY, _
hDContext, 0, 0, vbSrcCopy
[b]Picture1[/b].Refresh
[b]Picture1[/b].Picture = [b]Picture1[/b].Image
ReleaseDC hWindow, hDContext
End Sub
Best regards
-
Oct 14th, 2001, 09:56 AM
#3
Thread Starter
Junior Member
Hmmm
I just tried that code.............
it said..........
Member or Data Member not found
and it highlighted
.TwipsPerPixelsX
can you help me?
This is our world now, The world of the pop-trunk and the switch.
The beauty of my Broad :-)
We wage wars, murder, cheat, lie to our women and make them believe its for their own good. And we're the criminals.
My crime is but of pimpology.
I am a Pimp, and this is my manefesto!
-
Oct 14th, 2001, 10:00 AM
#4
Sorry! I have typed it wrong. That happens sometimes when you type directly in the post instead of doing it in VB and then copy and paste the code 
Here's the correct procedure:
VB Code:
Private Sub CaptureDesktop()
Dim hWindow As Long
Dim hDContext As Long
Picture1.AutoRedraw = True
hWindow = GetDesktopWindow()
hDContext = GetDC(hWindow)
BitBlt Picture1.hdc, 0, 0, _
Screen.Width \ Screen.TwipsPerPixelX, _
Screen.Height \ Screen.TwipsPerPixelY, _
hDContext, 0, 0, vbSrcCopy
Picture1.Refresh
Picture1.Picture = Picture1.Image
ReleaseDC hWindow, hDContext
End Sub
Best regards
-
Oct 14th, 2001, 10:01 AM
#5
Thread Starter
Junior Member
This is what i did!
I got it to work by taking out the Twips part.. What did that part of the code do anyway? Thanx!
This is our world now, The world of the pop-trunk and the switch.
The beauty of my Broad :-)
We wage wars, murder, cheat, lie to our women and make them believe its for their own good. And we're the criminals.
My crime is but of pimpology.
I am a Pimp, and this is my manefesto!
-
Oct 14th, 2001, 10:04 AM
#6
It re-calculates the Twips mesurement used by VB to pixels that you have to use in API calls. You should put them back otherwise this code will take much longer then necassary to call.
-
Oct 14th, 2001, 10:11 AM
#7
Fanatic Member
How would I make a screenshot of a specific window?
I've got the classname (or handle) of the window
-
Oct 14th, 2001, 10:15 AM
#8
Use the FindWindow to get the hWnd of the window. Then use the above code from the GetDC call (and send the handle of the window).
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
|