秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  278 随笔 :: 0 文章 :: 308 评论 :: 20万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
使用bgrabitmap的TBCLeaBoard控件。
弹出窗口后,如果鼠标离开弹窗,并点击form1的任意位置(利用OnDeactivate),就会关闭弹窗

复制代码
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, lazutf8;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

uses unit2;
{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var p:tpoint;
    myMouse: TMouse;
begin
  p:=ClienttoScreen(point(Button1.Left,Button1.Top+Button1.Height));
  form2.Left:=myMouse.CursorPos.X;
  form2.Top:=p.Y;
  form2.show;
end;

end.
复制代码

复制代码
object Form1: TForm1
  Left = 378
  Height = 622
  Top = 36
  Width = 788
  Caption = 'Form1'
  ClientHeight = 622
  ClientWidth = 788
  DesignTimePPI = 144
  object Button1: TButton
    Left = 48
    Height = 38
    Top = 32
    Width = 113
    Caption = '弹出窗口'
    TabOrder = 0
    OnClick = Button1Click
  end
end
复制代码

 

复制代码
unit Unit2;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
  DBGrids, BCLeaBoard, BCLeaTheme;

type

  { TForm2 }

  TForm2 = class(TForm)
    BCLeaBoard1: TBCLeaBoard;
    Button1: TButton;
    DBGrid1: TDBGrid;
    Edit1: TEdit;
    Label1: TLabel;
    procedure FormDeactivate(Sender: TObject);
  private

  public
  end;

var
  Form2: TForm2;

implementation

{$R *.lfm}

{ TForm2 }

procedure TForm2.FormDeactivate(Sender: TObject);
begin
  close;
end;

end.
复制代码

 

复制代码
object Form2: TForm2
  Left = 382
  Height = 393
  Top = 250
  Width = 559
  AllowDropFiles = True
  AlphaBlendValue = 100
  BorderStyle = bsNone
  Caption = 'Form2'
  ClientHeight = 393
  ClientWidth = 559
  Color = clInactiveCaption
  DesignTimePPI = 144
  OnDeactivate = FormDeactivate
  object BCLeaBoard1: TBCLeaBoard
    Left = 0
    Height = 393
    Top = 0
    Width = 559
    Align = alClient
    TabOrder = 0
    TabStop = False
    FrameColor = 8421440
    BoardColor = clMoneyGreen
    BackgroundColor = clBtnFace
    object Edit1: TEdit
      Left = 89
      Height = 32
      Top = 104
      Width = 216
      TabOrder = 0
      Text = 'Edit1'
    end
    object Button1: TButton
      Left = 320
      Height = 38
      Top = 101
      Width = 113
      Caption = 'Button1'
      TabOrder = 1
    end
    object Label1: TLabel
      Left = 89
      Height = 24
      Top = 64
      Width = 57
      Caption = 'Label1'
    end
    object DBGrid1: TDBGrid
      Left = 51
      Height = 176
      Top = 152
      Width = 464
      Color = clWindow
      Columns = <>
      TabOrder = 2
    end
  end
end 
复制代码
posted on   秋·风  阅读(497)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示