JVCL Help:TJvTrayIcon.OnContextPopup

From Project JEDI Wiki
Jump to navigationJump to search
JEDI Visual Component Library Help

Search in JVCL Help

 
Search in all projects
 

Summary

Occurs when the user right-clicks the tray icon or otherwise invokes the popup menu (such as using the keyboard).


Pascal

 propertyOnContextPopup: TContextPopupEvent;


Description

The OnContextPopup handler is called when the user uses the mouse or keyboard to request a popup menu. The OnContextPopup event is generated by a WM_CONTEXTMENU message, which is itself generated by the user clicking the right mouse button or by pressing Shift+F10 key.
The OnContextPopup event can be used to override the automatic context menu that appears when the control has an associated popup menu. In this last case, if the event handler displays its own menu, it should set the Handled parameter to true to suppress the default context menu.
The handler’s MousePos parameter indicates the position of the mouse, in client coordinates. Windows moves the mouse pointer to the tray icon when the event was not generated by a mouse click, thus the MousePos parameter is always valid.
To show a custom popup menu, use the following code: procedure TForm1.JvTrayIcon1ContextPopup(Sender: TObject; MousePos: TPoint;

 var Handled: Boolean);
begin
Handled := True;


 SetForegroundWindow(JvTrayIcon1.Handle);
YourCustomPopupMenu1.Popup(MousePos.X, MousePos.Y);
PostMessage(JvTrayIcon1.Handle, WM_NULL, 0, 0);
end;


See Also

TJvTrayIcon.PopupMenu


About

Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page