Jump to content
  • Advertisement

Archived

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

smidge_tech

Transparent font / static control

This topic is 6021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a simple problem but for some reason it's annoying me... I have a few static controls on my window, and I've changed the background window colour to a nice pale blue colour... However the background behind the lettering of the text in each static control is still painted in the original colour... According to the Platform SDK, I have to handle the WM_CTLCOLORSTATIC message, which can be used to set the background colour. So this is what I have:
  
// g_App.GetBckBrush() returns the HBRUSH I'm using.

// rcRect is just a RECT structure.

case WM_CTLCOLORSTATIC:
    // A static control is about to be drawn...

    GetWindowRect((HWND)lParam, &rcRect);
    FillRect((HDC)wParam, &rcRect, g_App.GetBckBrush());
    return((LRESULT)g_App.GetBckBrush());
  
... but when I do that it redraws the background behind the text as plain white, whatever brush I supposedly paint it with in this snippet of source code. Weird. Have I missed something? Thanks, ======== Smidge ======== Edited by - smidge_tech on December 26, 2001 10:24:55 AM

Share this post


Link to post
Share on other sites
Advertisement
try this (works for me):

  
// g_App.GetBckBrush() returns the HBRUSH I''m using.

// rcRect is just a RECT structure.

case WM_CTLCOLORSTATIC:
SelectObject((HDC) wParam, g_App.GetBckBrush());

//

// Set the text background color and background mode.

SetBkMode((HDC) wParam, TRANSPARENT);
SetBkColor((HDC) wParam, g_App.GetBkColor());

//

// Set the text foreground color.

SetTextColor((HDC) wParam, g_App.GetTextColor());

//

// Return the control background brush.

return (long) g_App.GetBckBrush();
break;




Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Just to clarify what made the difference - you needed to set the background mode to TRANSPARENT so that anything in the background doesn''t get overdrawn except where the actual text is.

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!