I have a .net 2.0 windows forms application.
I have overridden the WndProc method to capture the user activities on the form
Ex:
const int HTCLOSE = 0x0014;
bool m_bCloseButtonActive = false;
if (m.Msg == WM_NCHITTEST)
{
base.WndProc(ref m);
m_bCloseButtonActive = (m.Result.ToInt32() == HTCLOSE);
}
Based on the value of m_bCloseButtonActive i take further actions.
The issue now i face is my form doesn't close as it is not able to capture the Close button clicked event in the Operating systems Vista and above(even Windows 7).
i.e the condition m.Result.ToInt32() == HTCLOSE is never true and my form never closes when i click the close button.
My application works in previous OS (Windows 2000, XP, XP Embedded). Also an interesting thing is that it works when i specify
Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAreaEnabled;
Any idea whats going on in here. Is this something related to the Desktop Windows Manager, my application is not able to trap the close button clicked event.
Thanks in advance