[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

CreatePen , how to change color

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
superabbe
Asked:
superabbe
1 Solution
 
r parkinsonCommented:
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
 
superabbeAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now