unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
FAnchors: TAnchors;
procedure WMMOVING(var Msg: TMessage); message WM_MOVING;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses Math;{ TForm1 }procedure TForm1.WMMOVING(var Msg: TMessage);
begin
inherited;
with PRect(Msg.LParam)^ do begin
Left := Min(Max(0, Left), Screen.Width - Width);
Top := Min(Max(0, Top), Screen.Height - Height);
Right := Min(Max(Width, Right), Screen.Width);
Bottom := Min(Max(Height, Bottom), Screen.Height);
FAnchors := [];
if Left = 0 then Include(FAnchors, akLeft);
if Right = Screen.Width then Include(FAnchors, akRight);
if Top = 0 then Include(FAnchors, akTop);
if Bottom = Screen.Height then Include(FAnchors, akBottom);
Timer1.Enabled := FAnchors <> [];
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
Timer1.Interval := 200;
FormStyle := fsStayOnTop;
end;procedure TForm1.Timer1Timer(Sender: TObject);
const
cOffset = 2;
begin
if WindowFromPoint(Mouse.CursorPos) = Handle then begin
if akLeft in FAnchors then Left := 0;
if akTop in FAnchors then Top := 0;
if akRight in FAnchors then Left := Screen.Width - Width;
if akBottom in FAnchors then Top := Screen.Height - Height;
end else begin
if akLeft in FAnchors then Left := -Width + cOffset;
if akTop in FAnchors then Top := -Height + cOffset;
if akRight in FAnchors then Left := Screen.Width - cOffset;
if akBottom in FAnchors then Top := Screen.Height - cOffset;
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
FAnchors: TAnchors;
procedure WMMOVING(var Msg: TMessage); message WM_MOVING;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses Math;{ TForm1 }procedure TForm1.WMMOVING(var Msg: TMessage);
begin
inherited;
with PRect(Msg.LParam)^ do begin
Left := Min(Max(0, Left), Screen.Width - Width);
Top := Min(Max(0, Top), Screen.Height - Height);
Right := Min(Max(Width, Right), Screen.Width);
Bottom := Min(Max(Height, Bottom), Screen.Height);
FAnchors := [];
if Left = 0 then Include(FAnchors, akLeft);
if Right = Screen.Width then Include(FAnchors, akRight);
if Top = 0 then Include(FAnchors, akTop);
if Bottom = Screen.Height then Include(FAnchors, akBottom);
Timer1.Enabled := FAnchors <> [];
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
Timer1.Interval := 200;
FormStyle := fsStayOnTop;
end;procedure TForm1.Timer1Timer(Sender: TObject);
const
cOffset = 2;
begin
if WindowFromPoint(Mouse.CursorPos) = Handle then begin
if akLeft in FAnchors then Left := 0;
if akTop in FAnchors then Top := 0;
if akRight in FAnchors then Left := Screen.Width - Width;
if akBottom in FAnchors then Top := Screen.Height - Height;
end else begin
if akLeft in FAnchors then Left := -Width + cOffset;
if akTop in FAnchors then Top := -Height + cOffset;
if akRight in FAnchors then Left := Screen.Width - cOffset;
if akBottom in FAnchors then Top := Screen.Height - cOffset;
end;
end;end.
解决方案 »
- 如果Dbgrid的第三列为负数,,显示的时候如何变成正数显示?
- 移动文件的问题!MoveFileEx
- 有人使用modelmaker吗?我不会在它的类图里画聚合关系
- 高手请进:帮我把类型为cardinal的信息怎样在可视化的界面上显示出来?!
- TComboBox控件中清除text属性
- 请问哪套报表控件可以支持Unicode
- FastReport报表页面的设置问题
- 求个为帮忙:项目中遇到的问题(在线等待)
- 为什么主键找不到?????
- 各位版主delphi高手 大家帮帮我吧 我实在没办法了!!!!!
- Delphi7中用dbExpress連接MSSQL老是報錯;求教!!!!
- 为什么我的delphi的帮助文件里的内容没有别人的多?
http://www.csdn.net/Expert/TopicView1.asp?id=621216
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Memo1: TMemo
Left = 0
Top = 0
Width = 536
Height = 348
Align = alClient
Lines.Strings = (
'Memo1')
TabOrder = 0
end
object Timer1: TTimer
OnTimer = Timer1Timer
Left = 120
Top = 24
end
end