Why can’t you use WM_CTLCOLORSTATIC to change the color of a SS_BLACKRECT?


If you specify one of the static control styles which draw a frame or rectangle

SS_BLACKRECT SS_BLACKFRAME
SS_GRAYRECT SS_GRAYFRAME
SS_WHITERECT SS_WHITEFRAME

the control will be drawn with the corresponding color (which, as we saw last time, isn't actually black, gray, or white). If you try to customize the color by handling the WM_CTL­COLOR­STATIC message, you'll find that it has no effect.

Well, yeah, because you said you wanted a black rectangle.

If you want some other color, you could set the style to SS_OWNER­DRAW then draw the solid color in your WM_DRAW­ITEM handler. Or you can just use a text static control with no text. In that case, you can respond to WM_CTL­COLOR­STATIC in the usual way. Since you specified no text, all that will be drawn is the background color.

Comments (1)
  1. Anonymous says:

    Kinda self explanatory :)

    Concerning SS_OWNERDRAW, was there a reason why this specific style was not available in the resource editor for quite a few versions of VS?

Comments are closed.