troubleshooting Question

Trying to create Flicker free CStatic with Bitmap background

Avatar of microwhat
microwhat asked on
C++Visual C++.NETSystem Programming
8 Comments2 Solutions2805 ViewsLast Modified:
I have a transparent background CStatic text class(CStatic subclass). The CStatic txt is located in a dialog with a bitmap for a background. I'm trying to implement flicker free with this. Currently the code below is flickering less, but it's not flicker free. Also, i can't seem to get it to display the background as transparent with this flicker free code, this is something it did with no issue without the flicker free code. Any input is welcome. I've read/searched a lot and i'm just about stuck at this point.
BOOL CTransparentStatic::OnEraseBkgnd(CDC* pDC)
return TRUE;
void CTransparentStatic::OnPaint()
	CPaintDC dc(this); // device context for painting
	CDC      memDC;
	CBitmap  memBM;
	CBrush   hbrBkGnd;

	// Where to draw text
	CRect client_rect;

	// Get the caption
	CString szText;

	// Get the font
	CFont *pFont, *pOldFont;
	pFont = GetFont();

		// Create a compatible DC.

		// Create a bitmap big enough for our client rectangle.

		// Select the bitmap into the off-screen memory DC.
		CBitmap *hbmOld = memDC.SelectObject(&memBM);

		// Erase the background.
		memDC.FillRect( &client_rect, &hbrBkGnd);

		// Select the font.
			pOldFont = memDC.SelectObject(pFont);

		// Render the image into the offscreen DC.
		memDC.SetTextColor ( RGB(54,54,112) );
		memDC.DrawText(szText, client_rect, DT_LEFT);


		// Blt the changes to the screen DC.
			   0, 0,

		// Done with off-screen bitmap and DC, clean up.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros