I've run into an odd situation regarding FrmDoDialog - I've managed to work
around the problem, but I'm hoping there's a "right way" to do this that
will let me drop the work around.

My application makes use of N read-only databases, all of the same format,
and the user is allowed to choose any one of them via a popup menu.  Each
database is created by a shareware app, which if registered at database
creation time, puts its unlock key into the database so the main application
can check it.  If it isn't registered at creation time, the main app allows
use of the database for 30 days, or until the user registers and enters the
unlock code (via a "Register database" menu item in the main app).

In its AppStart routine (i.e., before the main form has been created) the
main app checks each database in turn to determine its registration status,
and if its trial period has expired, puts up a modal dialog via FrmDoDialog
to give the user a chance to enter the unlock key.  The dialog is created in
the standard fashion, UI elements initialized, an event handler is assigned
to it, and the dialog is successfully displayed.  Here's where the odd stuff
happens.

First, in order to make the dialog go away (after pressing OK with a valid
unlock key entered), the event handler for the OK button must return
"handled = false" - the docs don't say anything about this requirement.
Second, if I show a "Thanks for registering" alert from the OK button
handler, I get a "Direct read from memory manager memory" error within
EvtGetEvent (in the main event loop) after the alert and the modal dialog
have been erased, seemingly without problems.  Note that this doesn't happen
if the Cancel button is pressed (handled = true), or if OK is pressed but
the unlock code is no good (a "Invalid unlock key" alert gets displayed for
this).  The work around to this is to move the "Thanks ..." alert call to
just after the FrmDoDialog call that created the modal dialog.

My question is this - is this the way all this is supposed to work, or am I
somehow using modal dialogs and/or the event handler improperly?

Thanks,

Mark Peters



Reply via email to