Class: cApplication

Properties  Events  Methods    Index of Classes

Encapsulates methods and properties that are essential to the running of your application



Library: Common (Windows and Web Application) Class Library

Package: cApplication.pkg


The cApplication class encapsulates methods and properties that are essential to the running of your application. It is the central location that handles the help system, the Workspace, the command-line, version information and coordinates access to the Registry for storing window sizes, etc.

In your application, you create an object of this class like this:

Use cApplication.pkg

Object oApplication is a cApplication
    // Define properties for Registry access:
    Set psCompany To "Data Access Worldwide"
    Set psProduct To "DataFlex 19.1 Examples"
    Set psVersion To "19.1"
    Set psProgram To "Order"

    // Define the help system (Windows applications only)
    Set peHelpType To htHtmlHelp
    Set psHelpFile To "Order.chm"

    // cConnection object for Managed Connections
    Object oConnection is a cConnection
        Use LoginEncryption.pkg
        Use DatabaseLoginDialog.dg  // (Windows applications only)

    // Determine if application should use the Registry for settings:
    Set pbPreserveEnvironment To True

    // Should the Enter key act like the Tab key:
    Set pbEnterKeyAsTabKey To True  // (Windows applications only)

A standard cApplication object like this will open a workspace file named As long as you have a workspace file named in the same directory as your compiled program (.exe file), the application will load and run. If you wish to customize your workspace file by naming it something other than, you can do so by either changing the value of psAutoOpenWorkspace or augmenting the OnCreate event.

Managed Conections to SQL Databases

See Using Managed Connections or the cConnection class for information on Managed Connections to SQL databases.

Preserving Program Environment

Your application will automatically use the Registry to preserve the size and locations of its windows. Use the pbPreserveEnvironment property to determine if you want to preserve your settings after the program exits. The settings that are stored in the Registry are stored per-user under HKEY_CURRENT_USER. You determine the exact subkey name that is used by defining the psCompany, psProduct, psVersion and psProgram properties.

Writing to the Windows Registry

You can write data to the Registry for your application using the WriteBinary, WriteInteger WriteString and WriteUInteger methods. You can read the data back using ReadBinary, ReadInteger, ReadString and ReadUInt. To test if a Value exists, use ValueExists.

Managing Application Help

You determine which help engine to use by setting the peHelpType property: You can use HTML help by setting it to htHtmlHelp; use WinHelp by setting it to htWinHelp. The help file that will be used is determined by setting the psHelpFile property.


If you want your application to use the Enter key as though it were the Tab key, then set the pbEnterKeyAsTabKey property to True.

To gain access to the embedded cWorkspace object that controls the Workspace, use the phoWorkspace property.

To gain access to the command-line arguments that were passed to your program, use the embedded cCommandLine object, which exposes its object handle through the phoCommandLine property.

To query embedded Version Information, use the embedded cVersionInfo object, which exposes its object handle through the phoVersionInfo property.

Note:A global variable, ghoApplication, is automatically created that contains the object-handle of the application object that you create

See Also

cWorkspace | cVersionInfo | cCommandLine