dragging files to client area

This is a discussion on dragging files to client area within the Windows Programming forums, part of the Platform Specific Boards category; hey all, I have seen a couple of apps now where you can drag files into the client area to ...

  1. #1
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355

    dragging files to client area

    hey all,

    I have seen a couple of apps now where you can drag files into the client area to do stuff with them.

    A good example is the latest version of messenger where you can drag a file into the chat window to send it, and I suppose windows explorer (my computer etc.) is also an example of this.

    I need this functionality for a program I am developing, and was wondering if anyone could point me in the right direction as to what message I would have to handle.

    Thanks.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    The Win32 Programmer's Reference has a section on shell extensions, including drag-drop operations. Look at that first I would say. If you don't have it, get it. Google should find it.

    To tell the truth, I had never even considered drag drop operations until reading this post, but now I will give it a shot. Hopefully we can help each other.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    Cool thanks I do have the reference it's an invaluable tool, I'll have a look.

    I'm actually developing a File Manager program and the client area will allow you to drag files onto it to be securely (or insecurely) deleted (i.e. I am going to fill the file with 0s before deletion so it's irrecoverable), as well as doing things like being able to compare directories with a file made by someone else and the program will spit out who's missing what files.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  4. #4
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    look up WM_DROPFILES

    Easy as pie.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Haha yep, easy as pie.

    That gives you the filename, but will it have the path and drive?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    Just tested it, passed whole path.

    edit:
    This is how I did it:
    Code:
    	case WM_DROPFILES:
    		{
    		wchar_t FileNameBuf[MAX_PATH];
    		HDROP hDrop = (HDROP) wParam;
    
    		DragQueryFile(hDrop, 0, FileNameBuf, MAX_PATH);
    		MessageBox(hwnd, FileNameBuf, L"File Dropped...", MB_OK);
    
    		DragFinish(hDrop);
    		}
    		break;
    I was concerned about the wParam cast to HDROP but compiler didn't complain and everything seems to work, is it ok?
    Last edited by HybridM; 10-31-2003 at 12:18 AM.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing two or more rectangles on client area.. HELP!
    By csonx_p in forum Windows Programming
    Replies: 2
    Last Post: 05-12-2008, 02:43 AM
  2. Nonclient & client area transparency
    By TheDan in forum Windows Programming
    Replies: 0
    Last Post: 03-27-2007, 03:19 PM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21