i have a Winforms application that does trap some events in WndProc handler, in order to be able to resize and move the window.
What i noticed was, when the application is active in the sharing window of Teams, the top control bar will not appear
What i am wondering, is what event am i trapping or how can i enable the control bar to appear, this doesn't happen when other applications are active, the control bar appears just fine, only when my application has focus, so i am sure its some event that i am preventing from leaving the appl.
the specific event that i am trapping, is WM_NCHITTEST = 0x84;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
Point pos = new Point(m.LParam.ToInt32());
pos = this.PointToClient(pos);
//if (MouseButtons == MouseButtons.Left)
{
// move by title bar
if (pos.X > cGrip && pos.X <= (this.ClientSize.Width - cGrip) && pos.Y > cBorderWidth && pos.Y < cCaption)
{
m.Result = (IntPtr)HTCAPTION; // move
return;
}
// resize top/right corner
if (pos.X >= this.ClientSize.Width - cGrip && pos.Y <= cGrip)
{
m.Result = (IntPtr)HTTOPRIGHT;
return;
}
//resize top left corner
if (pos.X <= cGrip && pos.Y <= cGrip)
{
m.Result = (IntPtr)HTTOPLEFT;
return;
}
//resize top
if (pos.X > cGrip && pos.Y <= cBorderWidth && pos.Y > 0 && pos.X < (this.ClientSize.Width - cGrip))
{
m.Result = (IntPtr)HTTOP;
return;
}
// resize bottom Right
if (pos.X >= this.ClientSize.Width - cGrip && pos.Y >= this.ClientSize.Height - cGrip)
{
m.Result = (IntPtr)HTBOTTOMRIGHT;
return;
}
// resize right side
if (pos.X >= this.ClientSize.Width - cBorderWidth && pos.Y >= cGrip && pos.Y <= this.ClientSize.Height - cGrip)
{
m.Result = (IntPtr)HTRIGHT;
return;
}
// resize top left
if (pos.X <= cGrip && pos.Y > this.ClientSize.Height - cGrip)
{
m.Result = (IntPtr)HTBOTTOMLEFT;
return;
}
// resize left side
if (pos.X <= cBorderWidth && pos.Y >= cGrip && pos.Y <= this.ClientSize.Height - cGrip)
{
m.Result = (IntPtr)HTLEFT;
return;
}
//resize bottom
if (pos.Y >= (this.ClientSize.Height - cBorderWidth) && pos.X >= cGrip && pos.X < (this.ClientSize.Width - cGrip))
{
m.Result = (IntPtr)HTBOTTOM;
return;
}
m.Result = (IntPtr)HTNOWHERE;
return;
}
}
base.WndProc(ref m);
}
i have tried removing the return following the m-Result, that doesn't work and actually prevents me from being able to resize or move the application window.