|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Q: closing a formHi
I'm soooo sorry but I've had to re-post this message again. I have no idea what has been happening but for some reason I couldn't seem to be able to see messages that I'd posted earlier. My question is this - how can I determine if a user clicked the cross in the top right of the form to close it. Thanks in advance (and sorry again for re-posting) Goeff "G .Net" <nodamnspam@email.com> schrieb And what if he closes it from the window menu or by pressing Alt+F4 or by > Hi > > I'm soooo sorry but I've had to re-post this message again. I have > no idea what has been happening but for some reason I couldn't seem > to be able to see messages that I'd posted earlier. > > My question is this - how can I determine if a user clicked the > cross in the top right of the form to close it. > > Thanks in advance (and sorry again for re-posting) pressing a Close-Button? Does it make a difference? Maybe you're looking for the Closing or Closed events. Armin Hi Armin
I think that the events Close and Closing occur whatever way the form has closed e.g. if there is button with DialogResult Ok then it will still trigger the above. I need to know the form has been closed by clicking the cross. Geoff Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:%23zkiI8NTGHA.5924@TK2MSFTNGP09.phx.gbl... > "G .Net" <nodamnspam@email.com> schrieb >> Hi >> >> I'm soooo sorry but I've had to re-post this message again. I have >> no idea what has been happening but for some reason I couldn't seem >> to be able to see messages that I'd posted earlier. >> >> My question is this - how can I determine if a user clicked the >> cross in the top right of the form to close it. >> >> Thanks in advance (and sorry again for re-posting) > > > And what if he closes it from the window menu or by pressing Alt+F4 or by > pressing a Close-Button? Does it make a difference? > > Maybe you're looking for the Closing or Closed events. > > > Armin As far as I know, the .Net framework does not recognise a difference
between the different possible ways of closing a form. It might not even be possible at a low level to distinguish them - say, each method just sends a WM_CLOSE message. However, as Armin indicated, if you could give more information about why knowing whether the form was closed this way is important, perhaps someone could suggest another way to achieve your desired result. hth, Alan. Hi
Interesting. I've thought of a way to do it. Basically, I'm going to create a boolean which will be set to true if some buttons are pressed otherwise it will be left as false. I can then check the variable in the OnClose event which will give the functionality I require. The reason I am trying this is that I want to re-set some global variables if, for example, a cancel button is pressed. Geoff Show quoteHide quote "AlanT" <alanto***@users.com> wrote in message news:1142952524.460688.84490@u72g2000cwu.googlegroups.com... > > As far as I know, the .Net framework does not recognise a difference > between the different possible ways of closing a form. > > It might not even be possible at a low level to distinguish them - say, > each method just sends a WM_CLOSE message. > > However, as Armin indicated, if you could give more information about > why knowing whether the form was closed this way is important, perhaps > someone could suggest another way to achieve your desired result. > > hth, > Alan. > > As far as I know, the .Net framework does not recognise a difference It may not know the difference between Alt-F4 and closing the form, but it > between the different possible ways of closing a form. can offer some assistance. In the FormClosing event, you can check the CloseReason property of the event arg for some ideas. It will tell you if the reason is due to MDIParent closing, OS shutdown, etc. It does not distinguish between form closing by the user selecting the X, Alt-F4, and me.close() in a btnOk.Click handler however. Jim Wooley http://devauthority.com/blogs/jwooley "G .Net" <nodamnspam@email.com> schrieb If you're using VB 2005, you could handle the FormClosing event and look at > Hi Armin > > I think that the events Close and Closing occur whatever way the > form has closed e.g. if there is button with DialogResult Ok then it > will still trigger the above. I need to know the form has been > closed by clicking the cross. e.CloseReason. I still don't know if you want to distinguish between the cross and the window menu and Alt+F4. If this is all the same and there is only a difference to the button, then you could evaluate the Dialogresult property, which is only Dialogresult.Ok if you used the button. Armin > I'm soooo sorry but I've had to re-post this message again. I have no FWIW, you can browse to the original message thread at http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc> idea what has been happening but for some reason I couldn't seem to be > able to see messages that I'd posted earlier. > > My question is this - how can I determine if a user clicked the cross > in the top right of the form to close it. Jim Wooley http://devauthority.com/blogs/jwooley Cheers Jim
Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8e47648c81b01962a286a@msnews.microsoft.com... >> I'm soooo sorry but I've had to re-post this message again. I have no >> idea what has been happening but for some reason I couldn't seem to be >> able to see messages that I'd posted earlier. >> >> My question is this - how can I determine if a user clicked the cross >> in the top right of the form to close it. > > FWIW, you can browse to the original message thread at > http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc > > Jim Wooley > http://devauthority.com/blogs/jwooley > > Thanks everybody for all your help.
Geoff Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8e47648c81b01962a286a@msnews.microsoft.com... >> I'm soooo sorry but I've had to re-post this message again. I have no >> idea what has been happening but for some reason I couldn't seem to be >> able to see messages that I'd posted earlier. >> >> My question is this - how can I determine if a user clicked the cross >> in the top right of the form to close it. > > FWIW, you can browse to the original message thread at > http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_frm/thread/c1bb8c32c77d8ea1/ba0e849bc599d7fc?q=Q%3Aclosing+a+form&rnum=1#ba0e849bc599d7fc > > Jim Wooley > http://devauthority.com/blogs/jwooley > > |
|||||||||||||||||||||||