This is for all of us who always thought the menus should be given a chance to survive a click.
Here it is, straight from the class browser's output:
**************************************************
*-- Class: restorepopup (w:\prglib\m4_forms.vcx)
*-- ParentClass: shape
*-- BaseClass: shape
*
DEFINE CLASS restorepopup AS shape
Height = 68
Width = 68
Name = "restorepopup"
Visible = .f.
*-- Store the Popup()
HIDDEN frompopup
*-- store the bar()
HIDDEN frombar
PROCEDURE Init
this.FromPopup=popup()
this.fromBar=bar()
ENDPROC
PROCEDURE Destroy
if !empty(this.fromPopup)
activate popup (this.fromPopup) bar this.frombar && nowait
thisform.visible=.f.
endif
ENDPROC
ENDDEFINE
Just create a visual class with these properties and methods, and then drop it on your form. It remembers the last active popup and its active bar, and it reactivates it when it gets destroyed - i.e. when your form is getting released. The form isn't released until something gets clicked (the popups are, in their own right, modal), so I've added the thisform.visible=.f. just to patch the visual effect. I thought the nowait clause would overcome this, but then it didn't work at all, because I've had some other modal dialogs popping up for different reasons, and they seemed to interfere with this, so YMMV - maybe it should work with the nowait.
The net effect of this is that the form reactivates the popup it was called from, with the bar selected. Someone asked for this a few days ago, but I've just done some maintenance with my message tables and... well, I don't have the message anymore. I guess it was Jeff Sullivan who needed this - I see a new message from him on the subject. Jeff, how do you like this?
I'm not sure if this is against The Guidelines - the popup does vanish as required. It just gets restored afterwards, which is not mentioned anywhere, and I doubt it's explicitly forbidden anywhere.