Delphi:PopupMenu 在我的组件中不起作用
英文翻译(已经有一段时间了,所以可能不完全准确;使用谷歌翻译来翻译我遇到问题的部分):
我正在 Delphi 中开发一个可视化组件(它不是标准的 Delphi 组件),它拥有一个名为 < 的属性代码>弹出菜单。我将组件中的属性 PopupMenu
与 PopupMenu 关联起来,但是当我单击[鼠标]右键时,我什么也没看到。
我还尝试用此代码强制它显示:
x:= Mouse.CursorPos.X;
y:= Mouse.CursorPos.Y;
// //showmessage(inttostr(x)) PopupMenu1.Popup(x,y);
我有两个问题:
你如何知道鼠标右键单击处于活动状态?你们中有人遇到过此类问题吗?谢谢您的回答。
谢谢
编辑
这是我用来执行PopupMenu1:
过程的过程
TForm6.GeckoBrowser1DOMMouseDown(Sender: TObject; Key: Word);
var x,y:integer;
begin
if key=VK_RBUTTON then begin
x:= Mouse.CursorPos.X;
y:= Mouse.CursorPos.Y;
//showmessage(inttostr(x)) PopupMenu1.Popup(x,y);
end;
end;
English Translation (been a while, so may not be entirely accurate; used google translate for the parts I had trouble with):
I'm working on a Visual Component in Delphi (it's not a standard Delphi component) which possesses a property called PopupMenu
. I associated the property PopupMenu
in the component with the PopupMenu, but when I click the right button [of the mouse], I see nothing.
I also tried to force it to display with this code:
x:= Mouse.CursorPos.X;
y:= Mouse.CursorPos.Y;
// //showmessage(inttostr(x)) PopupMenu1.Popup(x,y);
I have two questions:
How do you know that the right click of the mouse is active? Have any of you encountered this type of problem? Thank you for your answers.
Thanks
EDIT
Here is the procedure that I'm using to execute the PopupMenu1:
procedure
TForm6.GeckoBrowser1DOMMouseDown(Sender: TObject; Key: Word);
var x,y:integer;
begin
if key=VK_RBUTTON then begin
x:= Mouse.CursorPos.X;
y:= Mouse.CursorPos.Y;
//showmessage(inttostr(x)) PopupMenu1.Popup(x,y);
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这永远不会起作用。您不能将表单中的代码与组件代码混合。
我建议这样:
或者如果您不希望 OnMouseUp 在出现弹出菜单时触发,请执行以下操作:
看到区别了吗? Popupmenu 现在是组件的一部分(无论如何都是良好链接的部分),而不是恰好位于同一表单上的东西。
This will never work. You cannot mix code in a form with the component code.
I would suggest something like this:
or if you do not want the OnMouseUp to fire when a popup menu appears do:
See the difference? Popupmenu is now a part (well linked part anyway) of your component and not something that just happens to be on the same form.