Nativewindow is an underlying class provided by. NET Framework. Microsoft's official explanation is: nativewindow provides a low-level encapsulation of a window handle and a window procedure. this is equivalent to not speaking, because nativewindow does not clearly understand what it is, which means a low-level encapsulation of the form handle and form process. Later, I found a lot of materials to understand the meaning of the materials.
Source:
Http://www.diybl.com/course/4_webprogram/asp.net/netjs/2007921/72804.html
This article describes how to use nativewindow to monitor wndproc messages. The content is long and the number of pages is large. after hard work and patience, we finally completed the example,Code:/Files/zhjp11/skin/nativewindowapplication.rar
Http://www.codeproject.com/KB/dialog/OpenFileDialogEx.aspx
This article is from codeproject. The code written by foreigners is relatively good. The openfiledialog subclass of Windows is displayed as a custom openfiledialog, and many events are added. Very admired.
After carefully reading these two articles, I finally learned about the role of nativewindow. nativewindow provides the underlying encapsulation and assignhandle and realesehandle methods, it mainly hooks the forms that have registered the form handle, and submits the events of the forms to Windows for processing. I used refector.net to view the assignhandle method in nativewindow and verified my statement. There is such a code in assignhandle:
Userdefwindowproc = Unsafenativemethods. getprocaddress ( New Handleref ( Null , Unsafenativemethods. getmodulehandle ( " User32.dll " ), Lpprocname );
For Win32 developers, we may all know the meaning of this Code, which is also a kind of hook. But it is a more advanced Hook method. Here we will not go into detail. Now we only need to know that he can hook the form we registered and load our code to the desired position.
Then I use nativewindow to get all the events of all forms, and then output the hook time. The result is as follows:
The download code is as follows:/Files/zhjp11/skin/skinengines20100319.rar