Keyboard Events, mouse events, and drag-and-drop techniques in VB

Source: Internet
Author: User

Keyboard Events:The parameter is keyascii. Each time you press a key on the keyboard, the ASCII value of the corresponding key must be assigned to the parameter keyascii, and then perform the corresponding operation.

Keypreview: accepts Keyboard Events. By default, the keypreview attribute of the form is false, and only the form obtains the focus of the corresponding keyboard event. If the keypreview attribute of the form is true, the form intercepts the keyboard event before it is null.

Shift and 7: Take the lower three digits of the shift parameter, because the binary number of 7 is 111, and the shift parameter and 111 perform the bitwise AND operation to obtain which of the three function keys is pressed.

The default attribute of the command button control is used to set the default command button ., if it is set to true, pressing the [enter] button is equivalent to clicking the button with the mouse, and the cancel attribute is true, the ESC key triggers the Click Event of the button.

The priority of the shortcut key is higher than that of the keyboard event,

Mouse event:

Parameters

Third place

Second place

First

Button

Key

Right-click

Left click

Shift

Shift

CTRL

ALT

Parameters X and Y indicate the cursor position.

CLC: Clear the image.

Line (x1, Y1)-(X2, Y2), [color], [B] [F]

(X1, Y1) is optional. Single (single-precision floating point number), the starting coordinate of a straight line or a rectangle.

(X2, Y2) is required. Single (single-precision floating point number), the ending coordinate of a straight line or rectangle.

Optional. Long (long integer), the RGB color used for line drawing. The RGB function is available.

Optional. If so, a rectangle is drawn using diagonal coordinates.

F is optional. If option B is used, option F specifies that the rectangle is filled with the color of the rectangle border. B rather than F.

Example: Line (0, 0)-(x, y), vbgreen, BF

Drag-and-drop Technology:

Dragmode attribute: 0-manual drag and drop, 1-Automatic drag and drop

Dragdrop event: private sub form_dragdrop (source as control, X as single, y as Single)

Source. Move X, Y

End sub

--- Source indicates the drag-and-drop control, that is, the control whose dragmode attribute is 1; XY indicates the coordinates of the mouse pointer.

Drag method: Format: <Object Name>. Drag [action] example if button = 1 then text1.drag vbbegindrag

If Button = 1 then text1.drag vbenddrag

Dragover event: when the source object is dragged to the target object, the dragover event of the object is triggered. The source parameter indicates the dragged object, the State has three states: benter, bleave, and vbover, which indicate entering, leaving, and passing through objects respectively.

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.