Problem with menu events

When a dialog box is created and showed as a result of processing a menu event, the dialog box is overlapped by the GFA-BASIC 32 IDE immediately. The IDE is brought to foreground after showing the dialog. This is a direct result from the internal WM_COMMAND handling of the IDE: it simply set the focus to the editor after handling the WM_COMMAND message, e.g. the menu event. It doesn't check for a visible dialog box. This problem only occurs after a menu event, not with a keyboard event.

One workaround could be by posting the keyboard shortcut that creates the dialog.

 

Sub menuDialog(i%)

SendKeys "^+9"        'calls Gfa_Ex_9 eventually

EndSub

This way the keyboard shortcut is placed in the message queue and will not be retrieved before the menu event is handled completely and the main message loop is re-entered.

Another solution is to relocate the ShowDialog command to the Gfa_CB procedure. Then, rather than invoke ShowDialog and SetFocus post a WM_USER message to display dialog. The advantage of this approach is that the initialization of the dialog box can be done in the Gfa_CB as well. The entire handling of the dialog box can be combined in one procedure.

{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}