Another DeviceContext/BitMap question

Posted on 2003-03-05
Medium Priority
Last Modified: 2010-05-01
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)

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?

Question by:Julian_K
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 8072777
<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 :))

Accepted Solution

SpideyMod earned 0 total points
ID: 8104505
Edited out your non-professional comment and PAQ'd the question with a refund of your points.

Community Support Moderator @Experts Exchange

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question