Windows Forms Control Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I tell if a user clicks the Close "X" on the windows form control box?
 
Dennis said:
How can I tell if a user clicks the Close "X" on the windows form control box?

If I remember correctly you have to override the mouse click event for
the form and the calculate if it is in that section. I could be wrong,
and I'm sure someone will correct me if I am.

Chris
 
Choose the Form's Closing event

You have 'e'. So, you could say:

e.Cancel = True

This means if the user clicks the ControlBox the application isn't closed,
but is handled how you need it. So this in conjunction of the Form_Closing
event is what you need

Crouchie1998
BA (HONS) MCP MCSE
 
Crouchie,
e.Cancel = True
This was not asked and I hope that Dennis will not implement this or he
should use a messagebox to ask by instance if closing true should be done.

In the other case *I* see it, when it is implemented as you wrote, as a bug.

There are possibilities to disable the X what than is in my opinion a good
solution..

Cor
 
If I have a button, "Apply" on the form and the user clicks it and I close
the form in this button click event, then the form closing event fires also
so I don't know which action the user took in the Form Closing event, i.e.,
clicked the button or the control box close. I know I could set a form
scoped variable boolean and set it to true in the button click event then
check it in the control box close event but I was hoping for something a bit
more elegant!
 
That's the only way I've found so far...not very neat but it does work.
 
Thanks...I'll study it as I've not actually used WinProc before but now's as
good a time as any.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top