Re: Get the "User pressed close button (in controlbox)" event...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: msnews.microsoft.com (freddyk_at_microsoft.com)
Date: 04/09/04


Date: Fri, 9 Apr 2004 15:44:58 +0200

Good practice would be to make code that does not need to know this.
Reason: If for some reason the next version of something makes a new way of
closing a window - you would have to change your code accordingly.
You should make the code to flag a success-return whereever this is needed
and you should take anything else as a cancel.

So - your dialog probably will have a static execute method, which creates
the dialog - runs it modal and returns the result - you should set the
result value to cancel in your constructor - and change it whereever you
select to return something else.

If you are in a situation where you have to know - you should override
WndProc and make special code for the message that origines from the X
button.

/Freddy

"Klaus" <klaus@-NOSPAM-kitchen-net.com.au> wrote in message
news:uESutsdHEHA.2668@TK2MSFTNGP10.phx.gbl...
> ..a seemingly easy task, but I just can't figure it out:
>
> want to retrieve the event "close ("X") button clicked" in a modal form.
Can't use the "Closing" event as I have to distinguish between a closing of
the form after a selection made and an abortion (which happens when the user
just closes the modal form by the forms Close ("X") button.
>
> Anyone an idea?
>
> Thanks.
> Klaus
>
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/



Relevant Pages

  • RE: Code to Implement Required Cells Not Working
    ... Cancel As Boolean) ... Dim iCell As Variant ... "a Reason Category has been selected.", ... "Change Type has been selected.", ...
    (microsoft.public.excel.programming)
  • Re: Simon is impersonating me.
    ... TeamB, and by association CG, are to maintain their reputation. ... explanation, and so would have to stay their hand. ... If the reason for concellation is obvious, ... BUT if there IS NO REASON to cancel, ...
    (borland.public.delphi.non-technical)
  • Re: cancelling at play-asia
    ... preparation, you may modify or cancel your order here." ... But it was the main reason I made the order. ... Obviously, the 2 better ones for me were shipped, but that Teacher one looks alright and my daughter is chomping to buy it locally for 50euros...out of her own money of course. ...
    (uk.games.video.misc)
  • Re: Outlook 2003 crashing/not closing
    ... The reason that I ask is ... >not closing. ... PDA synchronization software with your PDA in the cradle. ... Mail reminder add-ins that keep a stub of Outlook open in the ...
    (microsoft.public.outlook)
  • Re: Confirm data change on close
    ... closing the form or the application will save any changes. ... There is no real good reason to use a save button. ... For your Exit Button, just use Docmd.Close in the click event. ... to check for changes in the Form's Unload event. ...
    (microsoft.public.access.formscoding)