How can I detect the click event of the close (X) button at the top right corner of the control box of a form/window? Please note, I don't want to know about CloseReason, FormClosing, FormClosed or stuffs like these, unless they are inevitable. I exactly want to detect if the user clicked the X button of the form. Thanks.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you really have a good reason not to use
FormClosing, CloseReason, ...
, you can override the window procedure and write something like this:The details can be found here and here.
I know this is old thread, but here is a solution.
To get WM_NCLBUTTONUP work, don't call to base WndProc when you get WM_NCLBUTTONDOWN message :