Kbase 16878: ACTIVEX - Frequently Asked Questions
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/15/2008 |
|
Status: Verified
GOAL:
ACTIVEX - Frequently Asked Questions
FACT(s) (Environment):
Progress 8.2A
FIX:
Does Version 8.2A support Named Arguments?
Some Automation Objects and ActiveX Controls allow the usage of Named
Arguments in their method calls. Named Arguments allow the developer to
specify the name of the argument and its value during method calls, allowing
arguments to be passed in an arbitrary order. PROGRESS Version 8.2A does not
support Named Arguments; it is necessary to put arguments in the order
specified by the method definition.
DEFINE VARIABLE ch AS COM-HANDLE NO-UNDO.
CREATE "My.App" ch.
ch:Validate(arg1val, arg2val) /* Works */
ch:Validate(arg2=arg2val, arg1=arg1val) /* Not Supported */
Support for Named Arguments is under evaluation for a future release.
Does Version 8.2A support default properties and methods?
Some Automation Objects and ActiveX Controls support a default property
or method. In Version 8.2A, properties and methods need to be explicitly
accessed. An example of this is the Item property which is usually the
default for an ActiveX Collection.
DEFINE VARIABLE ch AS COM-HANDLE NO-UNDO.
CREATE "My.App" ch.
ch:GetCollection:Item(1) /* Necessary to access first item */
/* in the collection */
ch:GetCollection(1) /* Not Supported */
Support for default properties and methods is under evaluation for a future release.
What Automation Servers are certified for use with Version 8.2A?
Progress has tested Version 8.2A with:
- Microsoft Office 95 Professional
- Microsoft Office 97 Professional
Progress has also done limited testing of Version 8.2A with:
- Visio 4.1
- Microsoft SQLServer 6.5
- Microsoft Visual SourceSafe 5.0
- Automation Servers created with Microsoft Visual Basic 4 & 5
What ActiveX Controls are certified for use with Version 8.2A?
Progress has tested Version 8.2A with:
- Crescent SpinBox
- Crescent ComboBox
- PROGRESS Timer
Progress has also done limited testing of Version 8.2A with:
- Crescent Internet ToolPak 3.0
- Crescent PDQComm 3.2
- Crescent PowerPak Pro 2.0
- Crescent VB/J++ (ActiveX Controls)
- AddSoft Schedule/OCX
- Apex TrueDBGrid 4.0
- Data Dynamics ActiveBar
- FarPoint Spread 2.5
- MicroHelp OLE Tools 5.0
- Microsoft Internet Explorer Control
- Microsoft Common Dialog Controls
- Microsoft Windows Common Controls (I & II)
- Pinnacle-BPS Graph Control
- Sheridan Developers Toolkit
- VideoSoft VSFlex
- VideoSoft VSView/OCX
- VideoSoft VS-OCX
- Controls packaged in Microsoft Visual Basic 4.0 and 5.0
- ActiveX Controls created with Microsoft Visual Basic 5.0
If an ActiveX Control is certified to work with Visual C++ by the control
vendor it will most likely work in Version 8.2A (see next question). Consult
the Version 8.2A Release Notes for late breaking information.
What classes of ActiveX Controls are unsupported in this release?
Version 8.2A does not support the following classes of controls:
- Container Controls (example: Frame). Tab Controls are known
to work in this release as long as the display of the
controls in each Tab is managed by the 4GL application.
- Data Bound Controls (that do not work in an unbound mode).
Most Data Bound Controls provide functionality that is
independent of being used in a Data Bound scenario.
- Data Controls.
This is due to the restriction that a control-frame can hold only a single
c.ontrol. We anticipate to support multi-control control-frames in a future
release.
What special processing is required for COM-HANDLE event parameters?
If you have an event handling procedure that takes a COM-HANDLE event
parameter, it may require special processing:
- INPUT COM-HANDLE parameter
You must release the COM-HANDLE before the event procedure
terminates. However, if you save the COM-HANDLE in another
variable for use outside the procedure, release it later in
the application when it is no longer needed.
CAUTION: Saving the COM-HANDLE for later use is not
recommended because some Servers will not handle
this gracefully (they do not follow the COM standard).
- INPUT-OUTPUT COM-HANDLE parameter
You must release the COM-HANDLE before assigning a new value
to it. The same rules and caution apply as for INPUT
COM-HANDLE parameters stated above.
Is it safe to reuse COM-HANDLE variables in my program?
It is safe to reuse a COM-HANDLE variable for a new object if you follow this rule:
- Release the COM-HANDLE before assigning a new value to it.
In order to safeguard against unintentional use of a released COM-HANDLE variable:
- Once a COM-HANDLE is released, set its value to the unknown value(?).
- Once a COM-HANDLE is released, set the value of any other
COM-HANDLEs that referenced the same object to the unknown
value (usually copies of the original COM-HANDLE; for example
chCopy = chOrig).
It is important to follow these guidelines.
How does Version 8.2A support locales in COM objects?
ActiveX support involves two distinct locales:
- Syntax locale - the locale PROGRESS uses to look up the names
of properties and methods for a COM server. When PROGRESS
encounters a property or method name in 4GL code, it assumes
that the name belongs to the syntax locale. Version 8.2A
supports only U.S. English for this locale. This means that
when you refer to properties and methods in 4GL code, you
must use the U.S. English names for these properties and
methods.
- User locale - the locale the COM server uses when it is
executing a method or when it gives help to the user. The
server may use this locale when it handles parameter data.
This locale typically affects data formats (e.g. date format,
numeric format). When Version 8.2A talks to the COM Server,
it tells the Server to use whatever locale it supports by
default. There is no way in the 4GL to tell PROGRESS to tell
the Server to use any other locale.
I have a PROGRESS application and when I run it, it shuts down almost
immediately but I get no error message. What is happening?
This normally means that a required DLL is missing on the system where the
PROGRESS application is running. One way to track the problem is to launch
the PROGRESS application from a DOS prompt. Normally, this identifies the
missing DLL in a message box. If the DLL is a part of the PROGRESS product,
reinstall PROGRESS. If it is a system or third-party DLL, contact the
appropriate vendor.
What kind of problems can I run into with MAPI?
Microsoft's OLE Messaging (MAPI) is available as BOTH an Automation Object
and a Control. These cannot be used interchangeably although their
functionality is similar. If you are using the MAPI Automation Object, you
should write 4GL code to access it (as an automation object). The
alternative is to use the UIB to incorporate the MAPI control in yourr> application.
If you are having difficulty working with either a MAPI Automation Object or
Control, check that you are working with the correct one and that it is
installed on your system.
How do I implement common VB/VBA statements such as FOR EACH and WITH in
the 4GL?
- FOR EACH...NEXT STATEMENT (iterating through a collection
object)
- VB Syntax:
For Each MyObject In MyCollection
...
Next
- 4GL Syntax:
iCount = chMyCollection:Count.
DO iIndex = 1 TO iCount:
chMyObject = chMyCollection:Item(iIndex).
...
END.
- WITH STATEMENT (Short-hand to execute a series of statements on
a single object)
- VB Syntax:
With MyObject
.Height = 2000
.Width = 2000
.Caption = "This is my Label"
EndWith
- 4GL Syntax:
ASSIGN chMyObject:Height = 2000
chMyObject:Width = 2000
chMyObject:Caption = "This is my Label".
How does PROGRESS find the .WRX binary file associated with a .W file
generated by the UIB?
If a full, hard-coded path is coded into the .W, then the UIB will find the
.WRX where you specify. However, by default, the UIB generates the following
code:
OCXFile = SEARCH("myfile.wrx":U).
This means that PROGRESS will look for the .WRX in your PROPATH, which
generally contains your current directory as the first entry. If you run
PROGRESS from one directory and load the .W file from a different directory,
you will get the following results for these two cases:
- If you are running from the Procedure Editor, PROGRESS will not
find the .WRX unless the directory where the .W was loaded
from has been added to the PROPATH.
- If you are running from the UIB, PROGRESS will find the .WRX
file because the UIB runs a generated, temporary version of the
.W, not the original .W. This temporary .W and its associated
.WRX reside in the current directory (the directory you ran
PROGRESS from) and so the file is found in the PROPATH.
Does Version 8.2A support events generated by Automation Servers such as
Microsoft Office 97?
Version 8.2A does not support Automation Server Events (if available, use
DDE). Support for Automation Server Events is under evaluation for a future
release.
How do I view the properties, methods, and events of COM objects?
PROGRESS provides a COM Object Viewer that displays the properties, methods,
and events of COM objects with sample 4GL syntax. There are two ways to
access this tool:
- Use the "PROGRESS COM Object Viewer" icon provided in PRO*Tools.
- Launch PROOBJVW.EXE from the Explorer.
When I have COM-HANDLESs that reference several objects from the same
server, what effect does releasing one have on the others?
There are two ways to get a COM-HANDLE to an automation object. One is using
the CREATE statement, and the other is through a method or property on
another object. In either case, the release of one COM-HANDLE does not
effect any other COM-HANDLEs. The only exception to this is when the value
of a COM-HANDLE is the same as another. Here is an example, using Excel.
DEFINE VARIABLE chExcel AS COM-HANDLE.
DEFINE VARIABLE chWorkbook AS COM-HANDLE.
DEFINE VARIABLE chWorksheet AS COM-HANDLE.
CREATE "Excel.Application" chExcel.
chWorkbook = chExcel:Workbooks:Add().
chWorksheet = chWorkbook:Worksheets:Item(1).
RELEASE OBJECT chExcel.
/* The workbook and worksheet are still available */
chWorkbok:Worksheets:Item(1):Ce.lls:Item(1):Value = 20.
RELEASE OBJECT chWorkbook.
/* The worksheet is still available */
chWorksheet:Cells:Item(2,2):Value = 10.
Can I get from one automation object to another?
Although there is no relationship among objects maintained in PROGRESS, a
hierarchy may be maintained by the automation server. Many automation
objects provide the Parent and Application properties. Application gets the
top-level (application) object from the current object. Parent gets the
parent object for the current object.
Can you provide an example that illustrates how you can convert a macro
recorded using Microsoft Excel to 4GL?
- Record Excel Macro:
Sub Macro1()
ActiveCell.FormulaR1C1 = "Hello"
Selection.Columns.AutoFit
ActiveWindow.Zoom = 50
End Sub
- 4GL Code:
DEFINE VARIABLE chExcel AS COM-HANDLE.
CREATE "Excel.Application" chExcel.
chExcel:Workbooks:Add().
chExcel:Visible = TRUE.
chExcel:ActiveCell:FormulaR1C1 = "Hello".
chExcel:Selection:Columns:AutoFit().
chExcel:ActiveWindow:Zoom = 50.
RELEASE OBJECT chExcel.
chExcel = ?.
How do I register and un-register COM objects?
To register a COM object enter:
- REGSVR32 <FileName>
To un-register a COM object enter:
- REGSVR32 /U <FileName>
How do I obtain the COM-HANDLE of a control?
There are at least three ways of obtaining COM-HANDLEs to a control. They are:
- chControl = chControlFrame:Controls:Item(1)
chControlFrame is the handle to the CONTROL-FRAME COM object.
This is automatically generated by the UIB.
- chControl = chControlFrame:ControlName
chControlFrame is the handle to the CONTROL-FRAME COM object.
This is automatically generated by the UIB. Substitute the name
of the control, as seen in the property sheet, for ControlName.
- COM-SELF
This system handle is available only in an event procedure. It
is automatically set to the control that sent the event.
Does Version 8.2A support COM Object named constants?
Version 8.2A does not support named constants. This means that you can not
use the literal name for the value of a property or parameter. However, you
can obtain the value of the named constant by using the PROGRESS COM Object
Viewer. A good programming style would be to create an include file that
contains these named constants as &GLOBAL-DEFINEs.
What should I do to deploy my ActiveX based application?
Obtain the list of files that should be redistributed and registered from the
ActiveX Control or Automation Server vendor. Incorporate these files into
your setup program. Make sure you register the appropriate files.
.