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!

Droping a file on a TRichEdit or a form in general 1

Status
Not open for further replies.

varkhov

Instructor
Jul 25, 2001
4
0
0
GR
Hello ppl.
I would like to ask all the gentle souls in the audience if ever you encountered a problem of "how to drag & drop a file on a Builder form, TControl, whatever and then retrieve info about this file".
I searched a bit and found that I could add a VCL_MESSAGE_MAP that actually works with a similar way to the MSVC Message map. But the problem is that I do not know how to work around the message handler so that it traps the WM_DROPFILES message so that I can accept files from another app (namely Explorer). I would be grateful if anyone answered me.
Thank you in advance.
 
put this in the form's class

public:
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_DROPFILES, TMessage, DropFile);
END_MESSAGE_MAP(TForm);


this in the form's constructor:
DragAcceptFiles(Handle, True);

replace Handle with that of a control if you like

and a function similar to this:

MESSAGE void TForm1::DropFile(TMessage &Message){

HDROP hDrop;
char fName[MAX_PATH];
int nNumFiles, nCounter;

hDrop = (HDROP) Message.WParam;
nNumFiles = DragQueryFile(hDrop, -1, NULL,0);

for(int i=0; i < nNumFiles; i++) {
DragQueryFile(hDrop, i,fName,MAX_PATH);
ShowMessage((String) + fName); //shows filename & path
}
DragFinish(hDrop);

}
 
Thanx, I found out eventually, by checking out Borland's site! But thanx anyway! I have another question and I will post it soon!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top