Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   MFC: How to draw a semi-transparent shape? (http://www.velocityreviews.com/forums/t280309-mfc-how-to-draw-a-semi-transparent-shape.html)

Starlite 12-29-2003 10:32 AM

MFC: How to draw a semi-transparent shape?
 
I am using Microsoft visual c++ 6, and I want to draw a shape (say a
rectangle) on a view. The code that I have used is below, but this draws a
solid -filled rectangle, what I want is a displayed shape with a
semi-transparent color i.e. we should still be able to see whatever is
beneath the shape. Can anyone help me? Thanks.

void OnPaint()
{
CPaintDC dc(this);
CPen pPen(PS_SOLID, 1, RGB(0,0,0));
CBrush bBr(RGB(0,0,150));
CRect rec;

//rectangle to be drawn
rec.top = 0;
rec.left = 0;
rec.right = 100;
rec.bottom = 100;

dc.SelectObject(pPen);
dc.SelectObject(bBr);

dc.Rectangle(rec);
}



Dan W. 12-29-2003 05:05 PM

Re: MFC: How to draw a semi-transparent shape?
 
On Mon, 29 Dec 2003 14:32:34 +0400, "Starlite"
<genius.star@lycos.co.uk> wrote:

>I am using Microsoft visual c++ 6, and I want to draw a shape (say a
>rectangle) on a view. The code that I have used is below, but this draws a
>solid -filled rectangle, what I want is a displayed shape with a
>semi-transparent color i.e. we should still be able to see whatever is
>beneath the shape. Can anyone help me? Thanks.
>
>void OnPaint()
>{
> CPaintDC dc(this);
> CPen pPen(PS_SOLID, 1, RGB(0,0,0));
> CBrush bBr(RGB(0,0,150));
> CRect rec;
>
>//rectangle to be drawn
> rec.top = 0;
> rec.left = 0;
> rec.right = 100;
> rec.bottom = 100;
>
> dc.SelectObject(pPen);
> dc.SelectObject(bBr);
>
> dc.Rectangle(rec);
>}
>


I've seen an MFC-specific newsgroup, you might care to search for
'mfc' throught the newsgroups list. I have a feeling that you need to
use Direct X if you want real-time alpha blending. Or OpenGL; I don't
think the GDI has built-in capabilities for that; but you might want
to check with MFC gurus.



Victor Bazarov 12-29-2003 05:13 PM

Re: How to draw a semi-transparent shape?
 
"Starlite" <genius.star@lycos.co.uk> wrote...
> I am using Microsoft visual c++ 6, and I want [...]


Please post your MFC question to microsoft.public.vc.mfc




All times are GMT. The time now is 12:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.