Solved

CreatePen , how to change color

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

777 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