property AutoPopup: Boolean; 试试它!
Set AutoPopup to True to cause the pop-up menu to appear automatically when the user clicks the right mouse button on a control that has the pop-up menu specified as its PopupMenu property. The application key present on keyboards specifically designed for Windows 95 will also show this menu when pressed.Set AutoPopup to False if the appearance of the pop-up menu should be controlled programmatically. To display a pop-up menu when AutoPopup is False, use the Popup method.
Set AutoPopup to True to cause the pop-up menu to appear automatically when the user clicks the right mouse button on a control that has the pop-up menu specified as its PopupMenu property. The application key present on keyboards specifically designed for Windows 95 will also show this menu when pressed.Set AutoPopup to False if the appearance of the pop-up menu should be controlled programmatically. To display a pop-up menu when AutoPopup is False, use the Popup method.
我用API:GetMenuInfo()和GetMenu***()等,不知为何总是不行,GetLastError得知是参数错误,可是我的参数根本没错啊 :(
Thank you!
begin
inherited WndProc(Msge);
with Msge do
case Msg of
WM_CONTEXTMENU://PopupMenu弹出时
{在这里添加你的执行代码}
end;
end;
不行的!
没辙了,我用GetWindowInfo,发现它的WINDOWINFO始终不变,连dwWindowStatus也从未改变!!
对了,如何获得当前系统中所有注册了的menu类?即正在运行中的窗体的所有菜单对象。
to SuperQM:
你用GetWindowInfo传给他的是谁的句柄?
我给的是PopupMenu->WindowHandle,
也试过从Form中取Menu然后再传都不行,你有何高见?
API有上个列出当前进程所有窗口的句柄,
我查一下
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam // application-defined value
);
1.PopupMenu->Handle //菜单句柄
2.PopupMenu->WindowHandle //处理菜单消息的窗口句柄
3.PopupMenu->Items->Handle //???可能是子菜单句柄这三个句柄我都试了,都不行。你用Winsight32可以看到PopupMenu的窗口句柄和类名称,类名称是{#32768:PopupMenu}和Desktop的类名称有些相似,应该是由系统建立的,而且同一时间内只可能有一个这样的窗口,其实同一时间内不论是菜单还是弹出式菜单都只可能有一个。
现在的问题就是找到这个窗口的句柄,由于是系统建立的,而且不返回句柄,所以TPopupMenu累里也没有保存这个句柄,看来是只能用FindWindow或EnumWindows来找了,但是如果传入#32768:PopupMenu的类名的话,是找不到的,不过Winsight32能看到就肯定能找到。另外,这个句柄是变化的,看来是动态创建的。你可以是一下用EnumWindows,应该能找到。
你说:"同一时间内不论是菜单还是弹出式菜单都只可能有一个",这可未必,我在我的机器上试了,我同时打开了“金山词霸”、我的程序、“输入法”等等的弹出菜单,并且每一个都是有效的,操作完一个还可以操作另一个……
要是不信的话,告诉我你的Email,我把界面截给你看看!
没有两个POPUP那回事呀,只能出来一个