Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 451593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:59:03+00:00 2026-05-12T21:59:03+00:00

< I have reviewed the related questions shown by SO before posting this >

  • 0

< I have reviewed the “related questions” shown by SO before posting this >

Scenario :

  1. Drag and drop initiated from a control within a WinForm.

    note : all drag and drop code validated, carefully tested. I can use the code right now
    to create/write a file to the Desktop when the mouse is released.

  2. Drag goes outside the Form, mouse goes up over the Desktop or some “item” on the Desktop.

[edit in response to comment by Groo]

In this case the drop may go onto the desktop (where it will become a file : that case is already handled); or, the drop may go into a control of the same type (as the control from which the drag was initiated) in another application’s running instance (that case is taken care of). The case that I am asking about is where the drop occurs on a desktop Folder : Groo’s comments have made want to test trying to modify the DataObject type “on the fly” … during the drag … which I’ve never tried before : I have no idea if it’s possible.

[end edit ]

I can use the api calls in this code sample [1*] to get an IntPtr ID for the mouse going up over the Desktop : the same IntPtr is returned for any Desktop item, like a Folder, a Shortcut, the Recycle Bin, etc.

What I want is : to be able to detect when the mouse is released over a Folder on the Desktop : of course what I want to do then is to get the path of the folder the mouse went up over : so I can create the file within that folder.

thanks, Bill

[1*]

“FindWindow By Jörg Bausch”

http://www.codeproject.com/KB/dialog/FindWindow.aspx?msg=3262771

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:59:03+00:00Added an answer on May 12, 2026 at 9:59 pm

    If your file exists before you start to drag (or you are able to create it before), you can simply specify the source file path in the DataObject instance passed to DoDragDrop method.

    Something like this (you should already have the appropriate handlers):

    public partial class Form1: Form
    {
        public Form1()
        {
           InitializeComponent();
           this.MouseDown += Form1_MouseDown;
        }
    
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            string[] files = new string[] { @"C:\SomeTestFile.txt" };
            this.DoDragDrop(new DataObject(DataFormats.FileDrop, files),
              DragDropEffects.Copy);
        }
    } 
    

    If you are interested in adding some fancy translucent effects while you are dragging, try this link. If your file doesn’t exist and you really need to create it after it has been dropped to explorer, check this link.

    You can also override DataObject to handle the GetData method which is called when the object is dropped:

    public class MyDataObject : DataObject
    {
        public MyDataObject(string format, object data)
           : base(format, data) { }
    
        public override object GetData(string format)
        {
            MessageBox.Show("Format: "+format);
            return base.GetData(format);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have reviewed numerous reports of this error but the solutions I have seen
Before you point me to them, yes, I have reviewed the half dozen posts
I have reviewed a few Struts 1 vs 2 questions on SO but none
I've seen a number of 'code metrics' related questions on SO lately, and have
I have reviewed quite a few posts on this site concerning this issue with
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
Thank you for submitting APPNAME_HERE. We have reviewed your application and have determined that
I don't have Apple ID (reviewed), as I don't have credit card. So, for
I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.