How to get a method for processing the form movement event

zhaozj2021-02-16  53

In the VB event, there is no corresponding processing event interface when the form moves. however

Sub-processing can be utilized. The specific idea is to use subclasses to obtain WM-MOVE messages

Then pass a message to a normal form, using the event interface of the button to simulate the simulation of the form mobile event: The specific implementation code is as follows:

Add a button to the form, named EventBn to use the EventBN_Click () event to implement the processing of the form mobile event /

The module code is as follows:

Public Oldproc As Long

Public BnhWnd As Long

Public Function NewProc (Byval Hwnd As Long, Byval Msg As Long, Byval LP as long) As long

IF MSG = WM_MOVE THEN 'Capture Form Mobile Event

SendMessage Bnhwnd, WM_LButtondown, 1,0

SendMessage BnhWnd, WM_LBUTTONUP, 1, 0 'Send the message to the button, make it Click event

END IF

NewProc = CallWindowProc (OldProc, HWND, MSG, WP, LP)

END FUNCTION

Form within the form:

Private sub flow_load ()

Bnhwnd = Eventbn.hwnd 'Get the British

OldProc = setWindowlong (me.hwnd, gwl_wndproc, addressof newproc)

End Sub

Private sub EventBn_Click ()

'Add a form mobile code here

End Sub

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

New Post(0)