Article View: borland.public.cppbuilder.nativeapi
Article #11338Re: Get message form app-window.
From: Asger J�rgensen
Date: Fri, 13 Feb 2004 18:32
Date: Fri, 13 Feb 2004 18:32
64 lines
2418 bytes
2418 bytes
Hi Cactus
In article <402d0277$2@newsgroups.borland.com>, Cactus says :
> > Do You mean "drag a file" ?
> > and then dropping it on tha app window ?
> >
> Yes, Thank.
>
> it should like a copy and plaster operate.
Okey then:
First You need a line in the form constructor
DragAcceptFiles(Handle, true);
and one in the form FormCloseQuery event
DragAcceptFiles(Handle, false);
then You need to respond to the WMDropFiles message
in the unit1.h file You need this:
MESSAGE void __fastcall WMDropFiles(Messages::TWMDropFiles &Message);
BEGIN_MESSAGE_MAP // TMessage
VCL_MESSAGE_HANDLER(WM_DROPFILES, TWMDropFiles, WMDropFiles)
END_MESSAGE_MAP(TForm)//TForm TCustomLabel
and something like this in the unit1.cpp file
MESSAGE void __fastcall TForm1::WMDropFiles(Messages::TWMDropFiles
&Message)
{
char Buf[MAX_PATH];
unsigned NumberOfFiles;
HANDLE Hnd_Drop = (void*)Message.Drop;
NumberOfFiles = DragQueryFile(Hnd_Drop, 0xFFFFFFFF, Buf, 0);
if(NumberOfFiles > 0)
{
for(unsigned i = 0; i < NumberOfFiles; i++)
{
memset(Buf,0,MAX_PATH);
DragQueryFile(Hnd_Drop, i, Buf, MAX_PATH);
ListBox->Items->Add(Buf);
}// End for(unsigned i = 0
}
DragFinish(Hnd_Drop);
Message.Result = 0;
}
//---------------------------------------------------------------------------
I have not tested this code so there might be errors
Best regards
Asger
Technical Details
Message-ID:
<MPG.1a9736c98a64bf598971e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<402ca730$1@newsgroups.borland.com> <MPG.1a96cdd05eca648198971c@newsgroups.borland.com> <402d0277$2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,873ed39da4f4a729 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-13 10:40:38 PST From: Asger J�rgensen <Asger.Pnotthis@AJ-World.dk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Get message form app-window. Date: Fri, 13 Feb 2004 19:32:58 +0100 Message-ID: <MPG.1a9736c98a64bf598971e@newsgroups.borland.com> References: <402ca730$1@newsgroups.borland.com> <MPG.1a96cdd05eca648198971c@newsgroups.borland.com> <402d0277$2@newsgroups.borland.com> Organization: AJ-World X-Newsreader: MicroPlanet Gravity v2.50 NNTP-Posting-Host: 80.164.88.221 X-Trace: newsgroups.borland.com 1076697166 80.164.88.221 (13 Feb 2004 10:32:46 -0800) Lines: 68 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail