Results 1 to 4 of 4

Thread: Dropfiles emulation

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    10

    Exclamation Dropfiles emulation

    Hi all.

    I'm implementing some IPC mechanisms in VB using the API functions.

    I'm using SendMessage / PostMessage.

    I've been able to perform a data post from my app using WM_COPYDATA (very useful to control Winamp playlist, for example).

    Now, I'm trying to emulate a file drag&drop and I'll use WM_DROPFILES. I can't find information on how to create the struct needed to build the message in VB.

    Any example available?

    Thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hopefully this will help...

    http://216.26.168.92/tips/tip66.html

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    10

    Not really...

    Thank you, Hack, but I was refering to another issue...

    In the case that you suggest, the drag&drop operation is manual (it's performed by the user), and the way to handle the dropped file info is explained in the MSDN lib.

    What I want to do is emulate the drag&drop operation from my application, i.e. creating the struct containing the filelist to be passed and sending it to the destination application using a SendMessage(,,WM_DROPFILES...

    This can be very useful to control some applications from my app. For example, I will be able to pass an entire playlist to the Winamp Playlist window in a single message.

    Thanks again.

    Alex

    ___________

  4. #4
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    Here I go...

    Alright, I have never before worked with WM_DROPFILES, but Hack's link was actually very helpful for using as a stepping stone. I started working the problem backward: if you know how to handle the situation, then if you know what caused the situation, you can emulate it. Basically I monitored Notepad with spy++ to watch for the WM_DROPFILES message. The wParam contains the hDrop value when sending the WM_DROPFILES message. This is incredibly important because I believe it is a pointer to the structure that contains information about the drag operation. Although I am not entirely sure, I am almost positive that hDrop should be a pointer to a DRAGINFO structure. This structure, when configured with the proper values should appropriately simulate the drag and drop operation if you pass the pointer to it in wParam. That is my thesis; I have not been able to test it, nor will I have time in the near future to do so. Here is the structure from the API viewer:
    VB Code:
    1. Public Type DRAGINFO
    2.         uSize As Long                 '  init with sizeof(DRAGINFO)
    3.         pt As POINTAPI
    4.         fNC As Long
    5.         lpFileList As String
    6.         grfKeyState As Long
    7. End Type

    I do not think this structure is enough to simulate it though because I found this c++ definition of the structure:

    Code:
    typedef struct _DRAGINFO
    	  {
    	  ULONG	cbDraginfo;   // Structure size
    	  USHORT	cbDragitem;   // DRAGITEM structures sizes
    	  USHORT	usOperation;  // Modified drag operations
    	  HWND	hwndSource;   // Window handle
    	  SHORT	xDrop;	  // X-coordinate
    	  SHORT	yDrop;	  // Y-coordinate
    	  USHORT	cditem;	  // Count of DRAGITEM structures
    	  USHORT	usReserved;   // Reserved
    	  } DRAGINFO;
    This may be the defintion that yields the best success, but I am still undecided about which method I would try first if I had time. I wish you luck, and if you find out how to do it, please post it. (My recommendation for this situation and in general is to not immediately discount any information dealing with your topic. In this situation, I would recommend working it backward, especially when you have to assign which file names you are moving. Because of the article posted by Hack, it is very likely that to store the filenames in the lpFileList you store exactly 128 characters for each filename. That is just a guess, but it may help you. Good luck again)

    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width