Does System.Windows.Forms.Timer send WM_TIMER message?

荒凉一梦 提交于 2019-12-13 04:06:12

问题


Does System.Windows.Forms.Timer send WM_TIMER message ?

Basically I want to set a timer that should generate

WM_TIMER  

message for every 5 seconds. I am using

System.Windows.Forms.Timer

and the

Tick 

event is handled. But I am not getting WM_TIMER message in my WndProc().


回答1:


Yes, WM_TIMER is what makes a Winforms Timer tick. Unobserved in your code however, it creates its own window, it doesn't use yours. It is an invisible one, the underlying .NET class is TimerNativeWindow, a private class of the Timer class. You can't ever override its WndProc(). Technically you could subclass it with NativeWindow after digging out the handle with Reflection, but that way lies dragons and should never be necessary.



来源:https://stackoverflow.com/questions/21722438/does-system-windows-forms-timer-send-wm-timer-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!