title: Resize Form from the Drawn Shape of Panel - VB.NET
body: <p>I'm trying to make a form resizable based on dragging a custom shape drawn at the corner of the panel. I have a code which works fantastic if it's drawn in the main form, but if I'm trying to draw it at the corner of a panel it doesn't work, I cannot resize the form. The code is optimized to be drawn in the form, could someone help me and update it to work in a panel too?</p>
  
  <pre><code>    Protected Overrides Sub WndProc(ByRef m As Message)
      MyBase.WndProc(m)
      If m.Msg = &amp;H84 Then
          Dim pos = Me.PointToClient(New System.Drawing.Point(m.LParam.ToInt32() And &amp;HFFFF, m.LParam.ToInt32() &gt;&gt; 16))
          If pos.X &gt;= Me.Width - grab AndAlso pos.Y &gt;= Me.Height - grab Then
              m.Result = New IntPtr(17)
          End If
      End If
  End Sub
  Private Const grab As Integer = 14
  
  Protected Overrides Sub OnPaint(e As PaintEventArgs)
      MyBase.OnPaint(e)
      Dim rc = New System.Drawing.Rectangle(Me.Width - grab, Me.Height - grab, grab, grab)
      ControlPaint.DrawSizeGrip(e.Graphics, System.Drawing.Color.FromArgb(250, 250, 250), rc)
  End Sub
  </code></pre>
  
  <p>It looks like this:</p>
  
  <p><a href="http://i.stack.imgur.com/qKhxm.png" rel="nofollow">Here</a></p>