Hirdetés

Aktív témák

  • Edem

    senior tag

    válasz KovacsUr #28 üzenetére

    off
    MODERÁTOR? Gartula! :)
    on

    OK, köszönöm, megvan. Bár csúnya módon kikopiztam egy másik forrásból (kicsit gagyi, mert pl. a 20 nem mint konstans szerepel, de ezt már bárki megcsinálja).
    type
    TForm1 = class(TForm)
    private
    procedure WMWindowPosChanging(var Msg : TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
    end;

    procedure TForm1.WMWindowPosChanging(var Msg : TWMWindowPosChanging);
    var
    Desktop : TRect;
    begin
    Inherited;

    if SystemParametersInfo(SPI_GETWORKAREA, 0, @Desktop, 0) <> True then
    begin
    Desktop.Left := 0;
    Desktop.Top := 0;
    Desktop.Right := GetSystemMetrics(SM_CXSCREEN);
    Desktop.Bottom := GetSystemMetrics(SM_CYSCREEN);
    end;

    if (Msg.WindowPos.x >= Desktop.Left - 20) and
    (Msg.WindowPos.x <= Desktop.Left + 20) then
    begin
    Msg.WindowPos.x := Desktop.Left;
    end;

    if (Msg.WindowPos.x + Width >= Desktop.Right - 20) and
    (Msg.WindowPos.x + Width <= Desktop.Right + 20) then
    begin
    Msg.WindowPos.x := Desktop.Right - Width;
    end;

    if (Msg.WindowPos.y >= Desktop.Top - 20) and
    (Msg.WindowPos.y <= Desktop.Top + 20) then
    begin
    Msg.WindowPos.y := Desktop.Top;
    end;

    if (Msg.WindowPos.y + Height >= Desktop.Bottom - 20) and
    (Msg.WindowPos.y + Height <= Desktop.Bottom + 20) then
    begin
    Msg.WindowPos.y := Desktop.Bottom - Height;
    end;
    end;

Aktív témák