NativeWindow is a low-level class provided by the. NET Framework. Microsoft's official explanation is: NativeWindow provides a low-level encapsulation of a window handle and a window procedure. Said these also is equivalent not to say, because Nativewi What Ndow is doing is not clear, it means a lower level. A package of form handles and form procedures. Later, a lot of information was queried to understand the meaning.
Source of information:
Http://www.diybl.com/course/4_webprogram/asp.net/netjs/2007921/72804.html
This explanation is "use NativeWindow monitor WndProc message", this content is relatively long, and more pages, after their own efforts and patience, finally completed the example, the code download address: HTTP://FILES.CNBLOGS.COM/ZHJP11 /Skin/nativewindowapplication.rar
Http://www.codeproject.com/KB/dialog/OpenFileDialogEx.aspx
This article from CodeProject, foreigners write code is more level. The OpenFileDialog subclass of Windows is displayed as a custom OpenFileDialog, and many events are added. Quite a admiration.
After these two carefully read, finally understand the role of NativeWindow, NativeWindow is to provide the bottom of the package, providing the Assignhandle and realesehandle these two methods, mainly to register the form handle the form into Line hook, which processes the events of the form to the Windows processing. Using Refector.net to view the method of Assignhandle in NativeWindow, it also validates my claim. There is a section of code in Assignhandle:
Userdefwindowproc = unsafenativemethods.getprocaddress (New HandleRef (Null,unsafenativemethods.getmodulehandle (" User32.dll ")), lpprocname);
The development of Win32 may know the meaning of this code, he is also a kind of hook. It's just a more advanced way of hook. Here is not to elaborate, we now only know that he can register our registered form to hook, you can load their own code to the location we want it.
Then I use NativeWindow to get all the events of all the forms, and then output the hook to the time, the results are as follows:
This article supporting source code