Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Another DeviceContext/BitMap question

Hello, experts.
I'm doing this for the first time, and of course, it does not works :)))
It is a user control of some kind.

First, here is the procedure I use to create a Device context and Bitmap. I use them as a buffer to avoid flickering while drawing.

Note: I use this to Recreate the DC and bitmap (if they are destroyed for another purposes, thus the "IF=0" checks)

Private Sub pCreateBitMapBuffer()
'recreate the device context
    If (m_hDC = 0) Then
        m_hDC = CreateCompatibleDC(GetDC(0))
    End If
'recreate the bitmap
    If (m_hBMP = 0) Then
        m_hBMP = CreateCompatibleBitmap(m_hDC, UserControl.ScaleWidth, UserControl.ScaleHeight)
'select the bitmap into the Device context
        SelectObject m_hDC, m_hBMP
        SetBkMode m_hDC, bmb_TRANSPARENT
    End If
End Sub

Then, at some point I use:
...
call GradientFillRect(m_hDC, m_rcVertex(0), 3, rcGRECT(0), 2, DRAW_MODE)
...
Call BitBlt(UserControl.hDC, 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight, m_hDC, 0, 0, vbSrcCopy)
...

THE PROBLEM:
If I draw the stuff directly to the usercontrol's HDC, everything works fine. I tested it and it was OK.
Then I added the procedure above and tried to use memory resident bitmap as a buffer, but instead of getting gradient fill, I see only a black rectangle, filled with gray "x" pattern, as if the result bitmap is 2 color only.

Any ideas what goes wrong?

Thanks,
Julian
0
Julian_K
Asked:
Julian_K
1 Solution
 
Julian_KAuthor Commented:
<Comment edited by SpideyMod>
I found the answer :)
The problem is that when I create compatible bitmap, I refer to the newly created device context and there is no bitmap in it :))
0
 
SpideyModCommented:
Edited out your non-professional comment and PAQ'd the question with a refund of your points.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now