Resources for receiving and processing blinking messages: In the first lesson of MFC, we will talk about the message mechanism of windows. In this part, we use the wndproc function to capture messages using a message loop. Although wndproc is not used in WPF, another method is provided to complete the hook function. In winform, you only need to reload the wndproc function to complete message response. Private const int wm_sizeing = 0x0214; // window size change message Protected override void wndproc (Ref system. Windows. Forms. Message m) { Switch (M. msg) { Case wm_sizeing: // ...... YourCode Break; Default: Base. wndproc (ref m); // call the base class function to process other messages. Break; } }
Unfortunately, I tested it through spy ++. After opening the modal window, I clicked the parent form. The system did not send a message to the modal form. That is to say, we cannot notify modal form mouse actions by sending system messages. However, I also tested the message of his parent form. Even if a modal subform is displayed above, his parent form still obtains the mouse pointer message sent by the system: wm_setcursor.
In this case, there is a compromise. You can capture the messages of the parent form to determine whether the modal subform needs to flash.
Const Int Wm_setcursor = 0x20; Public Mainwindow () {initializecomponent (); This . Loaded + = New Routedeventhandler (mainwindow_loaded );} Void Mainwindow_loaded ( Object Sender, routedeventargs e) {intptr hwnd = New Windowinterophelper ( This ). Handle; hwndsource. fromhwnd (hwnd). addhook ( New Hwndsourcehook (wndproc);} intptr wndproc (intptr hwnd, Int MSG, intptr wparam, intptr lparam, Ref Bool Handled ){ If (MSG = wm_setcursor ){ // 0x202fffe: wm_lbuttonup and hittest // 0x201fffe: wm_lbuttondown and hittest If (Lparam. toint32 () = 0x202fffe | lparam. toint32 () = 0x201fffe ){ If (Win. isactive) win. Blink ();}} Return Intptr. Zero ;}
Refer:
Http://blog.csdn.net/woshinia/article/details/8032183http://blog.csdn.net/Lucifinil_S/article/details/6384111http://social.msdn.microsoft.com/Forums/zh-CN/wpfzhchs/thread/4ca0e954-0536-446c-84af-2c104c5cca6b/