Click or drag to resize

App Class

X#
Create an entity that represents the overall application. Please note that you have to create a subclass of App in your code and add a Start() method to this class. You can't add a Start() method to the App() class inside GUI Classes like you can in VO.
Inheritance Hierarchy
Object
  VObject
    App
      VOWinFormApp

Namespace:  VO
Assembly:  VOGUIClasses (in VOGUIClasses.dll) Version: 2.19
Syntax
 CLASS App INHERIT VObject
Request Example View Source

The App type exposes the following members.

Constructors
  NameDescription
Public methodApp
Construct an application.
Top
Methods
  NameDescription
Public methodDestroy
Free memory resources allocated for a VObject object and its derived objects.
(Inherited from VObject.)
Public methodExec
Start the event handling loop for the application.
Public methodGetAccel
This method returns the handle for the current active Accelerator Table.
Public methodGetAccelWindow
This method gets the handle to the window for which accelerators must be translated.
Public methodGetDialogWindow
This method gets the handle active Dialog window for which Dialog keys must be handled
Public methodGetMdiClientWindow
This method gets the handle to the MDI Clientwindow on the active ShellWindow.
Public methodHandle
Return the handle for an application.
Public methodQuit
Terminate the application by instructing the application to close itself.
Public methodRun
Invoke and execute a specified command.
Public methodSetAccel
This method sets the handle for the current active Accelerator Table (belonging to the active menu).
Public methodSetAccelWindow
This method sets the window for which accelerators must be translated.
Public methodSetDialogWindow
This method sets the handle active Dialog window for which Dialog keys must be handled
Public methodSetMdiClientWindow
This method sets the handle to the MDI Clientwindow on the active ShellWindow.
Top
Fields
  NameDescription
Public fieldoCargo
Cargo slot.
(Inherited from VObject.)
Top
Remarks
The App class starts, runs, and stops the application. However, nearly all the code in an application executes in event handlers. Once you invoke the method App:Exec(), the system starts sending you events. While the term application is consistent in both the windowing and non-windowing worlds, the event-driven nature of a windowing application is designed to handle user-driven events (such as a mouse click or the resizing of a window). As a result, the function of the windowing application is relegated to an event scheduling loop. In this class, the Start() method is analogous to the entry point START() function in CA-Clipper. It is where the main elements of your application are constructed. The objects declared within App:Start() should be those which have "application wide" scope. Within the App:Start() method you must call App:Exec(). Doing so invokes the message processing loop of your underlying windowing system and begins the system event handling mechanism by activating the system dispatcher. The App:Exec() method can be thought of as a layered service with a typical "get-translate-dispatch-message" mechanism driven by your underlying windowing system and a "filter-translate-dispatch-event" mechanism being directed through the system framework by the system dispatcher. The App:Quit() method provides a way of breaking out of the application's Exec() loop to terminate the application. It is analogous to the QUIT() function in CA-Clipper.
Examples
The following example demonstrates an entire application, using the various methods of the App class:
X#
 1DEFINE IDM_MYMENU := "MyMenu"
 2DEFINE IDM_MYMENU_CLOCK_ID := 1000
 3DEFINE IDM_MYMENU_GETHANDLE_ID := 1001
 4DEFINE IDM_MYMENU_QUIT_ID := 1002
 5FUNCTION Start as VOID
 6LOCAL oApp as XApp
 7oApp := XApp{}
 8oApp:Start()
 9RETURN
10
11CLASS XApp INHERIT APP
12METHOD Start()
13LOCAL oWin AS Window
14oWin := MyTopAppWin{SELF}
15oWin:Show()
16SELF:Exec()
17RETURN NIL
18
19END CLASS
20
21CLASS MyTopAppWin INHERIT TopAppWindow
22
23CONSTRUCTOR(oOwnerApp)
24LOCAL lRetVal AS LONG
25SUPER(oOwnerApp)
26SELF:Menu := MyMenu{SELF}
27lRetVal := oOwnerApp:Run("Clock")
28SELF:Caption := "My Top App Window Application"
29SELF:WarningMessage("The return value of running CLOCK is :" +AsString(lRetVal))
30RETURN
31
32METHOD GetClock()
33SELF:Owner:Run("Clock")
34RETURN NIL
35
36METHOD GetHandle()
37SELF:WarningMessage("The handle of this app is :"+AsString(SELF:Handle()))
38RETURN NIL
39
40METHOD GoQuit()
41SELF:Owner:Quit()
42RETURN NIL
43END CLASS
44
45CLASS MyMenu INHERIT Menu
46CONSTRUCTOR(oOwner)
47SUPER(ResourceID{IDM_MYMENU})
48SELF:RegisterItem(IDM_MYMENU_CLOCK_ID, HyperLabel{#GetClock,,,})
49SELF:RegisterItem(IDM_MYMENU_GETHANDLE_ID, HyperLabel{#GetHandle,,,})
50SELF:RegisterItem(IDM_MYMENU_QUIT_ID, HyperLabel{#GoQuit,,,})
51END CLASS
52RESOURCE IDM_MYMENU MENU
53BEGIN
54POPUP "&Menu1"
55BEGIN
56MENUITEM "&Clock", IDM_MYMENU_CLOCK_ID
57MENUITEM "&Get App Handle", IDM_MYMENU_GETHANDLE_ID
58MENUITEM SEPARATOR
59MENUITEM "&QUIT", IDM_MYMENU_QUIT_ID
60END
61END
See Also

Reference