ActiveX & Progress - FTP Directory Listing
Download
Report
Transcript ActiveX & Progress - FTP Directory Listing
ActiveX & Progress
Hendrik Demol
Company
LOGO
Who am I?
Progress since V4
Belgian ISV
Free-lance
DWP agent
Hotel-room ActiveX
student
From a city with a
Viking name: Brugge
[email protected]
Who are you?
Anybody using ActiveX ?
Why ?
Which ones?
Why use ActiveX’s?
To enhance the Progress GUI
To add functionality
To make better reports
To interface with hardware or software
To conform to fashion
To make marketing happy
When to avoid ActiveX?
When you can not install them on your
customer’s PC’s (policies)
When you are afraid of the added
complexity
When you don’t want to learn new syntax
Types of ActiveX
In-line processing:
The preferred way because it is many
times faster. The OCX runs in the
Progress container
OLE conversation:
For use with programs like Office modules
(Word, Excel, Outlook). Each call includes
a start & stop and this makes it very slow
Other division: UI element or not
Check if they work with
Progress!
Progress applies the rules very strictly
Others may not … including Microsoft!
E.g. Mappoint’s OCX does not load in
Progress so you can only use the OLE
type
As a rule of thumb: if a component works
with C++ it works with Progress as well
Tools
THE MANUAL: first source of functionality
and syntax – usually written with the VB or
C programmer in mind (“:” <> “.”)
Progress objectviewer: Progress tool for
discovering syntax
ActiveXplorer: check the internals
Dependency walker: to check the files you
need to re-distribute
Progress Knowledgebase (Solutions)
ActiveXplorer
Progress Objectviewer
The
bottom
pane
shows the
applicable
Progress
syntax!
Adding an OCX to a screen
Select “ocx” on the Progress palette
Select the required ocx
and size it
Set standard properties
ActiveX events
Most OCX components
also trigger events
These are listed in the
manuals and are
visible in the Progress
COM viewer
Also visible as events
in the Appbuilder
section editor
Wrx files
Created by the Appbuilder automatically in the
same directory as the .w file
Distribute together with .r files
Watch out for the change of .wrx files over
versions: .wrx file generated in Progress 9.1D06
does not load in Progress 9.1D05
OCX versions between developers and between
development & production may vary
Some keep their first wrx’s. Older wrx’s seem
upwardly compatible (both older OS & OCX)
Initialize-controls
Define your own variable and initialize it
properly – also for readability
Use this for setting to your standard
properties
DEFINE VARIABLE hSp
AS COM-HANDLE NO-UNDO.
ASSIGN
hSP
= chCtrlFrame:vaSpread
hsp:allowdragdrop
= TRUE
hSp:appearance
=1
hSP:BorderStyle
=1
hSP:unitType
= 2 /* twips */
hSP:PrintColHeaders = FALSE
hSP:PrintRowHeaders = FALSE
hSP:printMarginLeft
= 1000
hSP:TypeNumberShowSep = TRUE
hSP:Protect = FALSE.
Cleaning up
Clean up afterwards (memory leaks)
Delete the objects (com-handles)
Set the handle variables to Null
DELETE OBJECT hXMLDoc NO-ERROR.
ASSIGN
hXMLDoc = ?.
MS Office
Most Office programs are ActiveX servers:
Outlook, Word, Excel, Powerpoint, MapPoint,
Access, Visio and Binder
DEFINE VARIABLE chActiveX AS COM-HANDLE.
CREATE “my.app” chActiveX.
Once the handle to the application is set you
expand to other com-objects and use all the
properties and methods of each component.
Study the component objects!
Use Macro recording to retrieve syntax
Sun’s Star Office works in a similar way
Excel via OLE
Many samples available on the net
Use this for small projects (slow)
Ubiquitous
Dump a textfile and open it with Excel
Make a library with your functions
Consider also the in-line activeX (since
Office 9)
EXCEL object model
Some
collection of
objects!
Can be found
via “help” in
the VBA
(macro) editor
Excel sample code (1)
DEFINE VARIABLE chExcel
AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorksheet AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkbook AS COM-HANDLE NO-UNDO.
CREATE "excel.application" chExcel.
/* Open an Excel document
*/
chExcel:Workbooks:Open("c:\test1.xls"). chExcel:visible = true.
/* Sets the number of sheets that will be automatically inserted into new workbooks */
chExcel:SheetsInNewWorkbook = 5.
/* Add a new workbook */
chWorkbook = chExcel:Workbooks:Add().
/* Add a new worksheet as the last sheet */
chWorksheet = chWorkbook:Worksheets(5).
chWorkbook:Worksheets:add(, chWorksheet).
RELEASE OBJECT chWorksheet.
/* Select a worksheet */
chWorkbook:Worksheets(2):Activate.
chWorksheet = chWorkbook:Worksheets(2).
/* Rename the worksheet */
chWorkSheet:NAME = "test".
/* Modify the cell's format to Text */
chWorksheet:Cells:NumberFormat = "@".
/* Change the cell's color */
chWorksheet:Columns("A:A"):Interior:ColorIndex = 5.
/* Change the cell's format */
ASSIGN
chWorksheet:Columns("A:A"):Font:ColorIndex = 2
chWorksheet:Columns("A:A"):Font:Name = "Courrier New".
chWorksheet:Columns("A:A"):Font:Bold = TRUE.
chWorksheet:Columns("A:A"):Font:Italic = TRUE.
/* Set underline: StyleSingle = 2 */
chWorksheet:Columns("A:A"):FONT:UNDERLINE = 2 .
Excel sample code (2)
/* Add data */
ASSIGN
chWorksheet:Range("B1"):VALUE
chWorksheet:Range("B2"):VALUE
chWorksheet:Range("B3"):VALUE
chWorksheet:Range("B4"):VALUE
chWorksheet:Range("B5"):VALUE
chWorksheet:Range("B6"):VALUE
chWorksheet:Range("B7"):VALUE
=
=
=
=
=
=
=
"Value"
255
100
250
400
100
600.
/* Add a Formula */
chWorksheet:Range("A8"):VALUE = "Total:".
/* Set Cell's format to Number */
chWorksheet:Range("B8"):NumberFormat = 0.
chWorksheet:Range("B8"):Formula = "=SUM(B2:B7)".
/* Set horizontal alignment
Right Alignemnt: -4152 / Left Alignment :-4131 */
chWorksheet:Range("B:B"):HorizontalAlignment = -4152.
/* Freeze Pane */
chWorksheet:Range("A2"):SELECT.
chExcel:ActiveWindow:FreezePanes = TRUE.
/* Save the new workbook without displaying alerts */
chExcel:DisplayAlerts = FALSE.
chWorkbook:SaveAs("c:\test2.xls",43,,,,,).
/* Quit Excel */
chExcel:quit().
/* Release Com-handle */
RELEASE OBJECT chWorksheet.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chExcel.
Word
Sample program with print screen
Sample code:
DEFINE VARIABLE oWord AS COM-HANDLE NO-UNDO.
CREATE "Word.Application" oWord.
oWord:Documents:Open("Some.Doc").
oWord:Visible = True.
PAUSE.
/* Allow you to actually see the document before we kill it */
RELEASE OBJECT oWord.
Outlook
Very interesting and rich in functionality
Since V10 date-time format to interact with
Outlook agenda
MAPI namespace
Read & write mail, tasks, contacts,
calendar & notes
Think about master data! Who is boss?
Outlook or your application?
Make a library with your frequent functions
Sending mail
DEFINE
DEFINE
DEFINE
DEFINE
VARIABLE
VARIABLE
VARIABLE
VARIABLE
objOutlook
objOutlookMsg
objOutlookAttach
objOutlookRecip
AS
AS
AS
AS
COM-HANDLE
COM-HANDLE
COM-HANDLE
COM-HANDLE
NO-UNDO.
NO-UNDO.
NO-UNDO.
NO-UNDO.
CREATE "Outlook.Application" objOutlook.
objoutlookMsg
= objOutlook:CreateItem(0).
objOutlookRecip
=
objOutlookMsg:Recipients:Add("[email protected]").
/*use of concatenated object */
objOutlookRecip:Type = 1.
objOutlookMsg:Subject = "Your Subject".
objOutlookMsg:Body
= "The Body".
objOutlookMsg:Attachments:Add("c:\autoexec.bat").
objOutlookRecip:Resolve.
objOutlookMsg:Send.
objoutlook:Quit().
RELEASE OBJECT objOutlook.
RELEASE OBJECT objOutlookMsg.
RELEASE OBJECT objOutlookRecip.
Outlook Object Model
Folders
Inspectors
Collections
Items
Mappoint
Show addresses on the map
Calculate routes
Plan routes
Location services
Add data to maps
Very underestimated software (“Mappoint
who ?” by Microsoft!)
Farpoint Spread
Much faster than Excel
Easy object model
Rich functionality
Easy to build into a
powerful 4GL
wrapper:
automatically
display a temptable, etc
Charts
Many different components
out there
Some highly sophisticated
modules
The simplest: MS Chart
(VB6)
Often array based data
Try to add user interaction
(presentation change, data
selection change)
ComponentOne VsView
The first component I ever used (V2 in
combination with Progress 8.2)
Print preview
PDF
generation
Zooming
Page browsing
Own mini
toolbar
Infragistics SchedX
Alternative to
Outlook
Separate
components
for day-,
week- and
monthview
Toolbar
The newest and slickest are made for .Net
I am still looking for the right one
Infragistics has Ultra Toolbars with Office
XP look.
And an annoying bug!
And intersting tools
Calendars
Great for making a
date picker (add a
dynamic trigger to
each date fill-in). E.g.
right-mouse-click
Put an ocx on a
dialog-box and call
this from the trigger
List view & Tree view
Often used together
Some types have extra
UI features
Progress special
treeview from www.4gl.fr
Perhaps not the best UI
item for large datasets.
When to load the node?
Nice as a menu
Progress bar
DEF NEW SHARED VAR vStop AS LOG NO-UNDO init false.
DEFINE VARIABLE hProg AS HANDLE NO-UNDO.
DEFINE VARIABLE vInt AS INT NO-UNDO.
DEFINE VARIABLE vMax AS INT NO-UNDO INIT 8000.
DEFINE VARIABLE vMin AS INT NO-UNDO init 1000.
RUN progressbar.w PERSISTENT SET hProg.
RUN display_title IN hProg (INPUT "Oslo presentation").
RUN display_message IN hProg (INPUT "Hallo World"). /*system message */
RUN GaugeInitMax IN hProg (vMax).
RUN GaugeInitMin IN hProg (vMin).
DO vInt = vMin TO vMax :
RUN Gaugeincrement IN hProg (vInt).
IF vStop THEN LEAVE.
END.
RUN GaugeClose IN hProg.
pause 0.
Handling low volume SMS
For big volume you better talk directly to
the telecom SMS server
There are several components often
working very differently
Perhaps consider separating the modules,
making a small SMS server polling the
database for new records (generated by
the client software) and creating records
from the incoming messages
Outlook-style button bar
Great for 2 levelmenus
Familiar interface
Easy combining
text & graphics
COMM port reader & TCP/IP
Serial barcode
readers
Serial connections
to hardware
TCP/IP sockets,
Telnet ,etc
Image handling
Capturing, scanning, handling, viewing,
annotating, converting and more
Many different modules available from
Leadtools and Pegasus Imaging
Corporation are the best known
There is even a red-eye removal add-on
Trying to be funny
If you want to mimic
Microsoft you can try to
use moving graphics or
even genies
Many OCX are supplied
with standard Windows
programs like Media
player
Some more …
Credit-card validation
Spelling
Word-processing
Faxing
Data Analysis
GIS
Data compression
Postal code validation
Mail validation
XML parsing
etc
Use standard Microsoft
components or not?
A big question for you: use standard
Microsoft OCX components or buy from
specialised sources?
Standard MS components usually are part
of the Windows environment
Watch out for version differences between
Windows versions or components!
Non MS components equals more
installed components but more control
Use OCX in a framework
(DWP)
DWP framework : support for activeX, by
using a standard wrapper methodology.
Today treeview and listview are supported
out of the box. You can add your own
using the same methodology
Tips & tricks
Null values: Progress happily accepts null
values (x / 0 = ?). Microsoft does not!
Initialize variables and values to make
sure you have valid data
Since V9 you can concatenate objects
chApp:Object:SubObject:Property
Invest in making your code generic
Use OCX in a 4GL wrapper
Avoid sprinkling your application with the
same ocx in various modules
Consider the next version of your ocx
Work a little harder now and relax later
Render the use of ocx’s generic: run your
functions & procedures. Keep them when
you change ocx
Hide ocx complexity from developers
Where to find ActiveX’s?
http://www.componentsource.com
http://www.infragistics.com
http://www.component1.com
http://www.active-x.com/
http://www.vbxtras.com/
XP look
If all you want to accomplish is an XP look
then look at the use of a manifest file
Prowin32.exe.manifest is an xml file that
signals Windows XP to update the look of
the executable
Warning: add useClipChildren=Yes to your
ini file or registry in the startup section,
otherwise buttons will not show
Conclusion & questions
Think first!
OCX can be a nuissance
OCX are fun
OCX can enhance your app
Tusen Takk!