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 |
正在阅读:Delphi中的窗体移动Delphi中的窗体移动
2004-03-31 10:17
出处:delphi精髓网
责任编辑:sdq
键盘也能翻页,试试“← →”键