Interface Development (II)-nativewindow

Source: Internet
Author: User

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

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.