Solved

CreatePen , how to change color

Posted on 1997-06-01
2
383 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

22 Experts available now in Live!

Get 1:1 Help Now