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 Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type PointAPI X As Long Y As Long End Type Dim SelWnd As Long Private Sub Command1_Click() Dim WndRECT As RECT GetWindowRect SelWnd, WndRECT SavePicture hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp" Set Image1.Picture = hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)) End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.MousePointer = 99 Me.MouseIcon = Picture1.Picture Picture1.Visible = False End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim mousexy As PointAPI GetCursorPos mousexy SelWnd = WindowFromPoint(mousexy.X, mousexy.Y) Me.MousePointer = 0 Picture1.Visible = True End Sub Private Sub Timer1_Timer() Dim mousexy As PointAPI GetCursorPos mousexy label2.Caption = WindowFromPoint(mousexy.X, mousexy.Y) End Sub Private Sub form_load() WebBrowser1.Navigate ("http://www.runescape.com") End Sub
For the whole code take a look at this:
http://vtforce.com/cruel/window_bitblt.zip
Thanks! Hope that clears a few things up...




Reply With Quote