• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1063
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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