Application of neutron classification technology in VB

Source: Internet
Author: User
Tags requires

The principle of sub-classification technology: To get the original window procedure address, record it, and then set all the messages are transferred to the message we write process, we filter the message sent over to find a specific message for processing, the rest of the system, the system decided how to deal with. When we do not need to process these specific messages, we cancel the interception of the message, that is, abort the subcategory process. It generally requires three processes: Start the interception, message processing, stop interception.

The program requires a module, which is declared as follows in the module:

' API functions Declare function SetWindowLong Lib "user32" Alias "Setwindowlonga" _

(ByVal hwnd As Long, ByVal nindex as Long, ByVal Dwnewlong as Long) A Long Declare Function getwindowlong Lib "user32" Alias "Getwindowlonga" _

(ByVal hwnd As Long, ByVal nindex as Long) As Long Declare Function callwindowproc Lib "user32" Alias "Callwindowproca" _

(ByVal Lpprevwndfunc as Long, ByVal hwnd as Long, ByVal Msg as Long, _

ByVal WParam as Long, ByVal LParam as long) as long

' Define constant Public Const GWL_WNDPROC = ( -4) Public Const WM_MOUSEMOVE = &h200 Public Const WM_RBUTTONDOWN = &h204

' global variable, holding control's flag data public Prewinproc as Long

' This function is the public function WndProc of the message that was intercepted when the subcategory was received (ByVal hwnd as Long, ByVal Msg as Long, _

ByVal WParam as Long, ByVal LParam as Long) as

Long

The intercepted message is stored in the MSG parameter.

If Msg=wm_rbuttondown Then

' The right mouse click message is detected, and here we can add our processing code such as:

MsgBox "Hello, mouse right click Message!"

' Note that if you don't add any code here, it's equivalent to eating this message. Else

' If we're not the message we need to process, we'll send it back to the original program.

WndProc = CallWindowProc (Prewinproc, hwnd, MSG, WParam, LParam) endif end Function

++++++++++++++++++++++++++++++++++++++++++++++++++++

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.