473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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);
}
Jul 22 '05 #1
2 8382
"Starlite" <ge*********@lycos.co.uk> wrote...
I am using Microsoft visual c++ 6, and I want [...]


Please post your MFC question to microsoft.public.vc.mfc
Jul 22 '05 #2
On Mon, 29 Dec 2003 14:32:34 +0400, "Starlite"
<ge*********@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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kunal | last post by:
I have an application that was fully developed in VC++ 6.0 using MFC. I have to enhance the application in 2 ways: 1. Add some graphics stuff (draw graphs), and 2. Perform serial port...
1
by: Status Malus | last post by:
I'm working on a project that requires drawing binary trees, graphs and modular layouts. The user needs to have the ability to output these drawings to a file. A lot of the application has already...
1
by: Tim Haughton | last post by:
Like most fans of eye candy, I've always thought the standard MainMenu control was a bit drab. After looking at third party components, I decided to see if I could brute force it into looking nice....
3
by: Arnold the Aardvark | last post by:
I am creating a custom draw tree view based on CTreeCtrl. When the control is re-sized the background is blanked completely, resulting in a horrible flicker. I've seen various suggestions...
3
by: Sushil Srivastava | last post by:
Hi Guys, Would you be able to help me using C# GUI (with user interface component) in my MFC application. I have used managed extension, COM-interops, etc but problem is this C# component has...
2
by: mmacrobert | last post by:
We have an MFC application mixed with a few .NET controls. I would like to be able to render the content of a .NET control to an MFC device context - specifically a printing device context. We...
4
by: coctile | last post by:
Hi Guys.. i have project AVLTree By using MFC but the biggest Problem is how can i draw it ? as bitmap ? how can i call the bitmap and can i draw on it ? or Draw it as Lines ? Can in...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
2
by: YouPoP | last post by:
Hi, I am doing an MFC MDI application with VS 8.0. I am using the default document view plus a formview ans show both of them in the view using a splitter. In the formview there is an event...
3
by: mvjohn100 | last post by:
Hello, In an MFC application I want to draw a line which should move around after the drawing what can I do? Thanks, john
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.