永发信息网

delphi界面怎么设置像QQ一样自动隐藏

答案:3  悬赏:0  手机版
解决时间 2021-05-07 16:36
  • 提问者网友:临风不自傲
  • 2021-05-07 00:12

用delphi开发的软件 生成的EXE文件

怎么像QQ界面那样

拖到windows窗口边沿的时候自动隐藏

鼠标放上去的时候又显示出来?

最佳答案
  • 五星知识达人网友:西风乍起
  • 2021-05-07 01:14

unit Unit1;


interface


uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls,Math, StdCtrls;


type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
private
FAnchors: TAnchors;
procedure WMMOVING(var Msg: TMessage);message WM_MOVING;
public
{ Public declarations }
end;


var
Form1: TForm1;


implementation


{$R *.dfm}



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.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.

全部回答
  • 1楼网友:英雄的欲望
  • 2021-05-07 03:27

在form_move事件中判断一下窗体的坐标,如果Y值小于等于0,则把窗体的高度缩小(不能缩到0,否则就没办法重新显示出来了)

在form_mousemove事件中判断鼠标的位置,在范围内就把窗体的高度恢复为正常值,否则再次把他缩小.

  • 2楼网友:鱼忧
  • 2021-05-07 02:52

有一个控件,可以直接使用就能达到自动隐藏的效果了!

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯