Thanks for those who help with the key-press before!
I've come to another problem in creating that screen shot application.
I have an option that either takes a picture of the entire screen, or of the focused window.
Now, this wouldn't be a problem if i got the screen shot from using the kb_event API call. But i need the Clipboard to stay intact and unchanged, so i use a different way of getting the screen shot:
VB Code:
Public xpos As Long Public ypos As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long Private Sub Command1_Click() Dim wScreen As Long Dim hScreen As Long Dim w As Long Dim h As Long Picture1.Cls wScreen = Screen.Width \ Screen.TwipsPerPixelX hScreen = Screen.Height \ Screen.TwipsPerPixelY Picture1.ScaleMode = vbPixels 'w = Picture1.ScaleWidth 'h = Picture1.ScaleHeight w = Screen.Width / Screen.TwipsPerPixelX h = Screen.Height / Screen.TwipsPerPixelY hdcScreen = GetDC(0) r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy) End Sub
I know about using the StretchBlt API call to manipulate the picture box.
The part that i'm missing is how to get the active window's top, left, width and height to set the picture. So in other words, it takes the entire screen & cuts off the bit that doesn't belong to the focused window. Is there any way to do this?




Reply With Quote