Einzelnen Beitrag anzeigen

Benutzerbild von _frank_
_frank_

Registriert seit: 21. Feb 2003
Ort: Plauen / Bamberg
922 Beiträge
 
Delphi 3 Professional
 
#7

Re: TPanel während der Laufzeit die Größe verändern ?

  Alt 20. Aug 2006, 19:06
ich würde die rects im onresize des panels berechnen (r1-r4,für jede ecke) und im mousemove die rects durchprobieren und entsprechend den cursor setzen...

so in etwa (getestet):

Delphi-Quellcode:
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TEdge=(eNone,eTopLeft,eTopRight,eBottomLeft,eBottomRight);
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Panel1Resize(Sender: TObject);
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
    r1,r2,r3,r4:TRect;
    edge:TEdge;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if ptinRect(r1,Point(x,y)) then edge:=eTopLeft else
  if PtInRect(r3,Point(x,y)) then edge:=eBottomRight else
  if ptinRect(r2,Point(x,y)) then edge:=eTopRight else
  if PtInRect(r4,Point(x,y)) then edge:=eBottomLeft else
    edge:=eNone;
  case edge of
    eNone:Panel1.Cursor:=crDefault;
    eTopLeft,eBottomRight:Panel1.Cursor:=crSizeNWSE;
    eTopRight,eBottomLeft: Panel1.Cursor:=crSizeNESW;
  end;
end;

procedure TForm1.Panel1Resize(Sender: TObject);
begin
  r1:=rect(0,0,5,5);
  r3:=rect(panel1.width-5,panel1.height-5,panel1.width,panel1.height);
  r2:=rect(r1.left,r3.top,r1.right,r3.bottom);
  r4:=rect(r3.left,r1.top,r3.right,r1.bottom);
end;

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if edge<>eNone then
  begin
    releaseCapture;
    case edge of
      eTopLeft:Panel1.PerForm(WM_SysCommand, $F004, 0);
      eTopRight:Panel1.PerForm(WM_SysCommand, $F007, 0);
      eBottomLeft:Panel1.PerForm(WM_SysCommand, $F005, 0);
      eBottomRight:Panel1.PerForm(WM_SysCommand, $F008, 0);
    end;
  end;
end;

end.
Gruß Frank
  Mit Zitat antworten Zitat