Color chooser MFC

Started by
0 comments, last by Draigan 21 years, 5 months ago
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?
Advertisement
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.

This topic is closed to new replies.

Advertisement