Article # 160, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
Using FoamStandardDialogOptrNoBlock vs PutUpDialogViaUIThread
Q. Can FoamStandardDialogOptrNoBlock be used in place of PutUpDialogViaUIThread? A. Well, this is a little tricky. Here are the issues, if you don't use FoamStandardDialogOptrNoBlock: 1) The dialog has to be runnable by the system UI thread (not your application), which means you have to use a template dialog, and call UserCreateDialog from the UI thread (see how to do this below). 2) Since you want a no-blocking dialog (since you cannot put up a blocking dialog on the UI thread) you need some way to make the dialog free itself when it goes away. Hence, the dialog box itself should not be an instance of GenInteraction, but rather an instance of SelfDestroyingDialogClass. If you use FoamStandardDialogOptrNoBlock, it handles creating and freeing the dialog for you, so you don't have to worry about the above issues. You *do*, however, need to call it from the UI thread. Here's how to do it: 1) Get the handle of the UI thread: ThreadHandle uiHandle; optr uiOptr; uiHandle = SysGetInfo( SGIT_UI_PROCESS ); 2) Send a message to the UI thread, passing a routine that will be called on that thread: uiOptr = ConstructOptr( uiHandle, 0 ); @call uiOptr::MSG_PROCESS_CALL_ROUTINE( 0, 0, 0, 0, 0, 0, DisplayDialog ); 3) Have that routine call FoamStandardDialogOptrNoBlock void DisplayDialog() { ... FoamStandardDialogOptrNoBlock(...) ... } You can either have separate routines for each dialog you display, or change your DisplayDialog routine to have some assembly code that accepts parameters in registers.