Application of VB neutron classification technology

zhaozj2021-02-11  160

Application of VB neutron classification technology

http://www.tongyi.net Author: The Dragon Views: 372

The principle of sub-classification technology: First get the address where the original window procedure is located, record it, then set all the messages to the message processing we have written, we filter the news, find specific The message is processed, the rest of the return system is determined by the system how to handle it. When we don't need to deal with these specific messages, the interception of the message is canceled, that is, the intercourse classification process.

It usually requires three processes: starting interception, message processing, abort intercept. Program requires a module, declare below the module: 'API function declare function setwindowlong lib "user32" Alias ​​"setwindowlonga" _ (Byval HWnd As Long, Byval Nindex As Long, ByVal dwNewLong As Long) A s 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 the constant Public Const GWL_WNDPROC = (-4) Public Const WM_MOUSEMOVE = & H200 Public Const WM_RBUTTONDOWN = & H204' globally Variables, storage control landmark data public preWinProc as long "Public Function WndProc (Byval Hwnd As Long, Byval WParam As Long, BYVAL LONPARAM As Long, BYVAL LPAR AS Long As long 'intercepted the message stored in the MSG parameter. If msg = wm_rbuttondown life' detected the mouse to the message, here you can join our processing code such as: msgbox "Hello, the mouse right click on the message!" If you don't add any code here, it is equivalent to eating this message. Else 'If we are not the news we need to handle, then send it back to the original program. WndProc = CallWindowProc (PrewinProc, HWND, MSG, WPARAM, LPARAM) Endif End Function 'The following code is in the form:' This example takes a message that intercepts a ComboBox control, assumes the name of the 'control is: Comb1 Private Sub Subclass () DIM RET AS long 'records the address of Window ProCedure preWinProc = getWindowlong (comb1.hwnd, gwl_wndproc) Start intercepting messages, and hand over the message to the WNDPROC process. Ret =

转载请注明原文地址:https://www.9cbs.com/read-5439.html

New Post(0)