Results 1 to 10 of 10

Thread: BitBlt'ing one DC into another

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506

    BitBlt'ing one DC into another

    OK here's the score, I've created two device contexts and loaded a bitmap using the LoadImage API. I'm now 'selecting' the bitmap into the first DC and the BitBlt'ing it into the second DC but when I try to BitBlt this DC to the form for testing I get nothing.

    This is the troublesome code:
    VB Code:
    1. 'Create a copy of the original bitmap so it can be masked
    2.   Dim hbmCopy As Long, hdcCopy As Long
    3.  
    4.   hDC = CreateCompatibleDC(0)
    5.   hdcCopy = CreateCompatibleDC(0)
    6.    
    7.   hbmCopy = CreateCompatibleBitmap(0, 16, 16)
    8.  
    9.   'Select the original image
    10.   SelectObject hDC, m_hbmMain
    11.   'SelectObject hdcCopy, hbmCopy
    12.  
    13.   'BitBlt the original into the copy DC
    14.   Debug.Print "copying from ", hDC, "to", hdcCopy
    15.   Debug.Print "result:", BitBlt(hdcCopy, 0, 0, 16, 16, hDC, 0, 0, vbSrcCopy)
    16.  
    17.   'See if we can BitBlt our copied one onto the form
    18.   Debug.Print "bitblt onto form", BitBlt(Me.hDC, 16, 0, 16, 16, hdcCopy, 0, 0, vbSrcCopy)
    19.  
    20.   'Refresh the form
    21.   Me.Refresh
    22.  
    23.   DeleteObject hbmCopy
    24.   DeleteDC hdcCopy
    25.   DeleteDC hDC

    I'll also attach the form incase anyone needs a closer inspection. When the command button is clicked 2 images of an apple should appear in the top-left corner.

    Cheers for any help, adehh.
    Attached Files Attached Files

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