Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to trick OLE DragDrop Event

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
0
0
US
My users have different ways to accomplish things. Some like to "drag and drop" while others like to "explore". I have a form with a control where they can drop a file to be operated on. I've also put a command button on the form that allows them to navigate to the file using the GETFILE() function.

I'd like to find a way to programatically 'drop' the file from the GETFILE function onto the control that is set to accept Drag and Drop.

I tried the following line in the click event of my command button, but it reported that "ODATAOBJECT is not an object."

thisform.container2.OLEDragDrop(gcInputFile, 7, 1, 0, 105, 44)

I got the parameters (7, 1, 0, 105, 44) from the debugger with a real file that was dropped and figured if I used them along with the name of the file that it would work. So how do I make the value of gcInputFile into an object that OLEDragDrop will recognize?

Steve
 
Steve

You will find the Windows common dialog supports OLE drag and drop, and should resolve your problem.

faq184-3106 shows you how you can enable multiple file selection from the Windows common dialog as an alternative to drag and drop.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris,

I'll look into it and let you know if it solves my problem.

Steve
 
Chris,

The Common Dialog control does allow me to drag/drop a file onto my forms control, but once the file has been dropped the CD window is still open and I haven't been able to find a way to programatically close it.

Any suggestions?

Steve
 
Steve

Not tried and not sure if this would work if the CD window is open, but it you .AddObject the class to a form, then you should should be able to .RemoveObject() the class.
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris,

By incorporating your idea with something I found in the FoxPro Advisor I was able to get the window to close. Here's what I came up with:

DECLARE INTEGER FindWindow IN Win32api STRING, STRING
lcWindowTitle = ALLTRIM(thisform.cusCommonDialog.cTitleBarText)
IF lcWindowTitle = "Select DBF File To Process"
** If the file was 'dropped' by the Windows Common Dialog box, close that dialog.
lnHWnd = FindWindow(NULL, lcWindowTitle)
IF lnHWnd <> 0 && found another copy
DECLARE long PostMessage IN WIN32API LONG hWnd, LONG wMsg, LONG wParam, LONG lParam
#DEFINE WM_CLOSE 0x10
PostMessage( lnHWnd, WM_CLOSE, 0, 0)
ENDIF
ENDIF
 
Steve

Looks good - I was also going to suggest a variant on George Taskers' IsRunning() had you not come up with that solution, which would have achieved much the same result.

Why don't you write it all up as a FAQ?
FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top