正在阅读:Delphi中的窗体移动Delphi中的窗体移动

2004-03-31 10:17 出处:delphi精髓网 作者:delphi精髓 责任编辑:sdq

            Form2
            unit uDock;
            interface
            uses
            Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
            Dialogs;
            type
            TForm2 = class(TForm)
            procedure FormMouseDown(Sender: TObject; Button: TMouseButton;Shift:
            TShiftState; X, Y: Integer);
            procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y:
            Integer);
            procedure FormMouseUp(Sender: TObject; Button: TMouseButton;Shift:
            TShiftState; X, Y: Integer);
            private
            { Private declarations }
            public
            { Public declarations }
            end;
            var
            Form2: TForm2;
            CanMove, CanMoveX, CanMoveY, DocktoForm: Boolean;
            OldX, OldY: Integer;
            implementation
            uses uMain;
            {$R *.DFM}
            procedure TForm2.FormMouseDown(Sender: TObject; Button:
            TMouseButton;Shift: TShiftState; X, Y: Integer);
            begin
            CanMoveX := true;
            CanMoveY := true;
            CanMove := true;
            OldX := X;
            OldY := Y;
            end;
            procedure TForm2.FormMouseMove(Sender: TObject; Shift: TShiftState;
            X, Y: Integer);
            begin
            if (CanMove) then
            begin
            if CanMoveX then
            Form2.Left := Form2.Left + (X - OldX);
            if CanMoveY then
            Form2.Top := Form2.Top + (Y - OldY);
            //This section latches to the top
            if (Form2.Top < WorkArea.Top + 10) and (Form2.Top > WorkArea.Top-10)
            then

察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品