>>>>>Hi,
>>>>>
>>>>>Can you programmatically close a modal form when a user clicks anywhere outside the form?
>>>>
>>>>Shouldn't form's .deactivate() event fire then?
>>>
>>>When making the form modeless, clicking outside the form indeed closes the form. And I can determine that the form .deactivate is called.
>>>Do you suggest to set the form reference to NULL in deactivate()? So that not to have what I believe is called "dangling" references?
>>>
>>>UPDATE. The code that runs upon a user clicking on a button of the menu form, is based on the form tag value. That is, the tag is set to '1' when user clicks on the 1st button, and so on.
>>>Now, when the form is deactivated, the value of Tag is gone.
>>>How do I pass the value of selected button to the called method?
>>
>>Old trick... you instantiate the form from a class and assign to a variable. Then have your buttons only .hide() the form, not close it. Then in the calling code you still have a reference to your form, can access its properties. Then you can release the variable when done (or if it's a local one, do nothing, it'll release when the code exits).
>
>The above scenario works if the form is Modal. But if the form is Modeless, the deactivate closes the form. And .Tag value is lost.
>Am I misunderstanding what you wrote?
Covered that case in some other reply few minutes ago.