Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I handle WM_CTLCOLORSTATIC message to make transparent background for static control:
C++
case WM_CTLCOLORSTATIC:
{
SetTextColor((HDC)wParam,RGB(0,0,0));
SetBkMode((HDC)wParam,TRANSPARENT);
HBRUSH return_brush = (HBRUSH)GetStockObject(NULL_BRUSH);
return (LRESULT)return_brush;
}

This works fine.
And now I try to change text for static control by calling SendMessage(). But in result new text is placed over the existing text. I think that need to repaint static control.
How to repaint static control and what WM messages need to handle?
Posted

 
Share this answer
 
At first you need to draw the background. -> WMERASE_BKGROUND

http://msdn.microsoft.com/en-us/library/windows/desktop/ms648055(v=vs.85).aspx[^]
 
Share this answer
 
Comments
Igor-84 21-Jun-13 5:50am    
KarstenK, please write the source code, because I don't know how to do it.
KarstenK 21-Jun-13 5:59am    
Please learn it by yourself. It includes handling the message an a FillRect call.

If it is too hard for you to figure it out, you should consider doing work which fits better to you. ;-)
Try calling Invalidate() on the window.
 
Share this answer
 
Windows controls are not intended to have a transparent background.

Either set the background color to the color of the underlayiong control or paint the underlaying control before displaying text.

The problem is that since the background brush is transparent, then it does not erase old text as it would be the case with a regular fully opaque brush.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900