drag and drop on NotifyIcon in tray in C#
Asked Answered
H

3

6

I am trying to create a C# application that runs in tray where I can drop files on it's icon. Is there any way to get the path of the file dropped on the System Tray icon? System.Windows.Forms.NotifyIcon does not have any events related to drag and drop.

Hiett answered 30/4, 2010 at 7:31 Comment(0)
E
9

it's not possible to do this, the easy way. You can show a dummy Form, if the cursor is in a special area near the notifyicon. The dummy Form can get the filepath of the droped file.

Escargot answered 30/4, 2010 at 7:51 Comment(3)
The workaround doesn't work either, you can't find out where the icon is located. – Iong
@HansPassant -- the Shell_NotifyIconGetRect Win32 API can be used to retrieve the location of the icon. – Hardden
Well, as long as you register the guid. – Iong
S
1

It has az example, but it's not fully and written in C++ :(

DragnDropOnTrayIcon

Spandau answered 20/7, 2010 at 19:25 Comment(0)
G
0

It actually is possible to do with a slightly hacky method. Fluffy App does this for its file uploader. It uses Spifftastic which uses a pretty neat little method to identify the location of the tray icon. Then a transparent window is placed over the location of the icon and used as the actual drop target, but to the end user it all appears to be dropping the file on the icon.

Grozny answered 27/10, 2010 at 2:9 Comment(1)
The Spifftastic.NotifyIconLoc GitHub repository is gone. πŸ™ – Silvia

© 2022 - 2024 β€” McMap. All rights reserved.