Scenarios
Now that you have a better understanding of the code in the Hello World application, let’s take a close look at what happens as events are passed from the event queue into the event loop. Unlike our earlier example, where we hand-waved through the technical parts of what happens when a menu was chosen, we will now look with great detail at three different user actions and the flow through the code as these scenarios occur.
This first code excerpt shows what happens when a user opens the
application by tapping on the application’s icon. Example 4.9 shows the flow of events. Pay particular
attention to the
frmLoadEvent
, which is handled by
ApplicationHandleEvent
,
and the frmOpenEvent, which is handled by
MyFormHandleEvent.
Example 4-9. Flow of Control as Hello World Application Is Opened
PilotMain (enter)
StartApplication (enter)
FrmGotoForm(HelloWorldForm) open the HelloWorldForm
StartApplication (exit) returns 0 (proceed)
EventLoop (enter)
EvtGetEvent returns frmLoadEvent (formID
HelloWorldForm)
SysHandleEvent returns false
MenuHandleEvent returns false
ApplicationHandleEvent (enter)
FrmInitForm(HelloWorldForm) load the form
FrmSetActiveForm(frm) activate the form
FrmSetEventHandler(frm, MyFormHandleEvent) set the event handler
ApplicationHandleEvent (exit) returns true
EvtGetEvent returns frmOpenEvent
SysHandleEvent returns false
MenuHandleEvent returns false
ApplicationHandleEvent returns false
FrmDispatchEvent (enter) calls form's event handler MyFormHandleEvent (enter) ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access