送分题

smilyvm 2008-11-07 01:56:30
任何点击一个按钮后在按钮下方弹出右键菜单
...全文
108 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
HanChin 2008-11-07
  • 打赏
  • 举报
回复
PopupMenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
yuqianyi1974 2008-11-07
  • 打赏
  • 举报
回复

procedure TForm1.ToolButton1Click(Sender: TObject);
var
APoint: TPoint;
begin
apoint:=toolbutton1.ClientToScreen(Point(toolbutton1.Left+toolbutton1.Width, toolbutton1.Top+toolbutton1.Height));
popupmenu1.Popup(apoint.X,apoint.y);
end;
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 dyzhong 的回复:]
Delphi(Pascal) code
procedure TForm1.ToolButton2Click(Sender: TObject);
var
APoint: TPoint;
begin
APoint := ToolButton2.ClientToScreen(Point(0, ToolButton2.ClientHeight));

TrackPopupMenu(PopupMenu1.Handle, TPM_BOTTOMALIGN , APoint.X, APoint.Y,
0, self.Handle, nil);
end;
[/Quote]
这个可以弹出到指定位置,但是不知道怎么回事点击弹出菜单后不执行菜单的N1Click过程,就是点了没反应
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
procedure TFrmPrint.ToolButton3Click(Sender: TObject);
var Rect:TRect;
begin
GetWindowRect(ToolButton3.Handle,Rect);
PopupMenu1.Popup(Rect.Left,Rect.Bottom);
end;
[Error] UPrint.pas(88): Undeclared identifier: 'Handle'
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
toolbutton
yuqianyi1974 2008-11-07
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 smilyvm 的回复:]
引用 7 楼 yuqianyi1974 的回复:
Delphi(Pascal) code
procedure TForm1.Button1Click(Sender: TObject);
var
rct:Trect;
begin
getwindowrect(button1.Handle,rct);
popupmenu1.Popup(rct.Right,rct.Bottom);
end;

[Error] UPrint.pas(87): Undeclared identifier: 'Handle'
[/Quote]
我试好用的,你有button1吗?button1与事件关联了吗?TForm1.Button1Click
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 yuqianyi1974 的回复:]
Delphi(Pascal) code
procedure TForm1.Button1Click(Sender: TObject);
var
rct:Trect;
begin
getwindowrect(button1.Handle,rct);
popupmenu1.Popup(rct.Right,rct.Bottom);
end;
[/Quote]
[Error] UPrint.pas(87): Undeclared identifier: 'Handle'
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
[Error] UPrint.pas(87): Undeclared identifier: 'Handle'
dyzhong 2008-11-07
  • 打赏
  • 举报
回复

procedure TForm1.ToolButton2Click(Sender: TObject);
var
APoint: TPoint;
begin
APoint := ToolButton2.ClientToScreen(Point(0, ToolButton2.ClientHeight));

TrackPopupMenu(PopupMenu1.Handle, TPM_BOTTOMALIGN , APoint.X, APoint.Y,
0, self.Handle, nil);
end;
yuqianyi1974 2008-11-07
  • 打赏
  • 举报
回复

procedure TForm1.Button1Click(Sender: TObject);
var
rct:Trect;
begin
getwindowrect(button1.Handle,rct);
popupmenu1.Popup(rct.Right,rct.Bottom);
end;

yuqianyi1974 2008-11-07
  • 打赏
  • 举报
回复
BOOL GetWindowRect(

HWND hWnd, // handle of window
LPRECT lpRect // address of structure for window coordinates
);
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
那是取的鼠标的相对坐标吧
怎么取按钮的相对坐标呢
我需要点击按钮后在按钮的下方弹出菜单
yuqianyi1974 2008-11-07
  • 打赏
  • 举报
回复
BOOL GetCursorPos(

LPPOINT lpPoint // address of structure for cursor position
);
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
怎么取相对坐标
panrongzeng 2008-11-07
  • 打赏
  • 举报
回复
TPopupMenu类,不会用上网找。
smilyvm 2008-11-07
  • 打赏
  • 举报
回复
PopupMenu1.Popup(ToolButton3.Left,ToolButton3.Top+ToolButton3.Height);
这么写后弹出的不在按钮的下方
可能是取的绝对位置

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧