PDA

Click to See Complete Forum and Search --> : HELP!! GetDC and Blt not working!


konstantine1
Aug 25th, 2000, 01:57 PM
This doesn't work. Help!!!
Something is wrong with parameter's I'm passing to the GetDC or the BitBlt function.


_________________________________________________-
Declare Function FindWindow Lib "user32" alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
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 Form_Load()
' Use any active window on the desktop.
hWnd_MyWindow = "This is the name of my window"


A = FindWindow(vbNullString, hWnd_MyWindow)
s = GetDC(A)

BitBlt Form1.hDC, 0, 0, Screen.Width, Screen.Height, s, 0, 0, vbSrcCopy
End Sub

Aug 26th, 2000, 12:38 AM
Is the Form's AutoRedraw Property Set to False??
because it should be false.

parksie
Aug 26th, 2000, 05:21 PM
It works on mine - try this:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd 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 Declare Function GetDesktopWindow Lib "user32" () As Long
Private Sub Form_Paint()
Dim s As Long
s = GetDC(GetDesktopWindow)

BitBlt Form1.hDC, 0, 0, Screen.Width, Screen.Height, s, 0, 0, vbSrcCopy

End Sub

konstantine1
Aug 29th, 2000, 09:43 AM
thanks for your reply.
Yes, I have Form's AutoRedraw property set to true.

The problem is that this code captures the active window.
I need it to capture a window that I pass through as an argument, not the desktop window.
Any suggestions???

Thanks.