That saves the screenshot that's printed into Picture1. The attachment was good, but it still doesn't solve my problem. I'm trying to take a screenshot of a picturebox inside a form, not the whole form.
Thanks
Last edited by BefunMunkToloGen; May 4th, 2005 at 07:53 PM.
Right, i've managed to get it to work. However i have to drag this annoying picture to the 'object' to get it to work. How can i set my picture box to it already without having to move the image to get the window shot?
If you have a look at http://vtforce.com/cruel/window_bitblt.zip , it shows how to drag this picture to an object to take a screenshot of. I want to do this but I dont want to have to use the picture to find the object. I want a command button to automatically take a screenshot of the object. Sorry it's hard to explain.
Imagine I offered you the services of the best programmer in the world.
He now lives in a cave in Tibet (portable generator).
He has no phone and no Internet.
I visit him once a year.
If you can type up your spec, I will take it to him, and I will return with the completed project.
If he misunderstands your spec, I can take the amendments/corrections/clarification with me 12 months later on my next visit.
Right, I can understand as the subject has sightly changed. I will try to explain in as much detail as possible.
I am trying to take a screenshot of an object within my form. The object is a picture box. I have some code that does this, however you have to move a picture (looks like a crosshairover) the object like below:
So, i am trying to get a screenshot of the picture box (that has a web browser inside) without moving the crosshair image over.
Heres some of the code:
VB Code:
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Hi,
Thanks for explaining more.
The attachment is the same one you posted before, I think ?
I could not work out how to use either of them.
I click the button.
I click and drag the mouse, and let go.
I see the rectangle whilst doing that What am i supposed to do next.
I'm attaching screen shot of the latest zip, in case you attached the wrong one.
The function uses the window handle to retrieve picture content. So you must provide the correct window handle to be able to take the screenshot. If you don't want to have to drag the crosshairs then you'll have to use a series of FindWindow and FindWindowEx api calls.
Luckily if you're just wanting a screenshot of a picture box, then you can just use Picture1.hWnd
That being said, here's the revised button event:
Code:
Private Sub Command1_Click()
Dim WndRECT As RECT
GetWindowRect Picture2.hwnd, WndRECT
SavePicture hDCToPicture(GetDC(Picture2.hwnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp"
End Sub
I tested and it should work. If not, post the problem.
Last edited by Cruel__Machine; May 8th, 2005 at 03:29 PM.