forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Send a drop event notice to another program?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Mar 08, 2009 10:58 pm    Post subject: Send a drop event notice to another program? Reply with quote

Anyone know if it's possible and or how to send a drag and drop event notice to another window, like Notepad etc. Where you say drag a file from explorer and drop it on Notepad, and Notepad gets that info and then opens the file.

Thanks in advance,
~Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Mar 09, 2009 8:32 pm    Post subject: Reply with quote

Garrett,
Here ya go.. The code below has a User Define Command that will send the WM_DROPFILES API message to any window. You can also specify the client cordinates of where to drop the files however Notepad does not care about that but other programs may.

Code:

#---------------------------------------------------------------------------------------#
#                                                                                       #
# Description: Sends a WM_DROPFILES message to a window                                 #
#                                                                                       #
# Author: Johnny Kinsey                                                                 #
#                                                                                       #
# Copyright: Copyright © 2009 DragonSphere Software All Rights Reserved.                #
#                                                                                       #
#---------------------------------------------------------------------------------------#

# user defined functions
#DEFINE COMMAND,SENDFILES

# VDS list with files and paths to the files
%%DropFiles_lst = @New(LIST)
# add our files like you would with any list.
List Add,%%DropFiles_lst,@path(%0)vdsDropFiles.dsc

# Send the files to a window
SendFiles #Notepad,25@fsep()25,%%DropFiles_lst
If @OK()
  Info NotePad should be displaying the file you sent.
Else
  Warn Files were not sent.
End

Exit

:SENDFILES
  # %1 = destination Window ID
  # %2 = the X@fsep()Y cordnate of the location in the destination window you want the files to be droped
  # %3 = A VDS list of files and their paths
 
   %R =
  # load the DLL's that we are going to use
  LoadLib kernel32.dll 
  LoadLib user32.dll
  # define the constants for this function
  %%WM_DROPFILES = 563
  %%GMEM_MOVEABLE = $2
  %%GMEM_ZEROINIT = $40
  %%GHND = @sum(%%GMEM_MOVEABLE,%%GMEM_ZEROINIT)
 
   # Translate %1 into a window handle
   If @Equal(@Pos(@chr(37),%1),1)
     %%hWnd = @strdel(%1,1,1)
   Else
     %%hWnd = @strdel(@winexists(%1),1,1)
   End
   
   # Get the X|Y cords where you want the file to drop.
   PARSE "%x;%y",%2
   
  # turn the VDS file list into a dropfiles list
  %%cnt = 0
  %%count = @count(%3)
  %A =
  %L = 0
  If @Greater(%%count,0)
    Repeat
      %I = @Item(%3,%%cnt)
      If %I
        If %A
          %A = %A@chr(0)%I
          %L = @SUM(%L,@SUM(@LEN(%I),1))
        Else
          %A = %I
          %L = @SUM(@LEN(%I),1)
        End     
      End
      %%cnt = @succ(%%cnt)
    Until @Equal(%%cnt,%%count)
  End
   
   # Build the dropfiles structure and append the list of files above to it.
  %A = @BINARY(DWORD,20)@BINARY(DWORD,%x)@BINARY(DWORD,%y)@BINARY(DWORD,0)@BINARY(DWORD,0)%A@chr(0)
   
   # Allocate Global memory to hold the dropfiles structure above
  %%hDrop = @lib(kernel32,GlobalAlloc,INT:,INT:%%GHND,INT:@SUM(20,@succ(%L)))
  If @unequal(%%hDrop,0)
     # lock the memory so we can copy the data to it.
     %m = @lib(kernel32,GlobalLock,INT:,INT:%%hDrop)
      If @unequal(%m,0)
        # move the data in %A to the global memory location %m
        %z = @lib(kernel32,RtlMoveMemory,INT:,INT:%m,INT:@addr("%A"),INT:@SUM(20,@succ(%L)))
         # Unlock the global memory
         %z = @lib(kernel32,GlobalUnlock,BOOL:,INT:%%hDrop)
         # Post the WM_DROPFILES message to the window
         %R = @lib(user32,PostMessageA,BOOL:,INT:%%hWnd,INT:%%WM_DROPFILES,INT:%%hDrop,INT:0)
      End
    %%hDrop = @lib(kernel32,GlobalFree,INT:,INT:%%hDrop)
  End
  FreeLib kernel32
  FreeLib user32
  If @Not(%R)
     error -1
   End 
Exit %R

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Tue Mar 10, 2009 12:49 am    Post subject: Reply with quote

Schaaaaweeeeeeeeeet! Thanks DragonSpere! You da man! Smile
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Tue Mar 10, 2009 1:20 am    Post subject: Reply with quote

Your very welcome. Just note that not many programs use WM_DROPFILES anymore. Most programs use the OLE way for drag and drop today which I am frantically working on for another VDS project.
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group