Solved

CreatePen , how to change color

Posted on 1997-06-01
2
379 Views
Last Modified: 2013-12-03
When i create a pen like CreatePen () , how do i do to change that pens color later ??
using bwc++ 4.02
Write a simple example.
0
Comment
Question by:superabbe
2 Comments
 
LVL 2

Accepted Solution

by:
r parkinson earned 50 total points
ID: 1397781
There is no way to change a pen once it is created, however you can accive a similar effect if you use CreatePenIndirect, which takes a structure, and just modify the color parameter (hence maintaining the other attributes).  You can then 'switch' pens with the code :

// Create the first Pen.
hPen=SelectObject(hdc,CreateFontIndirect(&lgpn));

// Change a property of the pen here ...

//create a new pen, select the font to your DC and
//delete the previous pen.  
DeleteObject(SelectObject(hdc,CreateFontIndirect(&lgpn)));

//Delete the selected pen and replace it to the DC with the
//default pen.
DeleteObject(SelectObject(hdc,hPen));

0
 

Author Comment

by:superabbe
ID: 1397782
In my program the pen will change color when WM_MOUSEMOVE occur .
Is it possible that my GDI-res will be way out of control ??
like 1 % left or so ?
.

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now