PApplication


This is the base class for every application. You can create exactly one instance of this class. Any attempt to create more than one will cause a fatal error!

Contained in this class is the main event loop and the initial form. This form cannot be created dynamically (yet).

Synopsis

#include <PLAppl.h>

Initialization

Note: Your resource files must not include resource ids in the range 9900 - 9999

Before you try to create any PCL-based objects, you must call PCLInit() otherwise you will get an error as you try to run the event loop. This should look like:

DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
  ...
  if (cmd == sysAppLaunchCmdNormalLaunch)
  {
    PCLInit(APPID);
    PApplication mainAppl(formId);
    ...
    mainAppl.run();
  }
  ...
  return(0);
}

Derivation

  • PEventLoop
  • PForm
  • PApplication
  • Constructors

         PApplication(const Word frmId,
                      const Word timeOut,
                      const Boolean applicationFirst = false);
    
    Creates an application form from the resource frmId. if timeOut is set, nilEvents will be generated every timeOut ticks. Anyway, some controls, like fields (PField) generate nil events as soon as they get the focus.
    If applicationFirst is true, the application's event handlers will be called before the system's.


         PApplication(const Word frmId,
                      const PEvtSysCallback = 0,
                      const Word timeOut = evtWaitForever,
                      const Boolean applicationFirst = false);
    
    This lets you specify a default handler function for non-handled events (see PFormHandler). This should only be used to call any legacy code.

    Public functions

         run();
    
    Shows the form and starts the event loop. No PForm::goto() is necessary.
    After this function terminates and any cleanup code is done, PilotMain should terminate.


        static DWord appId();
        static PString appIdString();
    
    Returns the appId given in the constructor either as four bytes or as PString.