Boston Computer Society Clipper SIG               Clipper
Developer's Guide to Entering WIndows
                                                            
                                                Page: {page}
      The Clipper Developer's Guide To Entering Windows
                         Development
                              
                              
A Boston Computer Society Clipper SIG Presentation by Darren
                           Forcier
                              
                              
                      February 15, 1994
                              
                              

Windows Takes Over The World

Windows, Windows, WINDOWS! You here it echoing through your
brain relentlessly. Your clients are all screaming for it. Their
managers are screaming for it. Their manager's managers are
screaming for it.  In the span of four years since Window 3.0
was originally introduced, Bill Gates has ordained our future is
Windows. It's slow, it's ugly, and it's complex. What's a poor
Clipper programmer to do?




Visual Objects: SET WAIT ON

While we are all waiting patiently for VO, there are plenty of
tools on the market which can assist us in exploring Windows
programming and development. During this talk I will present to
you two major tools for doing Windows application development in
CA-Clipper, Clip4Win from Grumpfish and Dolce Vita from Fiesta
Publishing.  I will also cover a minor tool, FromDOS, which is a
device driver based DOS utility which gives you access to a
limited amount of Windows features from your DOS based
application.  While FromDOS is mostly a C based product, the
author has provided a minimal interface for Dynamic Data
Exchange between CA-Clipper applications. (See the following
article, "FromDOS for C/Clipper"

Given how robust VO is going to be, and the amount of time it
takes to learn new development tools, is it wise to invest a lot
of time in learning these apparently limited-lifespan products?
I think it is.  Once VO comes out of the chute, there will be a
massive learning curve, spoking out in many directions. VO will
include application browsers, resource editors, screen
designers, report designers, an Object Oriented architecture,
Database Classes, SQL Classes, GUI Classes, and scores of
different compiler and compatibility options. Its native code
generator will provide us with many new data types to learn.  On
top of all this VO specific stuff, we will also be faced with
the mammoth Windows learning curve, working with the Windows SDK
and APIs.  All together it appears to be truly overwhelming, and
can make the heartiest programmer go running for a padded room.


Clip4Win and Dolce Vita: Windows Learning Now!

Can any of these tools help us get over some of the learning
curve now? They sure can. Both Clip4Win and Dolce Vita provide
Windows SDK access and Clipper based wrapper calls around many
Windows 3.1 API elements. Both products feature:

Windows SDK calls & support.
DDE (Dynamic Data Exchange)
DLLs (Dynamic Link Library access)
Resource Support (Dialog boxes, controls Dialog Resources,
Icons, Bitmaps, Menus)
Controls (Edit Boxes, List Boxes, Combo Boxes)
Windows Integration of Clippers GET system into Windows Controls
Windows Printer Support
Clipper Debugger Support (Clip4Win's is still in beta)

These products differ in their approach greatly. Clip4Win is a
library based tool which replaces Clipper.lib and other
internals with Windows based replacements.  When you link a
Clip4Win application you must use a Windows compatible linker
such as Microsoft Link 5.3 or the new Blinker 3.0. What comes
out on the other end is a true Windows executable file that will
only run under Windows. If you try to run a Clip4Win application
under DOS you will get an unceremonious message which states
"This application requires Windows 3.1" or an alternate message
depending on how you link and what you use for a Windows stub
executable. (A Windows stub is a piece of executable code that
is bound by the linker into the final output .EXE file).

Clip4Win is only compatible with Clipper 5.01a and 5.2c, it
won't work with Summer '87.  This should not be a major issue
with any of us now, as most of our applications (hopefully) have
been ported to at least Clipper 5.01a. If you intend port any
applications to Clip4Win you will at least have to bring them up
to 5.01a.

Since Clip4Win applications execute as true Windows executables,
they take on all the properties of Windows applications. They
are windowed, can be minimized, maximized, or icon-ized. They
can run in the foreground or background.  You can control their
execution via the .PIF editor, which allows you to configure
memory layout, time slicing, EMS and XMS usage, and all sorts of
other configuration features.  Using a resource editor you can
bind resources such as Dialogs, menus, icons, and bitmaps.

One major improvement to any application reworked as a Windows
application is memory management.  True windows applications by
their very nature are protected mode application. Windows takes
over all the memory management issues for your application, in a
very similar fashion to Exospace and Blinker 3.0 protected mode
for DOS.  What this means is that you are no longer bound to the
640K barrier under Windows.  Windows will provide true XMS/EMS
memory, or it will simulate it using disk swap space.

Dolce Vita takes an entirely different approach to Windows
development. Instead of binding a true Windows executable, Dolce
Vita applications run in a DOS window (known as the main session
window), and make requests to the Dolce Vita Server engine,
which must be loaded up prior to running the application. Your
Clipper application is linked as always using the linker of your
choice (preferrably Blinker).  There is a DV interface library
which you must link in, which provides the Clipper function
layer for Dolce Vita.  These functions "talk" to the Dolce Vita
server.  The DV server consists of two parts:  A Windows device
driver which is loaded in your SYSTEM.INI file (The Windows
equivalent of Autoexec.bat) and a running Windows .EXE, the DV
server engine.



Each product has its advantages and disadvantages.  Following is
a comparision of advantages and disadvantages between the two:


Clip4Win Advantages

1. Tight Windows .EXE generation.  You only have to distribute a
single .EXE in order to distribute your applications.

2. Clip4Win provides a Windows SDK emulation/wrapper layer which
is extremely close to the Windows SDK. So close in fact that you
can take many of the examples in Charles Petzold's book and
write them in Clipper/Clip4Win.

3. Windows based memory allocation.  Similar to protected mode
linkers for DOS Clipper (Exospace, Blinker 3.0), Clip4Win takes
advantages of Windows memory management, which is implemented as
DPMI by Windows itself.  What this means in plain english is
that the 640K barrier is no longer for Clip4Win executables.
They are _TRUE_ windows executables.


Clip4Win Disadvantages

1. No debugger support in version 1.2.  This is currently in
beta for version 1.5.  When finished, the Clipper debugger will
run in a separate DOS window. (Note: I have worked with the beta
version of Clip4Win 1.5, and while the debugger works, it is
kind of rough going under Windows.  The Clipper debugger was
never designed to run as a Windows application, and as such John
Skelton, the author of Clip4Win had to crawl through broken
glass and hot coals just to get the debugger somewhat Windows
compliant.  The end result is that the debugger works as a
Windows window, but its video management is shot.  The window
refreshes about 4 or 5 times for almost every keystroke you do.
It's really hard on the eyes.  Certain features such as
breakpoint setting are difficult and sometimes cause GPFs and
System Integrity Violations under Windows.

2. More work is required to port the application to Windows.
With Clip4Win it is not just a simple matter of recompiling your
application.  You have a lot to consider in terms of reworking
the interface. Many givens in straight DOS Clipper apps such as
Achoice(), Menu To, and terminal output need to be reworked in
order to work cleanly in Clip4Win.


Dolce Vita Advantages

1. Minimal work is required to "port" your application to
Windows. Essentially all you need to do is stick an InitExec()
call at the beginning of your application and immediately your
app can access features such as better memory management,
Dynamic Data Exchange, and device independent printer support
without rewriting your entire interface. As such this approach
is very similar to the VO Terminal Window, which is an interface
VO will provide to rapidly move DOS based Clipper applications
to Windows.


2. Porting applications to Dolce Vita is a much more incremental
process. You can immediately move an application to Dolce Vita,
then work on different interface issues piecemeal, or forego
converting the interface alltogether and just take advantage of
things like Dynamic Data Exchange and DLL access.

3. Full Clipper Debugger Support. Dolce Vita provides complete
Clipper 5 debugger support from the word go. The debugger runs
in a DOS window, and is much tamer than under Clip4Win, but it
still has its annoyances.  The bottom line is that both products
had to retrofit a tool that was never designed to run under
Windows.

4. Cool utilities. Dolce Vita provides a DV specific task
manager to keep track of Dolce Vita applications.


Dolce Vita Disadvantages

1. The DV Server must always be up and running.  You have to
distribute and configure the server for each client that you
distribute the application to, including the user's SYSTEM.INI
and Windows Startup Group options.

2. Dolce Vita functions and calls are not as close to the SDK
functions as Clip4Win's are.  You will either have to write a
portability layer or preferrably a class abstraction layer in
order to ease the porting into VO.


Shared Advantages

Both products share some major advantages including:

1. Windows Tool Support - Standard Windows based tools can be
used to create resource dialogs. These tools include the
Whitewater Resource Toolkit, Borland's Resource Toolkit, and
Visual C++ Apps Studio designer.

2. DLL Access - This is a major advantage to the Windows
environment in general. The DLL library format is a runtime
Dynamic Link Library. It allows you to load in functions at
runtime on an as-needed basis and discard them when they are no
longer needed.  DLLs all follow a standard calling convention
which is much more generic than the Clipper Extend System. This
opens up Clip4Win and DV applications to a much broader spectrum
of hird party tool capabilities. There is a vast third party DLL
market which is exploding now even as we speak.  Visual Objects
itself is going to be very DLL intensive. It is estimated that
the the third party market for Windows DLLs is going to be an
order of magnitude greater than the Clipper third party market.
Clipper third party developers who are working on DLLs
(Successware, Ganahl Software and dLesko Associates are among
them) will be expanding their market greatly.

3. Better Memory Management. As discussed before, Windows
provides the virtual memory to CLip4Win and Dolce Vita
applications.

4. Windows Style Tbrowses.  Both products have Windowed Tbrowse
implementations which are mouse aware.  The TBrowses aren't 100%
graphical, however.  There are beta versions in the works for
both of these products which will feature TrueType TBrowse
implementations which will map the Tbrowse objects to Windows
fonts.

5. Full Class(y) and other Third Party Library support.  You can
use most third party libraries and RDDs in conjunction with
these products.


Major Disadvantage.

Code. You have to write lots of it for both products.  Even
something as simple as an add/delete/edit/next/previous style
data entry screen requires much more programming than
traditional DOS based Clipper.  This is not a fault of the
products, but simply the nature of Windows Event Driven
programming. You have to write a lot more code to service events
as they can happen from anywhere, including the mouse and the
keyboard, and they can happen in any window or control. This
drives up both the volume and complexity of your code.

Both products have excellent low level function implementations,
but both are lacking an overall application framework or set of
API classes to abstract the low level details.  They are also
lacking comprehensive screen generators and visual designers. VO
will of course rectify all this, but for now working with these
products is basically working at a very low level of detail
within Windows. This is kind of an advantage, however, as if you
can deal with Windows at a lower level now, you will be much
better prepared to deal with it at a higher level with VO, and
be able to dig down into the trenches when you need to.
Remember the goal here is to learn Windows as much as possible
prior to VO's release, without totally scrapping all of your
Clipper knowledge.



 La Strada

Craig Yellick, noted Clipper developer and co-author of the
"Clipper Developer's Guide" by Booth, Lief and Yellick, has
developed a very reasonably priced alternative to purchasing
Dolce Vita.  He has written a text called "La Strada del La
Dolce Vita".  This literally translates as "The Street Guide to
Dolce Vita".  It is a 256 page text which provides an excellent
tutorial on Windows development for Clipper developers. It comes
with a companion disk which includes a fully functional
education version of the Dolce Vita Server. All of the Dolce
Vita functions are available. The only restriction is that you
cannot legally distribute the DV Server engine which comes on
the disk. It is meant only for educational learning purposes for
one programmer only. Upon loading the Strada specific DV server,
a constant graphic Dolce Vita logo remains on your main Program
Manager window as a constant (and slightly annoying) reminder
that you are running the limited education version of the DV
server.

The book was completely self-published by Craig Yellick, and is
mainly distributed by word of mouth and user group tours and
educational seminars put on by Craig Yellick and Alto
Microcomputer. It is very reasonably priced at $40.00, and
highly recommended for anyone who wants to learn Windows
programming in Clipper for a nominal charge.  All of the DV
sample apps presented for this seminar were demoed using the
educational server edition.


The Big DDE Exchange

For my main demo for this presentation, I wanted to put
something together that would wow, astound, and amuse you. I
probably fell short of that mark, but what I have done should be
fairly impressive regardless.  I have come up with a three way
Dynamic Data Exchange demonstration which combines a Dolce Vita
program to "Poke" values into Microsoft Excel spreadsheet cells,
and a Clip4Win program to read those updated cells back and
display them in a scrolling Window.  The programs are provided
for your perusal. (If anyone wants them on disk see me after the
presentation or email me via CIS or Internet).

I'll be the first one to admit that I have never hit so many
walls in my life with doing DDE programming.  Dynamic Data
Exchange is probably one of the most difficult areas of Windows
programming to master.  Some things I learned during the
process:

1. Dolce Vita programs can be a DDE Client an a DDE Server (a
DDE Client requests data from a server, a DDE Server provides
the data).  The Dolce Vita documentation was pretty
straightforward on how to be a client, but the section of the
manual on DV DDE Servers was mysteriously cut short.  Overall
the documentation for Dolce Vita 1.1 was pretty rough.

2. DDE processing between Dolce Vita and Excel caused a lot of
warning errors to be returned.  Even though these were benign
and could be ignored, the Dolce Vita default error system kept
trapping them and putting up an Alert() box to that effect.
After a while I got annoyed with this and wrote my own
ErrorBlock handler to trap the warning errors and snuff them
out. My program was much happier.

3. Clip4Win 1.2 only supports the client side of DDE.  I

couldn't find any functions or features to assist with the

Server side.  There may have been some new stuff in the Clip4Win

1.5 beta, but as of this writing the author still hadn't updated

the Norton Guide.


The Implementation
In order to run my demos, you must do several things:

1. Load up Excel and minimize the window as much as possible.

2. Load up a DOS window to run the DV TESTDV.EXE. Minimize this
window as a graphical DOS window


3. Run the Clip4Win DDE.EXE from the ALT-File/Run from the
program manager.


4. Resize all the open windows so that you can see each one of
them clearly on the screen. Even on a 1024 X 768 monitor this
can be a real challenge. (A 17' monitor seems to really be a
must for doing some serious Windows development)


Now the fun begins.  TESTDV.EXE allows you to enter values into
the Excel default spreadsheet SHEET1.XLS, in cells R1C1, R5C5
and R2C3.  Note that these are not actual cell references, but
relative offsets (R1C1 == "Row 1 Column 1".  This is the DDE
protocol for talking to Microsoft Excel spreadsheets, everything
has to be done by relative offsets.  Who knows why, this is just
the way that Mickey-Soft decided to design it.


Any time you enter new values into the GET fields in the TESTDV
entry screen, those values are poked into the Excel spreadsheet
cells.  The Clip4WIn DDE.EXE window then picks up the fact that
the cells have changed and displays the new cell values.
Nothing fancy here, I am just using the ? operator to write out
the new values.


Several interesting things to ponder:  The DV application could
have been done with a true GUI look and feel, but I chose to go
for expedience, and do a straight modal Clipper GET/READ style
implementation.  The Clip4Win app isn't really that
sophisticated, it just puts up a main application window, and
then sits in an event loop looking either for DDE advisory
messages or a Windows WM_CLOSE event message.  I wanted to keep
things simple so as to not obfuscate what was going on in the
applications.


These examples merely scratch the surface of what can be done in
Windows with these products.



Which Tool Should I Buy?

This is entirely up to you.  With all of the information I have
provided here, you should be able to make an educated decision
as to which tool fits your  current needs the best.  If,
however, you are mainly interested in learning and you don't
want to invest a lot of $$$, then Craig Yellick's La Strada is
probably your best choice for now.  If you are looking to create
standalone Windows applications which will be very portable to
VO, then Clip4Win is probably the best choice.  If you want to
get your DOS applications to work more seamlessly with Windows
but you don't want to do an entire interface rewrite until VO
comes and you don't mind the Server based approach, then Dolce
Vita is not a bad choice either. If all you need is DDE and
again are on a limited budget and don't mind dealing with
minimal documentation then FromDOS is a possibility.  If money
is no object then buy them all! The choice is yours!


What Else Do I Need?

Here is my shopping list of required tools above and beyond
these products:

Visual C++ or Borland C++ for the resource editor tools (The
Whitewater Resource Toolkit is also available)

Resource editors allow you to design dialogs, icons, bitmaps,
and all sorts of other Windows goodies.

The Windows SDK (This includes the Windows Resource Toolkit)

This Comes with Visual C++, or can be purchased separately.
Alternately you can purchase some good reference books on the
market, such as "The Windows 3.1 Intern" (ISBN #1-557-55-159-6,
Abacus Books)

A 17" Monitor - While not absolutely necessary, it can make your
life a lot easier, as under Windows you have many tools loaded
up at once. Being able to have everything in front of you is
essential for your sanity.

Charles Petzold's Windows Programming book.

'Nuff said on this one, it's the defacto standard.  All the
examples are in C but the concepts carry over to Clip4Win and
Dolce Vita.


Time

What more can I say on this one.  Windows is a very complex
product, and as such it is going to take you time to explore all
its nooks and crannies. Set aside some quite time, break it
down, and try it a piece at a time. Write small example programs
until you get familiar and comfortable with it, then start
sewing things together.



Conclusion

The big burning question now is what good is using Clip4Win or
Dolce Vita when VO is going to be completely different?  Well it
is and it isn't. As mentioned, VO will have a massive learning
curve going off in many directions. Right now the best thing we
can do is minimize the learning curve of Windows itself, so we
have one less thing to learn by the time VO gets here. Believe
me, there will be so many different facets to learn with VO that
your brain will feel like it is about to explode.  With
Clip4Win, Dolce Vita, a little bit of planning and possibly some
OOP encapsulation, you can do work today which will help you get
over the VO learning curve faster, and also port into VO with
minimal effort. Start taking your lumps in Windows now, and you
will be much happier and much more productive by the time VO
arrives.

                              
                              
FromDOS for CA-Clipper Developers: Just What You Need, Nothing
                            More
                              
One day I was cruising the CLIPPER forum libraries on
Compuserve and I came across this mysterious file
called DDEIO.ZIP.  I was looking for a utility which
would allow me to simply perform Dynamic Data Exchange
between a Clipper application and Microsoft Excel for
Windows. DDEIO came with a library, DDEIO.LIB and a
sample .PRG illustrating some Windows dynamic data
exchange between the sample app and the Windows program
manager.  When I tried the sample app it wouldn't run,
and came up with a missing driver.  After emailing the
author I found that the demo wasn't supposed to run, it
was just a teaser for a commercial product called
FromDOS, a C based library/product foraccessing Windows
features from straight DOS apps.  Fairly limited in
functionality, the product provides:

Dynamic Data Exchange
Dialog Support
Graph Server Support

That's basically it. Nothing fancy.  The goal of the product was
to provide a small handful of Windows features to DOS apps.
Priced at only $59.95, I decided to grab a copy of the product
and take a look.

FromDOS operates mainly from a DOS device driver called
DDEDEV.SYS.  This must be loaded in your CONFIG.SYS file.  From
there, there are different server engines which you must load up
in Windows depending on whether you want DDE, Dialogs, Graphs,
or all three.  The DOS device driver eats up only a few K, and
loads into high memory very easily.

From here, all you need to do to access things such as Dynamic
Data Exchange is simply code the functions into your application
and go.

I found the product fairly easy to use, but the printed
documentation and the online help was a little bit skimpy.  I
also found the examples to be slightly thin.  Jim Knaack, the
author of the product told me he was fairly new to the Clipper
third party world, and was primarily a C and ASM developer.  As
such he hadn't really intended his product to be a Clipper based
product, but is considering working much more into the product
for third party developers.

For $59.95, if all you need is Dynamic Data Exchange, Graphs or

Dialogs, FromDOS is not a bad little tool.



                    PRODUCT AVAILABILITY

Clip4Win   1.2

Grumpfish, Inc.
2450 Lancaster Drive, N.E. Suite 206
Salem, OR 97305
Voice #   (800)-367-7613 / (503)-588-1815
Fax#      (503)-588-1980
BBS#      (503)-588-7572
CIS ID         71064,2543 / 70673,355



Dolce Vita 1.1

Fiesta Publishing
1402 East Las Olas Blvd #107
Ft. Lauderdale, FL 33301-1416
Voice #   (305)-728-8183
Fax #          (305)-523-2921
BBS #          (305)-525-0933


La Strada

Craig Yellick
C/O Alto Microcomputer, Inc.
7151 Metro Boulevard, Suite 100
Minneapolist, MN 55439-2119 U.S.A.
Voice #   (612)-942-9101
Fax#      (612)-942-8452
CIS ID    76247,541


FromDOS 1.1

Portable Software
P.O. Box 675573
Marietta, GA 30067
Voice #   (800)-484-2045 x3000 / (404)-952-2432
Fax#      (404)-955-1375


About the Author

Darren is an Independent Consultant based in Worcester, Ma,
and a frequent contributor to The Aquarium, a very unique
disk based Clipper technical journal and online BBS. He is
also very active with the BCS Clipper SIG and contributes to
the BCNN Newsletter.  Darren would like to extend thanks and
Kudos to the following people who helped him greatly during
the preparation of this presentation:


Greg Lief/Mary Gries - Grumpfish Inc., for Clip4Win support
& raffle copy.

John Skelton - Skelton Software, for much help in
unravelling the mysteries of Clip4Win 1.2/1.5 beta

Craig Yellick - Raffle copy of La Strada

Jim Knaack - DDE Assistance and answering my FromDOS
questions

And Special Thanks to Andrew Kurtz for his excellent Aquarium
articles on DDE with Clip4Win. It gave me a real good head
start for this presentation!

Most of all, thanks to all you BCS'ers for coming out and
listening to me rattle on!

