Friday, November 26, 2010

Draw Grabber Line on Canvas / Form

Below is the code snippet to draw a Grabber line... Its all self explainatory
const
  GrabberSize = 12;

procedure TForm1.DoPaintSidePanel();

procedure DrawGrabberLine(ALeft, ATop, ARight, ABottom: Integer);
begin
  with Canvas do
  begin
    Pen.Color := clBtnHighlight;
    MoveTo(ARight, ATop);
    LineTo(ALeft, ATop);
    LineTo(ALeft, ABottom);
    Pen.Color := clBtnShadow;
    LineTo(ARight, ABottom);
    LineTo(ARight, ATop-1);
  end;
end;
begin
  Canvas.Lock;
  try
    DrawGrabberLine(3, 12, 5, Height-2);
    DrawGrabberLine(6, 12, 8, Height-2);
  finally
    Canvas.Unlock;
  end;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  DoPaintSidePanel();
end;

No comments: