How to find the location of the icon in the system tray

前端 未结 3 958
感情败类
感情败类 2020-12-20 23:28

I have a NotifyIcon control that appears in the system tray. How can I find the location (x, y) of the icon on the screen?

Thanks

3条回答
  •  猫巷女王i
    2020-12-21 00:07

    Actually you can do this, here is code that shows you how and much more.

    In any Mouse Event from NotifyIcon, simply look at Control.MousePosition, this contains the (x,y) of the mouse. The same can be done to position a ContextMenu on a form/control exactly where the form/control was clicked using these (x,y) values.

    A good example of both of these is here:

    More Here: http://code.msdn.microsoft.com/TheNotifyIconExample

提交回复
热议问题