关于WM_PAINT(OnPaint)及WM_TIMER的小问题

来源:互联网 发布:老域名 编辑:程序博客网 时间:2024/05/22 14:39

 MSDN上面关于WM_TIMER有这么一段话: The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue. TIMER消息是一个低优先级的消息。只有当没有其他高优先级的消息的时候,才会被发送 好,你在onpaint函数里面如果不调用CPaintDC dc(this),而且你也没有调用基类的OnPaint,那么窗口的InvalidRect始终存在,也就是系统会不断地发送WM_PAINT消息给你的窗口,那么你的WM_TIMER消息永远不会被Dispatch,SO,你会发现ONTIMER只被调用了一次。 验证这一点很简单,你把SetTimer第三个参数给一个回调函数,这个函数会被调用很多次,说明很多个Timer消息已经被产生。只是你刚才不dispatch而已

 

来源:http://zhuidaniu.com/blogs/231

原创粉丝点击