开发者

Invalidate or clip text

开发者 https://www.devze.com 2023-01-25 00:46 出处:网络
I\'m trying to monitor the mouse position on client area of window. for example: WM_MOUSEMOVE: { std::ostringstring oss;

I'm trying to monitor the mouse position on client area of window. for example:

WM_MOUSEMOVE:
{
   std::ostringstring oss;

   xPos = LOWORD(lParam);
   yPos = HIWORD(lParam);

   oss << xPos << ", " << yPos;

   TextOut(hDC, 100, 100, oss.str().c_str(), oss.str().size());
}

Do i need to measure the height, width 开发者_Python百科of fonts to get the area to erase before drawing out new text? I don't understand if i would need clipping to redraw the region or just invalidate rect would be enough for properly drawing the text.


Every time you draw some text, use GetTextExtentPoint32 to measure the size of the area written, and save that somewhere. Then when you try to draw something new, you can pass a rectangle based on that value into InvalidateRect to indicate your desire to erase, then UpdateWindow to make the erasure happen immediately.

0

精彩评论

暂无评论...
验证码 换一张
取 消