delphi 自定义popupmenu,Delphi自定义弹出/下拉菜单,怎么样?

I want to make a custom dropdow/popup menu with a shadow nicely beneath it. The problem is that it is not a standard menu and I need to put some components on the popup/dropdown. So basically I want a dropdown I can do whatever I want with, not being limited to simple menuitems. I want it to act like a normal popupmenu problem is where do I start. Any solutions? References?

解决方案

It sounds like you want a form that looks like a popup menu, but contains components.

It is easier if you have a component that has an OnMouseDown event, like the TPanel shown in this sample, and you just pop up a second form which contains the controls you wanted to pop up:

procedure TForm3.JvPanel1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

if Button=mbRight then

FDown := true

else

FDown := false;

end;

procedure TForm3.JvPanel1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

var

pt:TPoint;

begin

if Button=mbRight then begin

FDown := true;

pt.X := jvPanel1.Left;

pt.Y := jvPanel1.Top+jvPanel1.Height;

pt := ClientToScreen(pt);

Form4.Position := poDesigned;

Form4.BorderStyle := bsNone;

Form4.Left := pt.X;

Form4.Top := pt.Y;

Form4.Show;

end;

end;

That handles the form showing itself, and positioning itself to look like a popup.

the second form hiding itself, is easy too:

procedure TForm4.FormDeactivate(Sender: TObject);

begin

Hide;

end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值