|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
catching close buttonHow can I prevent the big close button in the top of the window from
closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing? lord.zol***@gmail.com wrote:
> How can I prevent the big close button in the top of the window from nevermind... solution is e.Cancel (to stop the Closing event) and> closing the window? > I want to have and "are you sure?" confirmation so the user must press > "Yes" before the program ends. Right now, I've tried catching the > FormClosing and FormClosed events. The message box appears at the right > time, but since the form is already closing, it doesn't matter if the > user presses "Yes" or "No". how do I cancel the FormClosing? e.CloseReason. (e is the FormClosing eventarg) Just in case you (or other readers) may want to know about how to trap
the messages from the title bar buttons (maximize/minimize, restore, and exit) then here's a post from Herfried Wagner a while back that may help: Thanks, Seth Rowe ------------------------------------------------------ > Is there a way I can get into a form's close/minimize/maximize events when \\\> those buttons (the 3 small squared button in the upper right corner of a > form) are clicked? Private Const WM_SYSCOMMAND As Int32 = &H112 Private Const SC_MAXIMIZE As Int32 = &HF030 Private Const SC_MINIMIZE As Int32 = &HF020 Private Const SC_RESTORE As Int32 = &HF120 Private Const SC_CLOSE As Int32 = &HF060 Protected Overrides Sub WndProc(ByRef m As Message) If m.Msg = WM_SYSCOMMAND Then Select Case m.WParam.ToInt32() Case SC_MAXIMIZE Debug.WriteLine("Form gets maximized.") Case SC_MINIMIZE Debug.WriteLine("Form gets minimized.") Case SC_RESTORE Debug.WriteLine("Form gets restored.") Case SC_CLOSE Debug.WriteLine("Form gets closed.") End Select End If MyBase.WndProc(m) End Sub /// -- Show quoteHide quoteM S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> ------------------------------------------------------ lord.zol***@gmail.com wrote: > lord.zol***@gmail.com wrote: > > How can I prevent the big close button in the top of the window from > > closing the window? > > I want to have and "are you sure?" confirmation so the user must press > > "Yes" before the program ends. Right now, I've tried catching the > > FormClosing and FormClosed events. The message box appears at the right > > time, but since the form is already closing, it doesn't matter if the > > user presses "Yes" or "No". how do I cancel the FormClosing? > > > nevermind... solution is e.Cancel (to stop the Closing event) and > e.CloseReason. > (e is the FormClosing eventarg) Rowe,
Not in this case, the e.cancel is in this exit question in my idea the best. Cor Show quoteHide quote "rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht news:1164904713.019410.272200@j72g2000cwa.googlegroups.com... > Just in case you (or other readers) may want to know about how to trap > the messages from the title bar buttons (maximize/minimize, restore, > and exit) then here's a post from Herfried Wagner a while back that may > help: > > Thanks, > > Seth Rowe > > ------------------------------------------------------ > >> Is there a way I can get into a form's close/minimize/maximize events >> when >> those buttons (the 3 small squared button in the upper right corner of a >> form) are clicked? > > \\\ > Private Const WM_SYSCOMMAND As Int32 = &H112 > > Private Const SC_MAXIMIZE As Int32 = &HF030 > Private Const SC_MINIMIZE As Int32 = &HF020 > Private Const SC_RESTORE As Int32 = &HF120 > Private Const SC_CLOSE As Int32 = &HF060 > > Protected Overrides Sub WndProc(ByRef m As Message) > If m.Msg = WM_SYSCOMMAND Then > Select Case m.WParam.ToInt32() > Case SC_MAXIMIZE > Debug.WriteLine("Form gets maximized.") > Case SC_MINIMIZE > Debug.WriteLine("Form gets minimized.") > Case SC_RESTORE > Debug.WriteLine("Form gets restored.") > Case SC_CLOSE > Debug.WriteLine("Form gets closed.") > End Select > End If > MyBase.WndProc(m) > End Sub > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > > ------------------------------------------------------ > > lord.zol***@gmail.com wrote: >> lord.zol***@gmail.com wrote: >> > How can I prevent the big close button in the top of the window from >> > closing the window? >> > I want to have and "are you sure?" confirmation so the user must press >> > "Yes" before the program ends. Right now, I've tried catching the >> > FormClosing and FormClosed events. The message box appears at the right >> > time, but since the form is already closing, it doesn't matter if the >> > user presses "Yes" or "No". how do I cancel the FormClosing? >> >> >> nevermind... solution is e.Cancel (to stop the Closing event) and >> e.CloseReason. >> (e is the FormClosing eventarg) > > Not in this case, the e.cancel is in this exit question in my idea the best. I know - whenever I see a post about catching the close button I figurethe next question will be "ok, now how do I trap the other buttons?." I figured posted it here would help out someone searching the archives (well, if any one does that anymore :-) ) Thanks, Seth Rowe Cor Ligthert [MVP] wrote: Show quoteHide quote > Rowe, > > Not in this case, the e.cancel is in this exit question in my idea the best. > > Cor > > "rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht > news:1164904713.019410.272200@j72g2000cwa.googlegroups.com... > > Just in case you (or other readers) may want to know about how to trap > > the messages from the title bar buttons (maximize/minimize, restore, > > and exit) then here's a post from Herfried Wagner a while back that may > > help: > > > > Thanks, > > > > Seth Rowe > > > > ------------------------------------------------------ > > > >> Is there a way I can get into a form's close/minimize/maximize events > >> when > >> those buttons (the 3 small squared button in the upper right corner of a > >> form) are clicked? > > > > \\\ > > Private Const WM_SYSCOMMAND As Int32 = &H112 > > > > Private Const SC_MAXIMIZE As Int32 = &HF030 > > Private Const SC_MINIMIZE As Int32 = &HF020 > > Private Const SC_RESTORE As Int32 = &HF120 > > Private Const SC_CLOSE As Int32 = &HF060 > > > > Protected Overrides Sub WndProc(ByRef m As Message) > > If m.Msg = WM_SYSCOMMAND Then > > Select Case m.WParam.ToInt32() > > Case SC_MAXIMIZE > > Debug.WriteLine("Form gets maximized.") > > Case SC_MINIMIZE > > Debug.WriteLine("Form gets minimized.") > > Case SC_RESTORE > > Debug.WriteLine("Form gets restored.") > > Case SC_CLOSE > > Debug.WriteLine("Form gets closed.") > > End Select > > End If > > MyBase.WndProc(m) > > End Sub > > /// > > > > -- > > M S Herfried K. Wagner > > M V P <URL:http://dotnet.mvps.org/> > > V B <URL:http://classicvb.org/petition/> > > > > ------------------------------------------------------ > > > > lord.zol***@gmail.com wrote: > >> lord.zol***@gmail.com wrote: > >> > How can I prevent the big close button in the top of the window from > >> > closing the window? > >> > I want to have and "are you sure?" confirmation so the user must press > >> > "Yes" before the program ends. Right now, I've tried catching the > >> > FormClosing and FormClosed events. The message box appears at the right > >> > time, but since the form is already closing, it doesn't matter if the > >> > user presses "Yes" or "No". how do I cancel the FormClosing? > >> > >> > >> nevermind... solution is e.Cancel (to stop the Closing event) and > >> e.CloseReason. > >> (e is the FormClosing eventarg) > > In the form_closing event
set 'cancel = true' <lord.zol***@gmail.com> wrote in message Show quoteHide quote news:1164903494.269481.8000@l39g2000cwd.googlegroups.com... > How can I prevent the big close button in the top of the window from > closing the window? > I want to have and "are you sure?" confirmation so the user must press > "Yes" before the program ends. Right now, I've tried catching the > FormClosing and FormClosed events. The message box appears at the right > time, but since the form is already closing, it doesn't matter if the > user presses "Yes" or "No". how do I cancel the FormClosing? >
Re: Is VB.NET Stable?? To Aaron Kemp - Ahole Extrordinare
String to Byte & Vice Versa Best way to communicate from Desktop to SQL DB Re: Is VB.NET Stable?? Dropping folder on desk top icon Create Property on the fly Re: Is VB.NET Stable?? load external html vs 2005 Transparent text box. Serialization problem |
|||||||||||||||||||||||