Working with ActiveX and Native Windows Controls

ActiveX controls and Native Window Controls are reusable software components that you can embed in Paradox forms in to provide added functionality. ActiveX controls can include complex miniature applications, such as an Internet Web browser or a list box.

You can interact with ActiveX controls at runtime by writing ObjectPAL code to get and set properties, invoke methods, and handle events.

In this section, you'll learn about

  registering ActiveX controls
  
  displaying and modifying the ActiveX control toolbar
  
  adding an ActiveX or Native Windows Control to a form
  
  editing events on an ActiveX control
  
For more information about ActiveX and Native Windows Controls, see Reference: ActiveX and Native Windows Controls.

Registering ActiveX controls

ActiveX controls are available from third-party vendors. Before you can use a control you must register it with Paradox. When you register an ActiveX control, it is added to the system registry and you can then add it to the ActiveX control toolbar. Once the control is added to the ActiveX control toolbar, you can add it to a form. For more information about adding a control to the ActiveX control toolbar, see "To add a control to the ActiveX control toolbar."

Native Windows Controls do not need to be registered because they are installed with Paradox.

To register an ActiveX control

1	Click Tools  Register ActiveX control.

2	Choose the drive and folder where the ActiveX control is stored.

3	Click the ActiveX control.

This registers the control and registers Paradox as an ActiveX automation server.

Displaying and modifying the ActiveX control toolbar

To add an ActiveX control to a form, you must display the ActiveX control toolbar, and the control must be displayed on the toolbar. Once the ActiveX control toolbar is displayed, you can add additional ActiveX controls to the toolbar. You can also remove controls from the toolbar.

Native Windows Controls do not need to be added to the toolbar because they are automatically installed with Paradox.

To display the ActiveX control toolbar

1	Click View  Toolbars.

2	Enable the ActiveX control check box.

To add a control to the ActiveX control toolbar

1	In the form design window, click Tools  Add ActiveX control.

2	Choose a control from the Object type list.

Note

  Native Windows Controls do not need to added to the toolbar because they are installed with Paradox.
  
To remove a control from the ActiveX Control toolbar

1	In the form design window, click Tools  Remove ActiveX control.

2	Choose a control from the Object toolbar list.

3	Click Remove.

Adding an ActiveX or Native Windows Control to a form

You can add ActiveX or Native Windows Controls to a form.

Each ActiveX control contains methods, properties, or events, which you can set and call when you design or run a form. Because ActiveX controls are a separate application running as a subprocess of Paradox, the controls may behave differently than a Paradox UIObject. Each ActiveX control has its own child window on the form and its own message queue. This gives the ActiveX control its own event model, which is sometimes called the "fire event" model. For more information about editing ActiveX control events, see "Editing events on an ActiveX control."

In addition, Paradox includes five Native Windows Controls (NWC). These are created using property, method, and event specifications from OLE embedding. You can link them as a hybrid between traditional Paradox controls and regular ActiveX controls, because they follow similar specifications.

The Application Program Interface (API) for Native Windows Controls is directly ported from the Windows API. These controls are wrapped in an ActiveX container in Paradox; therefore, they behave just like an ActiveX control. The ActiveX wrapper governs the size, position, and frame style. It also provides its hooks to ObjectPAL. NWCs use the same technique as regular ActiveX controls (OleAuto type) to set and get properties and to invoke methods. The NWC properties, methods, and events are visible in the Object explorer, but cannot be set there. Their properties must be manipulated through ObjectPAL or interactively using the Object explorer. Native Windows Controls do not need to be installed, registered, or added to the toolbar because they are installed with Paradox.

Native Windows Controls look like ActiveX controls to the Paradox form and language system. The same programming concepts that apply to ActiveX controls apply to Native Windows Controls. However, NWCs do not use OLE embedding or support any kind of user interface negotiation.

To add an ActiveX Control or Native Windows Control to a form

1	In the form design window, click a tool on the ActiveX control toolbar.

2	Drag the ActiveX pointer in the form design window.

If you want to resize the ActiveX control object, point to a selection handle a drag it.

Note

  For information about the ActiveX controls that are included with Paradox, see "Controls included with Paradox."
  
Editing events on an ActiveX control

You can edit the manner in which Paradox responds to an event controlled by an ActiveX control by editing the event's code in the Object explorer. To interact with ActiveX controls at runtime, you can write ObjectPAL code to get and set properties, invoke methods, and handle events. You can refer to the UIObject name that hosts the ActiveX control directly or you can use the OleAuto ObjectPAL type. The OleAuto type lets you communicate with an OLE server and ActiveX control, and Native Window Controls, by translating ObjectPAL into OLE automation calls.

Because ActiveX controls are a separate application running as a subprocess of Paradox, the controls may behave differently than a Paradox UIObject. Each ActiveX control has its own child window on the form and its own message queue. This gives the ActiveX control its own event model, which is sometimes called the "fire event" model.

ActiveX controls are said to "fire" events; notifications display that something is about to happen (before event), is happening (do event), has just occurred (after event), or requests to determine if an impending action is permissible (request event).

An ActiveX control application will often fire an event without asking first if it is acceptable to fire such an event. This is the way that the ActiveX control specification is written. You cannot use ObjectPAL to intercept events that are going to an ActiveX control application, for example, you cannot disable a mouseClick on an ActiveX control.

To edit events on an ActiveX control

1	In the form design window, click the ActiveX control.

2	Click Tools  Object explorer.

3	Click the Events tab.

4	Double-click an event.

5	In the Editor window, edit the event.

Note

  For more information about editing events, see the "ObjectPAL online reference."
  
Reference: ActiveX and Native Windows Controls

This topic contains reference information pertaining to ActiveX and Native Windows Controls.

Controls included with Paradox

The following ActiveX and Native Windows Controls are provided with Paradox.

 List Box	A Native Windows Control that allows single or multiple selections

 Combo Box	A Native Windows Control with an edit region and a list box

 Spin Box	A Native Windows Control with Up and Down buttons to increase or decrease the value

 Progress Bar	A Native Windows Control used to track the completeness of a process

 Trackbar	A Native Windows Control that allows you to drag a pointer along a track to set numerical values

 Paradox VCR Control	An ActiveX control used to move through records in forms

ActiveX control event types

ActiveX controls have events that are different from Paradox events. Each control comes with a primary event set that follows a basic convention for what types of events are fired and how the event parameters are packaged. If the default event type for the control can be canceled, you can modify the event parameters to make the control behave the way you want.

ActiveX controls can issue events, such as click events. The names of the events issued by a control are chosen by the creator of the control. You can see the names of the events in the tabbed pane of the Object explorer on the Events page. All methods, events, and properties that come with a control are displayed in red text in the Object explorer and are preceded by a round button. These methods, events, and properties will also be listed in the documentation for the control.

Controls usually follow a naming convention for their events. For example, Do events begin with the word Do, and Request events begin with the word Request. Because After events are the most common, any event that does not begin with one of the other type names is assumed to be an After event.

ActiveX control events fall into four basic categories: Request events, Before events, After events, and Do events. Of the four types of controls, Before and After events cannot be canceled.

Request events

A control fires a Request event to determine if an impending action is permissible and allows the user to cancel an action. Request events can be canceled.

Before events

Before events are notifications that something is about to happen. They are fired before an action occurs to allow the completion of actions that are needed before the event fires. Before events cannot be canceled.

Do events

Do events are notifications that something is happening. They are fired to allow the user to replace or supplement the control's default behavior. Do events can be canceled. Do events usually begin with the word Do, and the last parameter is the cancel flag.

After events

After events are notifications that something has just occurred. They are fired after an action occurs to allow response to the action. After events cannot be canceled.

Most real controls only do the After event. For example, a typical control issues only one event for a click. The event would be called Click, comes after the click has happened, and cannot be canceled.

Some controls will issue a series of related events. For example, for the Click event, you could see the following events:

  RequestClick (Request event)
  
  BeforeClick (Before event)
  
  DoClick (Do event)
  
  Click (After event)
  
Ambient properties

Ambient properties are properties a control adopts from its container. For example, an ActiveX control placed on a yellow form obtains information about the form's properties, determines that it can use the yellow background color, and incorporates the form's background color into its properties, along with any other properties it can use, such as foreground color and text font.

Ambient properties can be set for each control, but ActiveX controls are not required to use these properties. Therefore, not all controls will respond to changes in these ambient properties.

Ambient properties give information about the state of the container around the control. This can be the entire container (such as the background color) or the immediate area surrounding the control. For example, a control can be inserted into a text document that will have different sized fonts. The ambient font property of the control has different values, depending on where the control is placed. 




