What causes my borderless C++/CLI app to crash when overriding WndProc?
- by Ste
I use a form with border NONE. I need to override WndProc for resize and move form. However, using this code, my app crashes!
static const int WM_NCHITTEST = 0x0084;
static const int HTCLIENT = 1;
static const int HTCAPTION = 2;
protected: virtual void Form1::WndProc(System::Windows::Forms::Message %m) override
{
switch (m.Msg)
{
case WM_NCHITTEST:
if (m.Result == IntPtr(HTCLIENT))
{
m.Result = IntPtr(HTCAPTION);
}
break;
}
Form1::WndProc(m);
}
virtual System::Windows::Forms::CreateParams^ get() override
{
System::Windows::Forms::CreateParams^ cp = __super::CreateParams;
cp->Style |= 0x40000;
return cp;
}
How can I fix my code not to crash but still allow my form to be moved and resized?