Thread: BRUSH PEN Color

  1. #1
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203

    Question BRUSH PEN Color

    Given an HBRUSH or an HPEN, is there any function in GDI to find its color (if possible in a COLOREF) ?

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    I think you can accomplish this using GetObject.

    Code:
    COLORREF GetBrushColor( HBRUSH hBrush ) {
      COLORREF color = 0 ;
      LOGBRUSH logBrush ;
      if ( GetObject( hBrush, sizeof(LOGBRUSH), &logBrush ) ) {
        color = logBrush.lbColor ;
      }
      return color ;
    }
    
    COLORREF GetPenColor( HPEN hPen ) {
      COLORREF color = 0 ;
      LOGPEN logPen ;
      if ( GetObject( hPen, sizeof(LOGPEN), &logPen ) ) {
        color = logPen.lopnColor ;
      }
      return color ;
    }

  3. #3
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    Thank you; this seems to be much more useful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Brush color
    By Gordon in forum Windows Programming
    Replies: 9
    Last Post: 04-14-2007, 06:51 AM
  2. Changing color of pen
    By Gordon in forum Windows Programming
    Replies: 4
    Last Post: 04-13-2007, 10:26 AM
  3. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  4. My opinion on skin color
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2003, 12:12 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM