Results 1 to 4 of 4

Thread: HELP!! GetDC and Blt not working!

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6
    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


  2. #2
    Guest
    Is the Form's AutoRedraw Property Set to False??
    because it should be false.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It works on mine - try this:
    Code:
    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
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width