如何在更改文本时重新绘制静态控件? [英] How to repaint static control on changing text?
本文介绍了如何在更改文本时重新绘制静态控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我处理WM_CTLCOLORSTATIC消息以为静态控制创建透明背景:
I handle WM_CTLCOLORSTATIC message to make transparent background for static control:
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;
}
这样可以正常工作。
现在我尝试通过调用SendMessage()来更改静态控制的文本。但结果是新文本放在现有文本上。我认为需要重新绘制静态控件。
如何重新绘制静态控件以及WM消息需要处理什么?
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?
推荐答案
试试这个:如何在更改文本时重新绘制静态控件? [< a href =http://stackoverflow.com/questions/17233247/how-to-repaint-static-control-on-changing-texttarget =_ blanktitle =New Window> ^ ]
首先你需要绘制背景。 - > WMERASE_BKGROUND
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648055(v = vs.85).aspx [ ^ ]
At first you need to draw the background. -> WMERASE_BKGROUND
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648055(v=vs.85).aspx[^]
尝试在窗口上调用Invalidate()。
Try calling Invalidate() on the window.
这篇关于如何在更改文本时重新绘制静态控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文