thready
asked on
Get filename of dragged icon on Windows
Hi Experts,
Is there a way to subscribe to file drag events in Windows, in order to obtain the full path to the file that was dragged? i.e., before the file is dropped?
Thanks,
Mike
Is there a way to subscribe to file drag events in Windows, in order to obtain the full path to the file that was dragged? i.e., before the file is dropped?
Thanks,
Mike
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
is that C++ or C# that you need? Winforms or WPF?
ASKER
C# :-)
Thanks jkr! ! !
Thanks jkr! ! !
ASKER
I'll try this tomorrow morning!
Winforms or WPF?
ASKER
Wpf...
No need to use Shell. Here is a WPF sample:
public MainWindow()
{
InitializeComponent();
TextBox1.AllowDrop = true;
TextBox1.PreviewDragEnter += TextBox1_DragEnter;
}
private void TextBox1_DragEnter(object sender, DragEventArgs e)
{
Label1.Content = string.Empty;
if (e.Data.GetDataPresent(DataFormats.FileDrop, true))
{
string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop, true);
foreach (string filename in filenames)
{
Label1.Content += filename + " ";
}
}
e.Effects = DragDropEffects.All;
e.Handled = true;
}
ASKER
I don't want to detect drops, I want to detect the start of drag only.
My code lets you preview before you drop. The drop is not handled. What are your trying to do exactly?
ASKER
Ok, I read it too quick. Thanks a lot for your help. I'd love to be able to tell you but I should not because of work... Sorry. I'll try tomorrow morning. Thanks again!
ASKER
I don't think your method will work Eric, I don't have a textbox to preview.. I really only want Windows messages with no ui involved from my app...
ASKER
jkr, I don't think I can get the shell method to work either. My program is minimized and the drop target is not known and the drop target is irrelevant (it's another unknown application)....
What are your trying to do exactly?
ASKER
lol... You're persistent Eric! I suppose I can tell you I'm trying to get the filename of a file that is dropped into a browser.
I am trying to understand your process (and I am sure others are trying to). By better understanding the process, we might be able to propose better solution!
So you have an application and you want to detect what is being drag-and-drop to a browser but this browser is not in your application. Right?
So you have an application and you want to detect what is being drag-and-drop to a browser but this browser is not in your application. Right?
ASKER
Correct
Then I am clueless!
ASKER
Thanks for trying :)
Unfortunately I don't think it's possible.
Unfortunately I don't think it's possible.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
That's not ok for commercial software. We don't know the source window, so we'd have to invade the system and do a little too much spying. If we owned the source then that would be ok...
ASKER
Then again, if we owned the source, we wouldn't even have to do that...
I've requested that this question be deleted for the following reason:
The question has either no comments or not enough useful information to be called an "answer".
The question has either no comments or not enough useful information to be called an "answer".
Evering is there that is needed and since LeeTutor only knows Delete Requests, objecting is mandantory.
ASKER
Thanks for your answers!