Improve company productivity with a Business Account.Sign Up

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

Transparent rectangle drawn on top of lines MFC on Windows CE 5.0

I would like to draw a transparent color filled rectangle on some static lines. The width of this rectangle changes in real time. How do I accomplish this? The background color is white.

Thank you in advance.
0
Anthony2000
Asked:
Anthony2000
  • 6
  • 5
1 Solution
 
alexey_gusevCommented:
do you mean like DrawFocusRect() or DrawEdge() Win32 API?

otherwise there is Rectangle() function which uses current pen to draw the frame and current brush to fill it.

moreover, you can SetBkMode() to transparent
0
 
Anthony2000Author Commented:
What I need is a snippet of code, can you supply one? Here is what I have tried:


	brushFill.DeleteObject();
	brushFill.CreateSolidBrush(m_colorNeedle) ;
 
	pDC->SetBkMode(TRANSPARENT);
	pBrushOld = pDC->SelectObject(&brushFill) ;
 
	// draw the rectangle
	pDC->Polygon(m_pointRectangle, 5) ;
 
	// restore the brush (but keep the pen!)
	pDC->SelectObject(pBrushOld) ;

Open in new window

0
 
Anthony2000Author Commented:
Also, I am developing using Visual Studio 6.0, but it will need to work on Windows CE using eVC++ 4.0. Thanks for your help.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
alexey_gusevCommented:
0
 
Anthony2000Author Commented:
Well, those functions will draw the rectangle, but what about filling it with a transparent color? How do I accomplish that? Thanks again for your help.
0
 
alexey_gusevCommented:
that do you exactly mean by "transparent colour" ? could you please explain it in more details?
0
 
Anthony2000Author Commented:
Lets say that I have a picture box with text in it. I want to fill in part of the rectangle with a color. So, that part of the text has a blue background  and the rest has a white background. I just wanted to avoid re-drawing the text. Does this help?
0
 
Anthony2000Author Commented:
Like a progress control.
0
 
alexey_gusevCommented:
well, if you change any part of the area then it will be Invalidate()'ed, so you'll get WM_PAINT eventually. thus you'd definitely have to redraw the text somehow. what you could do is to draw the text transparently, so it doesn't matter that's the background.
0
 
Anthony2000Author Commented:
I appreciate your help!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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