So gehts jetzt, habs auch mit
MDI getestet:
Delphi-Quellcode:
procedure TForm1.WMMove(
var Message: TWMMove);
var
ParentWnd : HWND;
ParentCRect : TRect;
begin
ParentWnd := GetParent(
Handle);
If (
Message.XPos < 0)
then
Left := 0;
If (
Message.YPos < GetSystemMetrics(SM_CYCAPTION))
then
Top := 0;
If (ParentWnd <> 0)
then
begin
Windows.GetClientRect(ParentWnd, ParentCRect);
If (
Message.XPos > (ParentCRect.Right - Width))
then
Left := ParentCRect.Right - Width;
If (
Message.YPos > (ParentCRect.Bottom - Height - GetSystemMetrics(SM_CYCAPTION)))
then
Top := ParentCRect.Bottom - Height;
end
else
begin
If (
Message.XPos > (Screen.Width - Width))
then
Left := Screen.Width - Width;
If (
Message.YPos > (Screen.Height - Height - GetSystemMetrics(SM_CYCAPTION)))
then
Top := Screen.Height - Height - GetSystemMetrics(SM_CYCAPTION);
end;
Message.result := 0;
end;