Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > MFC: How to draw a semi-transparent shape?

Reply
Thread Tools

MFC: How to draw a semi-transparent shape?

 
 
Starlite
Guest
Posts: n/a
 
      12-29-2003
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);
}


 
Reply With Quote
 
 
 
 
Dan W.
Guest
Posts: n/a
 
      12-29-2003
On Mon, 29 Dec 2003 14:32:34 +0400, "Starlite"
<(E-Mail Removed)> 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.


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-29-2003
"Starlite" <(E-Mail Removed)> wrote...
> I am using Microsoft visual c++ 6, and I want [...]


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
gifs or jpgs won't draw on some pages dougbabacool@voila.fr Firefox 3 01-13-2006 11:20 PM
Can't draw new maps mapmaker Firefox 2 10-22-2004 03:31 AM
Re: !! IMPORTANT !! Problem with owner draw listbox Yair Cohen ASP .Net 0 09-04-2003 05:54 PM
tool to draw FSM bubble diagram Ingmar Seifert VHDL 5 08-01-2003 06:13 PM



Advertisments