Thread View: alt.comp.borland-delphi
3 messages
3 total messages
Started by Maarten Veerman
Sat, 11 Jan 2003 11:09
DragDrop Files from explorer to ListView
Author: Maarten Veerman
Date: Sat, 11 Jan 2003 11:09
Date: Sat, 11 Jan 2003 11:09
67 lines
3080 bytes
3080 bytes
Hi,
I have a problem with dropping files in a ListView. I use the code that
everybody can find in the Delphipages TIPS section:
http://www.delphipages.com/tips/thread.cfm?ID=95&SR=drag
(See below for code)
Anyway, I try setting the DragAcceptFiles like this:
DragAcceptFiles(ListView1.Handle,True);
When I drag files over the listview it seems like it will accept the files,
since the cursor changes. But when I drop the files, the TForm1.WMDROPFILES
procedure is not activated, so nothing is dropped.
Strangely enough, I have no problems when I use a listbox:
DragAcceptFiles(ListBox1.Handle,True); works just fine.
But I need to use a ListView!
Any suggestions?
Maarten Veerman
CODE FROM TIP:
firs add ShellApi to th Uses clause
and this to the protected procedures
protected
procedure WMDROPFILES (var Msg: TMessage); message WM_DROPFILES;
and tis after the implementation part like this:
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.WMDROPFILES (var Msg: TMessage);
var
i,
amount,
size: integer;
Filename: PChar;
S: string;
begin
inherited;
Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, Filename, 255);
for i := 0 to (Amount - 1) do
begin
size := DragQueryFile(Msg.WParam, i , nil, 0) + 1;
Filename:= StrAlloc(size);
DragQueryFile(Msg.WParam,i , Filename, size);
s := Extractfileext(Filename);
if s <> '.bmp' then
continue
else
listbox1.items.add(StrPas(Filename));
StrDispose(Filename);
end;
DragFinish(Msg.WParam);
end;
Then Enable the function
by declaring
DragAcceptFiles(Form1.Handle, true);
Re: DragDrop Files from explorer to ListView
Author: Jianfeng Zou
Date: Sat, 11 Jan 2003 11:58
Date: Sat, 11 Jan 2003 11:58
95 lines
3613 bytes
3613 bytes
I have a program whose aim is the same to you.
I use following code to solve this.we can catch WM_DROPFILES message in
application.Onmessage function.
You must add this code in form.create
Application.OnMessage := AppMessage;
And
procedure TForm.AppMessage(var Msg: TMsg; var Handled: Boolean);
var
begin
if (Msg.message = WM_DROPFILES) and (msg.hwnd = ListView.Handle) then
begin
...
end
end;
"Maarten Veerman" <M.T.Veerman@[nospam]student.tudelft.nl> wrote in message
news:avou1u$5h1$1@news.tudelft.nl...
> Hi,
>
> I have a problem with dropping files in a ListView. I use the code that
> everybody can find in the Delphipages TIPS section:
> http://www.delphipages.com/tips/thread.cfm?ID=95&SR=drag
> (See below for code)
>
> Anyway, I try setting the DragAcceptFiles like this:
> DragAcceptFiles(ListView1.Handle,True);
>
> When I drag files over the listview it seems like it will accept the
files,
> since the cursor changes. But when I drop the files, the
TForm1.WMDROPFILES
> procedure is not activated, so nothing is dropped.
>
> Strangely enough, I have no problems when I use a listbox:
> DragAcceptFiles(ListBox1.Handle,True); works just fine.
> But I need to use a ListView!
>
> Any suggestions?
>
> Maarten Veerman
>
> CODE FROM TIP:
> firs add ShellApi to th Uses clause
>
> and this to the protected procedures
>
> protected
> procedure WMDROPFILES (var Msg: TMessage); message WM_DROPFILES;
>
> and tis after the implementation part like this:
>
> implementation
>
> uses Unit2;
>
> {$R *.DFM}
>
> procedure TForm1.WMDROPFILES (var Msg: TMessage);
> var
> i,
> amount,
> size: integer;
> Filename: PChar;
> S: string;
> begin
> inherited;
> Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, Filename, 255);
> for i := 0 to (Amount - 1) do
> begin
> size := DragQueryFile(Msg.WParam, i , nil, 0) + 1;
> Filename:= StrAlloc(size);
> DragQueryFile(Msg.WParam,i , Filename, size);
> s := Extractfileext(Filename);
> if s <> '.bmp' then
> continue
> else
> listbox1.items.add(StrPas(Filename));
> StrDispose(Filename);
> end;
> DragFinish(Msg.WParam);
> end;
>
> Then Enable the function
> by declaring
>
> DragAcceptFiles(Form1.Handle, true);
>
>
Re: DragDrop Files from explorer to ListView
Author: Maarten Veerman
Date: Sat, 11 Jan 2003 12:24
Date: Sat, 11 Jan 2003 12:24
102 lines
4104 bytes
4104 bytes
Thanks a lot!
"Jianfeng Zou" <zjf1998@21cn.com> wrote in message
news:avp0t3$f5a$1@mail.cn99.com...
> I have a program whose aim is the same to you.
> I use following code to solve this.we can catch WM_DROPFILES message in
> application.Onmessage function.
> You must add this code in form.create
>
>
> Application.OnMessage := AppMessage;
>
> And
>
> procedure TForm.AppMessage(var Msg: TMsg; var Handled: Boolean);
> var
> begin
> if (Msg.message = WM_DROPFILES) and (msg.hwnd = ListView.Handle) then
> begin
> ...
> end
> end;
>
>
>
>
> "Maarten Veerman" <M.T.Veerman@[nospam]student.tudelft.nl> wrote in
message
> news:avou1u$5h1$1@news.tudelft.nl...
> > Hi,
> >
> > I have a problem with dropping files in a ListView. I use the code that
> > everybody can find in the Delphipages TIPS section:
> > http://www.delphipages.com/tips/thread.cfm?ID=95&SR=drag
> > (See below for code)
> >
> > Anyway, I try setting the DragAcceptFiles like this:
> > DragAcceptFiles(ListView1.Handle,True);
> >
> > When I drag files over the listview it seems like it will accept the
> files,
> > since the cursor changes. But when I drop the files, the
> TForm1.WMDROPFILES
> > procedure is not activated, so nothing is dropped.
> >
> > Strangely enough, I have no problems when I use a listbox:
> > DragAcceptFiles(ListBox1.Handle,True); works just fine.
> > But I need to use a ListView!
> >
> > Any suggestions?
> >
> > Maarten Veerman
> >
> > CODE FROM TIP:
> > firs add ShellApi to th Uses clause
> >
> > and this to the protected procedures
> >
> > protected
> > procedure WMDROPFILES (var Msg: TMessage); message WM_DROPFILES;
> >
> > and tis after the implementation part like this:
> >
> > implementation
> >
> > uses Unit2;
> >
> > {$R *.DFM}
> >
> > procedure TForm1.WMDROPFILES (var Msg: TMessage);
> > var
> > i,
> > amount,
> > size: integer;
> > Filename: PChar;
> > S: string;
> > begin
> > inherited;
> > Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, Filename, 255);
> > for i := 0 to (Amount - 1) do
> > begin
> > size := DragQueryFile(Msg.WParam, i , nil, 0) + 1;
> > Filename:= StrAlloc(size);
> > DragQueryFile(Msg.WParam,i , Filename, size);
> > s := Extractfileext(Filename);
> > if s <> '.bmp' then
> > continue
> > else
> > listbox1.items.add(StrPas(Filename));
> > StrDispose(Filename);
> > end;
> > DragFinish(Msg.WParam);
> > end;
> >
> > Then Enable the function
> > by declaring
> >
> > DragAcceptFiles(Form1.Handle, true);
> >
> >
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads