Visual FoxPro HWND Control

See Also

Visual FoxPro includes the HWND ActiveX control (Foxhwnd.ocx) which you can add to and distribute with your applications. ActiveX controls are added to a form in an application with the Visual FoxPro OLE container control.

The HWND ActiveX control provides a window in which other ActiveX controls (such as the Microsoft Multimedia ActiveX control) can display images. Unlike the Visual FoxPro Image control, the HWND ActiveX control can be used to display icon and Windows metafiles.

The following table lists the properties, events, and methods available for the HWND ActiveX control.

Property, Event, or Method Description
Appearance Property Specifies the appearance of the HWND control. Available at design time and run time.

The Appearance property can have the following values:

0 - (Default) Flat.

1 - 3-dimensional.

BackColor Property Specifies the background color of the HWND control. Available at design time and run time.

The BackColor property is a single numeric color value. For more information about color values that can be assigned to the BackColor property, see the Visual FoxPro BackColor, ForeColor Properties topic in Help.

BorderStyle Property Specifies the border style of the HWND control. Available at design time and run time.

The BorderStyle property can have the following values:

0 - (Default) No border.

1 - Single line border.

Picture Property Specifies a picture object reference for the image displayed in the HWND control. Available at design time and run time.

Use LOADPICTURE( ) to create an object reference for a bitmap, icon, or Windows meta file.

HWnd Property Contains the handle to the window of the HWND control. Read-only at runtime.
Click Event Occurs when the user presses and releases the left mouse button while the pointer is over the HWND control.
DblClick Event Occurs when the user presses and releases the left mouse button twice in quick succession over the HWND control.
KeyDown Event Occurs when the user presses a key when the HWND control has the focus. Two parameters, keycode and shift, are passed to the KeyDown event.

Keycode Contains a number which identifies the key pressed. For a list of codes for special keys and key combinations, see INKEY( ).

Shift Sets a bit if the key is pressed. This parameter is the sum of the bits, 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. This parameter indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys is pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

KeyPress Event Occurs when the user presses and releases a key when the HWND control has the focus. One parameter, keyascii, is passed to the KeyPress event.

Keyascii Contains a number which identifies the key pressed and released. For a list of codes for special keys and key combinations, see INKEY( ).

KeyUp Event Occurs when the user releases a key when the HWND control has the focus.

Two parameters, keycode and shift, are passed to the KeyUp event.

Keycode Contains a number which identifies the key released. For a list of codes for special keys and key combinations, see INKEY( ).

Shift Sets a bit if the key is released. This parameter is the sum of the bits, 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. This parameter indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys is pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

MouseDown Event Occurs when the user presses a mouse button while the pointer is over the HWND control.

Four parameters, button, shift, x, and y, are passed to the MouseDown event.

Button Contains a number which specifies which button was pressed to trigger the event: 1 (left), 2 (right), or 4 (middle).

Shift Contains a number which specifies the state of the SHIFT, CTRL, and ALT keys when the button specified in the button argument was pressed.

A bit is set if the key is down. The shift argument is the sum of the bits, 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. The shift parameter indicates the state of these keys. 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 Contains the current horizontal (x) and vertical (y) position of the mouse pointer within the Form. These coordinates are always expressed in terms of the Form's coordinate system specified, in the unit of measurement specified ScaleMode property setting.

MouseMove Event Occurs when the user moves the mouse over the HWND control. The MouseMove event is triggered continually as the mouse pointer moves across the HWND control.

Four parameters, button, shift, x, and y, are passed to the MouseMove event.

Button Contains a number which specifies the state of the mouse buttons as a sum of bits: 1 (left), 2 (right), or 4 (middle).

Shift Contains a number which specifies the state of the SHIFT, CTRL, and ALT keys: 1 (SHIFT), 2 (CTRL), 4 (ALT). A bit is set if the key is down. The shift parameter is the sum of the bits, 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. shift indicates the state of these keys. 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 Contains the current horizontal (x) and vertical (y) position of the mouse pointer within the form. These coordinates are always expressed in terms of the form's coordinate system specified, in the unit of measurement specified ScaleMode property setting.

MouseUp Event Occurs when the user releases a mouse button while the pointer is over the HWND control.

Four parameters, button, shift, x, and y, are passed to the MouseUp event.

Button Contains a number which specifies which button was released to trigger the event: 1 (left), 2 (right), or 4 (middle).

Shift Contains a number which specifies the state of the SHIFT, CTRL, and ALT keys when the button specified in the button argument was released.

A bit is set if the key is down. The shift argument is the sum of the bits, 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. The shift parameter indicates the state of these keys. 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 Contains the current horizontal (x) and vertical (y) position of the mouse pointer within the form. These coordinates are always expressed in terms of the form's coordinate system specified, in the unit of measurement specified ScaleMode property setting.

Paint Event Occurs when the HWND control requires repainting. The RestoreDisplay method is typically executed in the Paint event code.
RestoreDisplay Method Restores the image stored to memory with the SaveDisplay method.
SaveDisplay Method Save the currently displayed image to memory.

Note that if a toolbar or a form with the AlwaysOnTop property set to true (.T.) is over the HWND control when the SaveDisplay method is executed, the image of the toolbar or form is saved with the image in the HWND control.


For additional information about adding ActiveX controls to your applications, see Chapter 16, Adding OLE, in the Programmer’s Guide.