|
Click, DblClick, Hide,
KeyDown, KeyPress, KeyUp,
MouseDown, MouseIn, MouseMove,
MouseOut, MouseUp, Paint,
Resize, Show
Description
Occurs when the user presses and then releases a mouse button over an object.
Syntax
object_Click ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
Typically, you attach a Click event procedure to a control to carry out commands and
command-like actions.
Clicking a control generates MouseDown and MouseUp
events in addition to the Click event.
When you're attaching event procedures for these related events, be sure that their
actions don't conflict.
Note: To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.
If there is code in the Click event, the DlbClick event will
never trigger, because the Click event is the first event to trigger between the two. As a
result, the mouse click is intercepted by the Click event, so the DblClick
event doesn't occur.
Back to top
Description
Occurs when the user presses and releases a mouse button and then presses and releases
it again over an object.
Syntax
object_DblClick ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
You can use a DblClick event procedure for an implied action, such as double-clicking
an icon to open a window or document.
Mouse events occur in this order: MouseDown, MouseUp, Click, DblClick, and MouseUp.
If DblClick doesn't occur within the system's double-click time limit, the object
recognizes another Click event. The double-click time limit may vary
because the user can set the double-click speed in the Control Panel. When you're
attaching procedures for these related events, be sure that their actions don't conflict.
Controls that don't receive DblClick events may receive two clicks instead of a DblClick.
Note: To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.
If there is code in the Click event, the DlbClick event will never
trigger.
Back to top
Description
Occurs when the objects Visible property changes to False.
Syntax
object_Hide ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
In order to draw to the screen in Windows, any object must have a window, temporarily
or permanently; GT Image controls have permanent windows. Before a control has been sited
on a form, its window is not on the container. The control receives Hide events when the
window is removed.
While the controls window is on the form, the object receives a Hide event when
the controls Visible property changes to False.
The control does not receive Hide events if the form is hidden and then shown again, or
if the form is minimized and then restored. The controls window remains on the form
during these operations, and its Visible property doesnt change.
If the control is being shown in an internet browser, a Hide event occurs when the page
is moved to the history list.
If the control is used with earlier versions of Visual Basic than 5.0, the control will
not receive Hide events at design time. This is because earlier versions of Visual Basic
did not put any visible windows on a form at design time.
Back to top
Description
Occurs when the user presses a key while an object has the focus. (To interpret ANSI
characters, use the KeyPress event.)
Syntax
object_KeyDown (keycode, shift)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| keycode |
A key code, such as vbKeyF1 (the F1 key) or
vbKeyHome (the HOME key). To specify key codes, use
the constants in the Visual Basic (VB) object library in the
Object Browser. |
| shift |
An integer that corresponds to the state of the SHIFT, CTRL,
and ALT keys at the time of the event. The shift argument is a
bit field with the least-significant bits corresponding to the
SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key
(bit 2 ). These bits correspond to the values 1, 2, and 4,
respectively. Some, all, or none of the bits can be set,
indicating that some, all, or none of the keys are pressed.
For example, if both CTRL and ALT are pressed, the value
of shift is 6. |
Remarks
See KeyUp.
Back to top
Description
Occurs when the user presses and releases an ANSI key.
Syntax
object_KeyPress (keyascii)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| keyascii |
An integer that returns a standard numeric ANSI keycode.
Keyascii is passed by reference; changing it sends a
different character to the object. Changing keyascii to 0
cancels the keystroke so the object receives no character. |
Remarks
The object with the focus receives the event. A KeyPress event can involve any
printable keyboard character, the CTRL key combined with a character from the standard
alphabet or one of a few special characters, and the ENTER or BACKSPACE key. A KeyPress
event procedure is useful for intercepting keystrokes entered in a control. It enables you
to immediately test keystrokes for validity or to format characters as they're typed.
Changing the value of the keyascii argument changes the character displayed.
You can convert the keyascii argument into a character by using the expression:
Chr(KeyAscii)
You can then perform string operations and translate the character back to an ANSI
number that the control can interpret by using the expression:
KeyAscii = Asc(char)
Use KeyDown and KeyUp event procedures to
handle any keystroke not recognized by KeyPress, such as function keys, editing keys,
navigation keys, and any combinations of these with keyboard modifiers. Unlike the KeyDown and KeyUp events, KeyPress doesn't
indicate the physical state of the keyboard; instead, it passes a character.
KeyPress interprets the uppercase and lowercase of each character as separate key codes
and, therefore, as two separate characters. KeyDown and KeyUp interpret the uppercase and lowercase of each character by means
of two arguments: keycode, which indicates the physical key (thus returning A and a as the
same key), and shift, which indicates the state of shift+key and therefore returns either
A or a.
If the KeyPreview property is set to True, a form receives the event before controls on
the form receive the event. Use the KeyPreview property to create global keyboard-handling
routines.
Note The ANSI number for the keyboard combination of CTRL+@ is 0. Because a keyascii
value of 0 is recognizes as a zero-length string (""), avoid using CTRL+@ in
your applications.
Back to top
Description
Occurs when the user releases a key while an object has the focus. (To interpret ANSI
characters, use the KeyPress event.)
Syntax
object_KeyUp (keycode, shift)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| keycode |
A key code, such as vbKeyF1 (the F1 key) or
vbKeyHome (the HOME key). To specify key codes, use
the constants in the Visual Basic (VB) object library in the
Object Browser. |
| shift |
An integer that corresponds to the state of the SHIFT, CTRL,
and ALT keys at the time of the event. The shift argument is a
bit field with the least-significant bits corresponding to the
SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key
(bit 2 ). These bits correspond to the values 1, 2, and 4,
respectively. Some, all, or none of the bits can be set,
indicating that some, all, or none of the keys are pressed.
For example, if both CTRL and ALT are pressed, the value
of shift is 6. |
Remarks
For both KeyDown and KeyUp events, the object with the focus
receives all keystrokes. Although the KeyDown and KeyUp events can
apply to most keys, they're most often used for:
- Extended character keys such as function keys.
- Navigation keys.
- Combinations of keys with standard keyboard modifiers.
- Distinguishing between the numeric keypad and regular number keys.
Use KeyDown and KeyUp event procedures if you need to respond to
both the pressing and releasing of a key.
KeyDown and KeyUp aren't invoked for:
- The ENTER key if the form has a CommandButton control with the Default property set to
True.
- The ESC key if the form has a CommandButton control with the Cancel property set to
True.
- The TAB key.
KeyDown and KeyUp interpret the uppercase and lowercase of each
character by means of two arguments: keycode, which indicates the physical key (thus
returning A and a as the same key) and shift, which indicates the state of shift+key and
therefore returns either A or a.
If you need to test for the shift argument, you can use the shift values which define
the bits within the argument:
| Value |
Description |
| 1 |
SHIFT key bit mask. |
| 2 |
CTRL key bit mask. |
| 4 |
ALT key bit mask. |
You test for a condition by first assigning each result to a temporary integer variable
and then comparing shift to a bit mask. Use the And operator with the shift argument to
test whether the condition is greater than 0, indicating that the modifier was pressed, as
in this example:
ShiftDown = (Shift And 1) > 0
In a procedure, you can test for any combination of conditions, as in this example:
If ShiftDown And CtrlDown Then
Note: If the KeyPreview property is set to True, a form receives these events before
controls on the form receive the events. Use the KeyPreview property to create global
keyboard-handling routines.
Back to top
Description
Occurs when the user presses a mouse button.
Syntax
object_MouseDown (button, shift, x,
x)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| button |
Returns an integer that identifies the button that was pressed
to cause the event. The button argument is a bit field with bits
corresponding to the left button (bit 0), right button (bit 1),
and middle button (bit 2). These bits correspond to the values
1, 2, and 4, respectively. Only one of the bits is set, indicating
the button that caused the event. |
| shift |
An integer that corresponds to the state of the SHIFT, CTRL,
and ALT keys at the time of the event. The shift argument is a
bit field with the least-significant bits corresponding to the
SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key
(bit 2 ). These bits correspond to the values 1, 2, and 4,
respectively. Some, all, or none of the bits can be set,
indicating that some, all, or none of the keys are pressed.
For example, if both CTRL and ALT are pressed, the value
of shift is 6. |
| x, y |
Returns a number that specifies the current location of the
mouse pointer. The x and y values are always expressed in
terms of the coordinate system set by the ScaleHeight,
ScaleWidth, ScaleLeft,
and ScaleTop properties of the object. |
Remarks
See MouseUp.
Back to top
Description
Occurs when the mouse moves into the control..
Syntax
object_MouseIn ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
None.
Back to top
Description
Occurs when the user moves the mouse.
Syntax
object_MouseMove (button, shift, x,
x)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| button |
Returns an integer that identifies the button that was pressed
to cause the event. The button argument is a bit field with bits
corresponding to the left button (bit 0), right button (bit 1),
and middle button (bit 2). These bits correspond to the values
1, 2, and 4, respectively. Only one of the bits is set, indicating
the button that caused the event. |
| shift |
An integer that corresponds to the state of the SHIFT, CTRL,
and ALT keys at the time of the event. The shift argument is a
bit field with the least-significant bits corresponding to the
SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key
(bit 2 ). These bits correspond to the values 1, 2, and 4,
respectively. Some, all, or none of the bits can be set,
indicating that some, all, or none of the keys are pressed.
For example, if both CTRL and ALT are pressed, the value
of shift is 6. |
| x, y |
Returns a number that specifies the current location of the
mouse pointer. The x and y values are always expressed in
terms of the coordinate system set by the ScaleHeight,
ScaleWidth, ScaleLeft,
and ScaleTop properties of the object. |
Remarks
The MouseMove event is generated continually as the mouse pointer moves across objects.
Unless another object has captured the mouse, an object recognizes a MouseMove event
whenever the mouse position is within its borders.
The button argument for MouseMove differs from the button argument for MouseDown and MouseUp. For MouseMove, the
button argument indicates the current state of all buttons; a single MouseMove event can
indicate that some, all, or no buttons are pressed. For MouseDown
and MouseUp, the button argument indicates exactly one button per
event.
Any time you move a window inside a MouseMove event, it can cause a cascading event.
MouseMove events are generated when the window moves underneath the pointer. A MouseMove
event can be generated even if the mouse is perfectly stationary.
See MouseUp.
Back to top
Description
Occurs when the mouse moves out of the control..
Syntax
object_MouseOut ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
None.
Back to top
Description
Occurs when the user releases a mouse button.
Syntax
object_MouseUp (button, shift, x, x)
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
| button |
Returns an integer that identifies the button that was released
to cause the event. The button argument is a bit field with bits
corresponding to the left button (bit 0), right button (bit 1),
and middle button (bit 2). These bits correspond to the values
1, 2, and 4, respectively. Only one of the bits is set, indicating
the button that caused the event. |
| shift |
An integer that corresponds to the state of the SHIFT, CTRL,
and ALT keys at the time of the event. The shift argument is a
bit field with the least-significant bits corresponding to the
SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key
(bit 2 ). These bits correspond to the values 1, 2, and 4,
respectively. Some, all, or none of the bits can be set,
indicating that some, all, or none of the keys are pressed.
For example, if both CTRL and ALT are pressed, the value
of shift is 6. |
| x, y |
Returns a number that specifies the current location of the
mouse pointer. The x and y values are always expressed in
terms of the coordinate system set by the ScaleHeight,
ScaleWidth, ScaleLeft,
and ScaleTop properties of the object. |
Remarks
Use a MouseDown or MouseUp event procedure to specify actions
that will occur when a given mouse button is pressed or released. Unlike the Click and DblClick events, MouseDown
and MouseUp events enable you to distinguish between the left, right, and middle mouse
buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL,
and ALT keyboard modifiers.
The following applies to both Click and DblClick
events:
- If a mouse button is pressed while the pointer is over a control, that object
"captures" the mouse and receives all mouse events up to and including the last
MouseUp event. This implies that the x, y mouse-pointer coordinates returned by a mouse
event may not always be in the internal area of the object that receives them.
- If mouse buttons are pressed in succession, the object that captures the mouse after the
first press receives all mouse events until all buttons are released.
If you need to test for the button or shift arguments, you can use the values which
define the bits within the argument:
| Value |
Description (button) |
| 1 |
Left button is pressed. |
| 2 |
Right button is pressed. |
| 4 |
Middle button is pressed.
|
| Value |
Description (shift) |
| 1 |
SHIFT key bit mask. |
| 2 |
CTRL key bit mask. |
| 4 |
ALT key bit mask. |
The values then act as bit masks you can use to test for any combination of buttons
without having to figure out the unique bit field value for each combination.
You test for a condition by first assigning each result to a temporary integer variable
and then comparing the button or shift arguments to a bit mask. Use the And operator with
each argument to test if the condition is greater than zero, indicating the key or button
is pressed, as in this example:
LeftDown = (Button And 1) > 0
CtrlDown = (Shift And 2) > 0
Then, in a procedure, you can test for any combination of conditions, as in this
example:
If LeftDown And CtrlDown Then
Note: You can use a MouseMove event procedure to respond to an
event caused by moving the mouse. The button argument for MouseDown
and MouseUp differs from the button argument used for MouseMove.
For MouseDown and MouseUp, the button argument indicates exactly
one button per event, whereas for MouseMove, it indicates the
current state of all buttons.
Back to top
Description
Occurs when part or all of an object is exposed after being moved or enlarged, or after
a window that was covering the object has been moved.
Syntax
object_Paint ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
A Paint event procedure is useful if you have output from graphics methods in your
code. With a Paint procedure, you can ensure that such output is repainted when necessary.
The Paint event is invoked when the Refresh method is
used. If the AutoRedraw property is set to True,
repainting or redrawing is automatic, so no Paint events are necessary.
Using a Refresh method in a Resize
event procedure forces repainting of the entire object every time a user resizes the form.
Note Using a Paint event procedure for certain tasks can cause a cascading event. In
general, avoid using a Paint event procedure to do the following:
- Move or size a control.
- Change any variables that affect size or appearance, such as setting an object's BackColor property.
- Invoke a Refresh method.
A Resize event procedure may be more appropriate for some of
these tasks.
Back to top
Description
Occurs when an object is first displayed or when the window state of an object changes.
(For example, a form is maximized, minimized, or restored.)
Syntax
object_Resize ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
Use a Resize event procedure to move or resize controls when the parent form is
resized. You can also use this event procedure to recalculate variables or properties,
such as ScaleHeight and ScaleWidth, that may depend on the size of the form. If
you want graphics to maintain sizes proportional to the form when it's resized, invoke the
Paint event by using the Refresh
method in a Resize event procedure.
Whenever the AutoRedraw property is set to False
and the form is resized, the related events, Resize and Paint, are
also call, in that order. When you attach procedures for these related events, be sure
their actions don't conflict.
Back to top
Description
Occurs when the objects Visible property changes to True.
Syntax
object_Show ( )
| Part |
Description |
| object |
an object expression that evaluates to a gtimage control. |
Remarks
In order to draw to the screen in Windows, any object must have a window, temporarily
or permanently. GT Image controls have permanent windows. Before a control has been sited
on a form, its window is not on the container. The control receives Show events when the
window is added.
While the controls window is on the form, the control receives a Show event when
the controls Visible property changes to True.
The control does not receive Show events if the form is hidden and then shown again, or
if the form is minimized and then restored. The controls window remains on the form
during these operations, and its Visible property doesnt change.
If the control is being shown in an internet browser, a Show event occurs if the user
returns to the page containing the control.
If the control is used with earlier versions of Visual Basic than 5.0, the control will
not receive Show events at design time. This is because earlier versions of Visual Basic
did not put any visible windows on a form at design time.
Back to top |