![]() |
![]() |
|
![]() |
ActiveX controls - A step by step tutorial © 2001 Peter Zevenaar Expand the scope of your Paradox applications. Play videos, read MP3 tags, use a calendar, or have your computer turned into a web server. These are only few of the possibilities with ActiveX controls... Introduction An ActiveX control is a software component that can interact with other software components, regardless of the language in which the components were created. ActiveX controls make it easy to integrate and reuse software components. Paradox supports the use of ActiveX controls both in the standard version as well as in the Runtime version, but not unconditionally. In Paradox some ActiveX controls work well and straight forward, some can be put to work with some workarounds, and some just don't work. An example of an ActiveX control that works in Paradox is the progress bar which is available in Paradox as a standard. This progress bar is an external software component which can be put in a Paradox form after which Paradox can send commands to it. As a beginning programmer I was confused about ActiveX controls and the related terminology. I hope this article can be helpful for beginning programmers and others who are just starting with ActiveX controls. Terminology: ActiveX, OLE, OCX In the Paradox Help files and other articles, ActiveX controls are also referred to as both OLE and OCX which can be confusing. Some clarification in chronological order: OLE - Object Linking and Embedding. A technology for transferring and sharing information among applications. OCX - OLE Custom Control (not sure where the X comes from) This is a refinement of the traditional OLE-technology and the predecessor of the ActiveX control. ActiveX control - A refinement of the traditional OCX-technology Unlike a traditional OCX, an ActiveX control is self-registering; that is, it can add and remove the necessary information for its use in the target system's registry. In articles and newsgroups posts OCX and ActiveX control are often used to refer to the same thing. ActiveX controls often have the .OCX file extension while they actually are DLLs ( Dynamic Link Library). So, in short: Every OCX uses the OLE-technology, but not every OLE-component is an OCX. Every ActiveX control is an OCX and uses OLE-technology but not every OCX or OLE-component is an ActiveX control. As ActiveX control is the most accurate and specified name for the subject of this article, I will use that term in future references. Six basic steps to make ActiveX controls work in Paradox 1. Find, purchase and/or download the ActiveX control Most ActiveX controls are not more than 100 to 300 KB. On the internet you can find lots of (free) ActiveX controls for download. http://www.Active-X.com offers a wide variety of links to sites to download ActiveX controls from. However, be careful what you download as the files aren't checked and could damage your computer which is your own risk. 2. Install the ActiveX control After obtaining the ActiveX control, install it according to its documentation. This will involve copying the .OCX file and any supporting files to the desired directory. An ActiveX control can consist of the following files:
All ActiveX controls must register important information in the system registry. Registering the control also registers Paradox as an ActiveX automation server. Quite often, simply installing the control does not register it. To make sure the ActiveX control will work, it's good practice to always register it before you start to work with it for the first time, even when the control already shows up in Paradox as registered (see point 4). In Paradox there are two ways to register an ActiveX control:
4. Add the ActiveX control to the Paradox toolbar Once you have installed and registered the control and before you can use it in Paradox, you must add it to the ActiveX Control toolbar. This is a how to do it:
Once the control is placed on the ActiveX control toolbar, you can use it while creating forms just like any other object. Click on the ActiveX control toolbar icon which you just added and click or click-and-drag it in the form. Now you'll see an OLE-field of which the look differs per control. You might see a white OLE-field but you might also see the logo of the ActiveX control. If you right-click the field you will see the ActiveX control's properties. Some ActiveX controls will just show the standard OLE-field properties while others offer extra properties tabs. 6. Program the control using ObjectPAL Once you have completed installing, registering, adding, and placing the control, you are ready to customize it using ObjectPAL. You can set the control's properties, invoke methods, or write event handlers just as you normally do in ObjectPAL. Right-click the OLE-field and choose the object explorer. Walk through the tabs to see what properties, methods and events are available in the ActiveX control. If there's a manual available for the ActiveX control it's good to read it, before using it in Paradox. Further, if you're a ProView user you can use its OLE servers explorer which gives all the info available in the ActiveX control. ProView is a free and alternative Project Viewer from Vladimir Menkin with many extra developer options. You can download it at: http://sheep.east.ru:8100/~menkin/default.html. Example 1 - the standard Progress Bar ActiveX control To get more familiar with how to use ActiveX controls, here's an example of the Progress Bar ActiveX control you can easily try out. It is a built-in Native Windows Control like the List Box, Combo Box, Spin Box, and Trackbar. The Native Window Controls work in Paradox version 5 to 10. For more info about these controls you can download the following newsletter: Corel Paradox 8 Native Windows Controls. Here is the Progress Bar example:
method pushButton(var eventInfo Event) ;/ Set the minimum and maximum values for Progress Bar ;/ and the step value (increment) respectively ProgBar.setRangeAndStep(1, 5, 1) ;/Step the Progress Bar by the step value for i from 1 to 4 ProgBar.stepIt() sleep(500) endfor msgInfo("Result","OK! Click OK to clear Progress Bar.") ;/clear the Progress Bar ProgBar.setRangeAndStep(0, 0, 0) endMethod5. Now run the form and click the pushbutton. If you go back into design mode and you go to the ProgBar in the Object Explorer, you'll see that the Progress Bar has two methods. The red bullets before the methods indicate that they are ActiveX control methods. So, with ProgBar.setRangeAndStep(1, 5, 1) in the above code, Paradox tells the ProgBar to execute the method with the indicated variables 1, 5, and 1. You can use this Progress Bar for instance to indicate how much of your code has been executed. If for instance you run a number of queries you can put the stepIt() method between them to give the user an indication on how much of the code has been processed. For more ActiveX examples, see the table at the end of this article. Additional tips for using ActiveX controls in Paradox The invoke() method and the caret The invoke() method or the caret ^ is especially useful when the ActiveX control has a method name that is similar to an ObjectPAL keyword. For example, Paradox will treat the method add() like the table/tcursor add() rather than the ActiveX control's add(), so you either need to use invoke() or you can use ^ instead. TreeView^add(..), and TreeView.invoke("Add", ...) tell Paradox to use the TreeView ActiveX's add, not Paradox's. Note: According to the Help files invoke() and the caret ^ should work for properties as well, but they don't! Using ActiveX control without putting them on a form In stead of putting an ActiveX control on a form to make it work, you can also use an OLEauto variable in the form or a library and use the ActiveX control from the variable only. This is how you do it: To know what the name is of the desired ActiveX control, enumerate them in a dynamic array by: var daShowAXCntrl Dynarray[] string endvar enumAutomationServers(daShowAXCntrl) daShowAXCntrl.view()The array will show you two columns. Look for the desired control in the left-hand column of the array and use its relative right-hand column's name. In case you choose the Alfafish EzyID33 MP3 ActiveX control, you can put it to use by: var oaMyAXcontrol OLEauto endvar if not oaMyAXcontrol.open("AlfafishEzyID33.EzyID3") then msgStop("Error", "Couldn't open Alfafish ActiveX control.") errorshow() return endifOne caveat: The object's name in the right-hand array column often ends with ".1". In most cases you can leave off the ".1". You have to test it to know which ones. Once you have successfully opened the control, everything else works as it does when you place it as an object on a form - except you can't see it. Multi-controls Some ActiveX controls have controls inside them. The TreeView is a prime example of this. It contains: TreeView -> Nodes (collection of all nodes) -> Node. Sometimes, the control's syntax and/or ObjectPAL will not allow you to get a property or invoke a method for the last object in the control using regular containership syntax. E.g. the following won't work: stText = testTree.Nodes.Node.TextInstead, you have to attach OLEAuto variables: var oaNodes, oaNode OLEAuto endVar oaNodes = testTree.Nodes oaNode = oaNodes.Item(1) ;// where 1 is the index of a node - node #1 stText = oaNode.Text Overview: ActiveX controls that work in Paradox We would like to bring all the ActiveX info related to Paradox together to make it available for the whole Paradox Community. Below is a table which lists all the ActiveX controls that work in Paradox and that are currently known by us. The table is far from complete. Do you know of any other ActiveX controls that work in Paradox? Do you know of another Paradox version which a control already known by us, also works in? Does the control require specific treatment? Do you want to write a manual for a specific ActiveX control? Do you have any additions or improvements regarding this article? Please contact us and send your info or article to Paradox Community to have it added to the site.
This article is based on the Paradox Help files, articles from the internet, newsgroups posts and my own experiences. Thanks to Liz Woodhouse and Tony McGuire for feedback and useful ideas. For more general information about ActiveX controls you can look at http://www.microsoft.com/com/tech/activex.asp. Discussion of this article |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 15 May 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|