?
Solved

get colour from gdi object

Posted on 2009-02-11
3
Medium Priority
?
367 Views
Last Modified: 2013-11-20
i like to initialize a CColorDialog by a colour (COLORREF value) from a GDI Object (CBrush).
I didn't find any function to do this yet.
example:

CBrush br;
br.Create(..);
...
// now I'm looking for something like this:
br.GetRGBColour();

Thanks experts.
0
Comment
Question by:stev75
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 300 total points
ID: 23609459
Hi stev75,

you can use 'GetObject' to retrieve info about GDI objects, i.e. for a CBrush:

> CBrush brush;
> brush.CreateSolidBrush( RGB( 255, 255, 0 ) );
>
> LOGBRUSH info;
> brush.GetObject( sizeof( info ), &info );
>
> TRACE( "Color of brush is %08x.\n", info.lbColor );

Hope that helps,

ZOPPO
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 300 total points
ID: 23609469
You can get the colour of a brush in this way:
// create a brush
CBrush oBrush( RGB( 255, 255, 0 ));
 
// get the brush descriptor
LOGBRUSH lbr;
oBrush.GetLogBrush( &lbr);
 
// test the colour
ASSERT( lbr.lbColor == RGB( 255, 255, 0 ));

Open in new window

0
 

Author Closing Comment

by:stev75
ID: 31545480
thanks, that's it! both comments lead to success so I will split points
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 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