Archived

This topic is now archived and is closed to further replies.

Draigan

Color chooser MFC

Recommended Posts

I have a dialog box that has a little rectangle in it. When the user clicks this rectangle, a CColorDialog box pops up and queries the user for a color. Once the user picks a color, this CColorDialog closes and this rectangle is to be drawn using that color. The rectangle itself I have implemented as a CStatic member that is simply a rectangle set to black in the Resource Editor. I can change the color of the box by getting this item, getting it''s DC and painting the rectangle myself. However, when it becomes redrawn, it goes back to it''s original black. How do I make it so that I can change the color of this rectangle and it will stay changed even when it needs to be redrawn? I tried overriding the OnPaint member of the dialog box class and getting the Client Rect of the rectangle itself and drawing it but the rectangle doesn''t appear in the right place... it appears in the top left of the dialog box itself. Is there a way to offset it to the correct position within the dialog box?

Share this post


Link to post
Share on other sites
nevermind... got it
I changed it to a frame instead of rectangle and made sure the notify property was checked.

Then I get the client coords of it... converted them to screen coords and then using the dialog box, converted the screen coords to client coords.

Share this post


Link to post
Share on other sites