473,786 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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


Please post your MFC question to microsoft.publi c.vc.mfc
Jul 22 '05 #2
On Mon, 29 Dec 2003 14:32:34 +0400, "Starlite"
<ge*********@ly cos.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(re c);
}


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
1477
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 communications Unfortunately, for 1, I've been given an ActiveX component that was developed using .NET. My questions are: 1. Is there some way of directly "using" the .NET Activex component in
1
2123
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 been developed using MFC. I don't have much experience with graphics programming so if anyone could point me in a direction to get started (books, websites, etc.) That would be great. TIA
1
3181
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. I set the owner draw on the menu items to true, and draw the MenuItems differently depending on whether or not their selected, thus providing nice Outlook 2003 menu styling. The only problem is, there is no 'unselected' event, so I can't...
3
7224
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 involving the use of double buffering. Those are fine but I want to understand what is wrong. When I created the same control in C++Builder the view was totally flicker free, so this must be something the framework does (or doesn't).
3
9836
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 user interface. how should have get window handle from managed windows? Thanks in advance. Sushil
2
1906
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 wrote the MFC app and the .NET control, so we can add hook functions into either module if necessary. The .NET control is hosted in the MFC app using the CWinFormsControl template.
4
1921
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 one help me ? or give me tutorels that help me ???
3
4712
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 application. Furthermore, I use a pointer to an unmanaged function to jump back into the managed dll. The managed part is basically a remoting enhancement which asynchronly
2
4988
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 onBtnclicked that displays some valued entered by the user in the document. Here is the code in my formview: // MyForm.cpp void CMyForm::OnBnClickedButtonok() { CTP1Doc *pDoc = (CTP1Doc *)GetDocument(); pDoc->hello += "BONJOUR";...
3
4180
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
10169
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.