开发者

Runtime Drawing on window

开发者 https://www.devze.com 2022-12-28 00:32 出处:网络
I usually put my drawing in WM_PAINT to draw on screen but if you need to figure out this at runtime would you still use GDI drawing APIs?

I usually put my drawing in WM_PAINT to draw on screen but if you need to figure out this at runtime would you still use GDI drawing APIs?

Example-

//In WndProc

case WM_PAINT:
{
   hdc = GetWindowDC (hwnd) ;
   //draw here using hdc
   ReleaseDC (hwnd, hdc) ;
开发者_如何学Go
}

Instead of putting the drawing in WM_PAINT, can you draw using function and still get the functionality of WM_PAINT to redraw?


WM_PAINT is asynchronous, meaning its called when the OS decides it's time to repaint the window. You can also draw synchronously by calling GetDC()/ReleaseDC() outside of a WM_PAINT message handler.

http://msdn.microsoft.com/en-us/library/dd145126(v=vs.85).aspx

Also, when handling WM_PAINT messages, you should use BeginPaint()/EndPaint() and return 0. I've seen some strange side-effects when this does not happen.

0

精彩评论

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

关注公众号