tak jsem si s tim lamal hlavu dalsich nekolik hodin,ale diky svymu neumu jsem to na jiz vytvorenej panel nedokazal prevest.
ale nasel jsem jinej kod primo na to, co potrebuji,ovsem je tady zapis funkce GetRectCorner, kterou mi D7 nechce prelozit a se kterou si nevim rady. pomuze mi prosim nekdo ??
konkretneji radek ... if x if y else , znam zapis if x <>= neco then neco a potom az else, .. to mi dava logiku,ale tenhle zapis vidim poprve a nevim co s nim. prosim poradte.
type
TRectCorner = (rcClient,rcTopLeft,rcTop,rcTopRight,rcLeft,rcRight,
rcBottomLeft,rcBottom,rcBottomRight);
function GetRectCorner(BoundsRect: TRect; P: TPoint): TRectCorner;
const
BorderSize = 4;
CornerSize = 16;
begin
with BoundsRect,P do
if y if x else if x>Right-CornerSize then Result:=rcTopRight
else Result:=rcTop
else if y>Bottom-BorderSize then
if x else if x>Right-CornerSize then Result:=rcBottomRight
else Result:=rcBottom
else if x if y else if y>Bottom-CornerSize then Result:=rcBottomLeft
else Result:=rcLeft
else if x>Right-BorderSize then
if y else if y>Bottom-CornerSize then Result:=rcBottomRight
else Result:=rcRight
else
Result:=rcClient;
end;
function RectCornerToSizeCursor(Corner: TRectCorner; Default: TCursor): TCursor;
begin
case Corner of
rcLeft,rcRight: Result:=crSizeWE;
rcTop,rcBottom: Result:=crSizeNS;
rcTopLeft,rcBottomRight: Result:=crSizeNWSE;
rcTopRight,rcBottomLeft: Result:=crSizeNESW;
else
Result:=Default;
end;
end;
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
SC_SIZELEFT = 1;
SC_SIZERIGHT = 2;
SC_SIZETOP = 3;
SC_SIZEBOTTOM = 6;
var
Corner: TRectCorner;
MsgCode: Integer;
begin
Corner:=GetRectCorner(Panel1.BoundsRect,
ScreenToClient(Panel1.ClientToScreen(Point(X,Y)))) ;
if Corner<>rcClient then
begin
SetCursor(Screen.Cursors[
RectCornerToSizeCursor(
GetRectCorner(Panel1.BoundsRect,
ScreenToClient(Panel1.ClientToScreen(Point(X,Y)))) ,
Cursor)]);
MsgCode:=SC_SIZE;
if Corner in [rcTopLeft,rcLeft,rcBottomLeft] then
Inc(MsgCode,SC_SIZELEFT)
else if Corner in [rcTopRight,rcRight,rcBottomRight] then
Inc(MsgCode,SC_SIZERIGHT);
if Corner in [rcTopLeft,rcTop,rcTopRight] then
Inc(MsgCode,SC_SIZETOP)
else if Corner in [rcBottomLeft,rcBottom,rcBottomRight] then
Inc(MsgCode,SC_SIZEBOTTOM);
ReleaseCapture;
SendMessage(Panel1.Handle,WM_SYSCOMMAND,MsgCode,0) ;
end;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
SetCursor(Screen.Cursors[
RectCornerToSizeCursor(
GetRectCorner(Panel1.BoundsRect,
ScreenToClient(Panel1.ClientToScreen(Point(X,Y)))) ,
Cursor)]);
end;