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))
'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
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?