473,702 Members | 2,519 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 8405
"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
1474
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
2116
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
3172
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
7221
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
9830
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
1904
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
1917
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
4707
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
4980
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
4176
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
8739
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9234
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9089
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...
0
8940
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
5907
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4412
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
3107
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
3
2036
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.