张志峰的博客

水滴石川,积少成多。

导航

delphi button 实现下拉列表

Posted on 2018-11-09 15:09  ╰★张志峰★╮  阅读(1713)  评论(1编辑  收藏  举报
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PopupMenu1: TPopupMenu;
    fgh1: TMenuItem;
    drg1: TMenuItem;
    dg1: TMenuItem;
    procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
pt:TPoint;
begin
GetCursorPos(pt);
PopupMenu1.Popup((pt.x-x),(pt.y+(Button1.Height-y)));

end;

end.

 简单的一种下拉列表