I have a generic dialog function for instantiating my dialog and for
registering my handler. It works great, except that I want to add the
behaviour that if the user taps outside of the area of the dialog, the
dialog closes. (Essentially, its the same behavior when the user taps the
"Cancel" button. I want this behavior because I'm using the dialog for a
popup toolbar. If the user taps outside the toolbar, I want the popup
portion of the toolbar to go away.)
Below is the code for my function. I think I got this out of either the
"Bible" or "Instant Palm OS Apps." I'm guessing that I have to queue a new
event to tell 'FrmDoDialog' to close its dialog and release control, but if
there's a simpler way to do this, I'd really appreciate hearing it.
Thanks!
Rich
UInt16
cfDisplayGenericDialog( UInt16 formID, FormEventHandlerPtr handler)
{
WinHandle savedWindow;
RectangleType savedBounds;
UInt16 err;
UInt16 buttonPressed = 0;
FormPtr active = FrmGetActiveForm();
UInt16 activeID = ( active != NULL ) ? FrmGetFormId( active ) : 0;
FormPtr dialog = FrmInitForm( formID );
WinGetWindowFrameRect(FrmGetWindowHandle(dialog), &savedBounds);
savedWindow = WinSaveBits(&savedBounds, &err);
FrmSetActiveForm( dialog );
if( handler )
FrmSetEventHandler( dialog, handler );
FrmPopupForm( formID );
buttonPressed = FrmDoDialog( dialog );
FrmReturnToForm( activeID );
WinRestoreBits(savedWindow, savedBounds.topLeft.x,
savedBounds.topLeft.y);
return buttonPressed;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/