Thomas Hummel - Encapsulating the Windows API with Object Oriented Templates
Posted September 1 1997
Tom showed a 2.003 application implemented using objects and the Windows API. Since objects have been thoroughly covered elsewhere, let's see how Tom encapsulated the Windows API into that app.
Tom pointed out that there is an important reason for using the Windows API (an API being just a set of function calls provided by the software provider). Using the Windows API, we can do things that are not possible in Clarion or, sometimes, that are easier than in Clarion. Some of the functions that were used in the app included copying, moving, converting and viewing files (his app worked mostly with image files).
The first step is to select the desired API calls to be included in the object. This, naturally, requires some research into or knowledge of the Windows API.
The next step is to create prototypes for the functions and declarations for the constants used. This is easily accomplished using the WinAPI Viewer including in Clarion Professional. You can use the WinAPI app to create an include file for use in your applications.
To ensure that the declarations used by the Win API are compatible with Clarion, you must also include WinEqu.clw from your LIBSRC subdirectory. This file Equates Windows' language with their Clarion equivalents.
To encapsulate all of this in an object, you create a source file and declare the class, then include the files you previously created. The key is to ensure that the class declaration includes a Module ('modulename') declaration. That file will include the methods (procedures and functions) that you want to effect (i.e., the way in which you want to use the various API calls).
Tom showed easily constructed templates that include the API class in the Global and declarations areas of your app and another that creates the objects to be used in the application. The source can be found at http://www.cwsuperpage.com.
Article comments
Post a comment
You must be logged on to post comments.
Talk To Us!
Search ClarionMag
From the archives
Calling the Skype API
12/22/2004 12:00:00 AM
By now you've probably heard of Skype, the free internet telephony service that makes the Planet Clarion podcast possible. But Skype is much more than just a free phone call. David Harms shows how to call the Skype API to manage calls, send instant messages, and much more.

Steve
Parker started his professional life as a Philosopher but now tries to imitate
a Clarion developer. He has been attempting to subdue Clarion since version 2007 (DOS,
that is). He reports that, so far, Clarion is winning. Steve has been writing
about Clarion since 1993.