How to flash when the mouse clicks the main form and the modal subwindow is windowstyle. None

Source: Internet
Author: User
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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.