protected override void WndProc(ref Message m)
{
Graphics g;
IntPtr hdc;
Point pt;
Message newMsg = new Message();
newMsg.HWnd = m.HWnd;
switch (m.Msg)
{
case WMConsts.WM_NCHITTEST :
pt = new Point(m.LParam.ToInt32());
pt = PointToClient(pt);
OffsetClientPoint(m.HWnd, ref pt);
if ( m_ncIconRect.Contains(pt) )
m.Result = new IntPtr(WMConsts.HTSYSMENU);
else if ( m_ncCloseButtonRect.Contains(pt) )
m.Result = new IntPtr(WMConsts.HTCLOSE);
else if ( m_ncMaxButtonRect.Contains(pt) )
m.Result = new IntPtr(WMConsts.HTMAXBUTTON);
else if ( m_ncMinButtonRect.Contains(pt) )
m.Result = new IntPtr(WMConsts.HTMINBUTTON);
// top left
else if ( ( pt.X < m_borderLeftTopRect.Right && pt.Y < m_borderWidth) || ( pt.X < m_borderWidth && pt.Y < m_borderLeftTopRect.Bottom) )
m.Result = new IntPtr(WMConsts.HTTOPLEFT);
//top right
else if ( ( pt.X > m_borderRightTopRect.Left && pt.Y < m_borderWidth) || ( pt.X > m_borderRightTopRect.Right - m_borderWidth && pt.Y < m_borderRightTopRect.Bottom) )
m.Result = new IntPtr(WMConsts.HTTOPRIGHT);
// top
else if ( pt.Y < m_borderWidth )
m.Result = new IntPtr(WMConsts.HTTOP);
else if ( m_ncRect.Contains(pt) )
m.Result = new IntPtr(WMConsts.HTCAPTION);
else
base.WndProc(ref m);
break;
case WMConsts.WM_NCLBUTTONDOWN :
pt = new Point(m.LParam.ToInt32());
pt = PointToClient(pt);