procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var r1,r2:Trect;
begin
releasecapture;
r1:=rect(0,0,5,5);
r2:=rect(panel1.width-5,panel1.height-5,panel1.width,panel1.height);
if ptInRect(r1,Point(x,y)) then
Panel1.PerForm(WM_SysCommand, $F004, 0)
else if ptInRect(r2,Point(x,y)) then
Panel1.PerForm(WM_SysCommand, $F008, 0)
else if ptInRect(rect(r1.left,r2.top,r1.right,r2.bottom),Point(x,y)) then
Panel1.PerForm(WM_SysCommand, $F007, 0)
else if ptInRect(rect(r2.left,r1.top,r2.right,r1.bottom),Point(x,y)) then
Panel1.PerForm(WM_SysCommand, $F005, 0)
end;