Einzelnen Beitrag anzeigen

Hawkeye219

Registriert seit: 18. Feb 2006
Ort: Stolberg
2.227 Beiträge
 
Delphi 2010 Professional
 
#2

Re: Formgrösse ändern - kleiner Fehler

  Alt 6. Apr 2007, 14:41
Hallo,

hier ist eine Anregung:

[code=delphi]
// Liefert einen eindeutigen Code für die Position von (x,y) im Rechteck R
function GetBorderCode (x, y: Integer; const R: TRect): Cardinal;
const
BORDER = 8; // Größe des "Rahmens"
begin
Result := 0;
if (x < R.Left + BORDER) then Inc (Result, 8);
if (x >= R.Right - BORDER) then Inc (Result, 2);
if (y < R.Top + BORDER) then Inc (Result, 1);
if (y >= R.Bottom - BORDER) then Inc (Result, 4);
end;

// Ändert die Cursorform in Abhängigkeit der Mauszeigerposition
procedure TDemoForm.Panel1MouseMove (Sender: TObject;
Shift: TShiftState; X, Y: Integer);
const
Cursors : array [0..15] of TCursor = (
// Umsetzung BorderCode -> CursorForm
crDefault, crSizeNS, crSizeWE, crSizeNESW,
crSizeNS, crDefault, crSizeNWSE, crDefault,
crSizeWE, crSizeNWSE, crDefault, crDefault,
crSizeNESW, crDefault, crDefault, crDefault
);
var
Code : Cardinal;
begin
Code := GetBorderCode(X, Y, Panel1.BoundsRect);
Screen.Cursor := Cursors[Code];
end;

// Startet eine Größenänderung des Formulars
procedure TDemoForm.Panel1MouseDown (Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
Command : array [0..15] of Integer = (
// Umsetzung BorderCode -> CommandCode für WM_SYSCOMMAND
0, $F003, $F002, $F005,
$F006, 0, $F008, 0,
$F001, $F004, 0, 0,
$F007, 0, 0, 0
);
var
Code : Cardinal;
cmd : Integer;
begin
Code := GetBorderCode(X, Y, Panel1.BoundsRect);
cmd := Command
Code:
;
  if (cmd <> 0) then
    begin
      ReleaseCapture;
      Perform(WM_SYSCOMMAND, cmd, 0);
    end;
end;
Gruß Hawkeye
  Mit Zitat antworten Zitat