-
A hardish one for you GDI people.
I'm trying to change the text colour and background colour of a Button using API (I have reasons).
I managed to change the text colour using BS_OWNERDRAW and SetTextColour. I also changed the colour of the box using
CreateSolidBrush and FillRect however this leaves me with 2 problems:
1). The Rect is now flat - the button no longer looks like a button.
2). The text is invisible (the FillRect has filled over my Text!)
Does anyone know how to change the background colour of a button while keeping it looking like an button AND keeping the text visible (like changing the system colour - but obviously not changing the system colours!!!)
I need this pretty quick - so if anyone has the answer I'd be eternally grateful!
-
OK...if I do the background first...the text stays visible, but I've still lost the 3d effect.
Do I have to ownerdraw it?
-
You use Fillrect right? Then you could just make the rect smaller by 1 pixel at each border
-
Kinda Works
Kedaman,
That sort of works but it draws the rect at client 0,0 (i.e. the top corner of the button). How can I adjust the DC to draw it at client (1,1) (Or whatever?)
-
Its ok...I figured it out.
Its in client coords so add to top and left, and minus from bottom and right.
Do you know any way to adjust a colour value?
A standard button is medium grey yes? and a pixel on the top and left is white, a pixel on the botom and right is dark grey.
To complete the effect of what I'm doing, if I change the button colour to (Say) red, can I calculate a light red (red+white) for the top/left and a dark red (red+dark grey) for the bottom/right?
-
yep, you could change the color light by multiplying each colorcomponent by a constant
Well not sure how you change the color, but you could use setpixel, a slightly slower than lineto, on the other hand you could blit i line you've drawn on a DC earlier
-
Got that too.
To lighten: (R+255)/2,(G+255)/2,(B+255)/2
To darken: (R)/2,(G)/2,(B)/2