{"id":14363,"date":"2010-04-09T07:00:00","date_gmt":"2010-04-09T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/04\/09\/why-cant-you-use-wm_ctlcolorstatic-to-change-the-color-of-a-ss_blackrect\/"},"modified":"2010-04-09T07:00:00","modified_gmt":"2010-04-09T07:00:00","slug":"why-cant-you-use-wm_ctlcolorstatic-to-change-the-color-of-a-ss_blackrect","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100409-00\/?p=14363","title":{"rendered":"Why can&#039;t you use WM_CTLCOLORSTATIC to change the color of a SS_BLACKRECT?"},"content":{"rendered":"<p>If you specify one of the static control styles which draw a frame or rectangle<\/p>\n<table border=\"0\">\n<tr>\n<td><code>SS_BLACKRECT<\/code><\/td>\n<td><code>SS_BLACKFRAME<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>SS_GRAYRECT<\/code><\/td>\n<td><code>SS_GRAYFRAME<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>SS_WHITERECT<\/code><\/td>\n<td><code>SS_WHITEFRAME<\/code><\/td>\n<\/tr>\n<\/table>\n<p> the control will be drawn with the corresponding color (which, as we saw last time, <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2010\/04\/08\/9992117.aspx\"> isn&#8217;t actually black, gray, or white<\/a>). If you try to customize the color by handling the <code>WM_CTL&shy;COLOR&shy;STATIC<\/code> message, you&#8217;ll find that it has no effect.\n Well, yeah, because you said you wanted a black rectangle.<\/p>\n<p> If you want some other color, you could set the style to <code>SS_OWNER&shy;DRAW<\/code> then draw the solid color in your <code>WM_DRAW&shy;ITEM<\/code> handler. Or you can just use a text static control with no text. In that case, you can respond to <code>WM_CTL&shy;COLOR&shy;STATIC<\/code> in the usual way. Since you specified no text, all that will be drawn is the background color. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t actually black, gray, or white). If you try to customize the color by handling the WM_CTL&shy;COLOR&shy;STATIC message, you&#8217;ll [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-14363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>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&#8217;t actually black, gray, or white). If you try to customize the color by handling the WM_CTL&shy;COLOR&shy;STATIC message, you&#8217;ll [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/14363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=14363"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/14363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=14363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=14363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=14363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}