Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WM_DROPFILES on ListView

26 views
Skip to first unread message

4N

unread,
Oct 19, 2006, 1:04:22 PM10/19/06
to
Hi,
I wrote a code to intercept WM_DROPFILES in a form, now I'd like to move it
on a ListView component inside the form.
I guess I could create a CustomListView and initialize it at runtime but
this way I can't see it in the Form editor and modify it visually.
How can I solve this problem?


Remy Lebeau (TeamB)

unread,
Oct 19, 2006, 2:17:09 PM10/19/06
to

"4N" <xx...@yyyy.zzz> wrote in message
news:4537af86$1...@newsgroups.borland.com...

> I wrote a code to intercept WM_DROPFILES in a form, now
> I'd like to move it on a ListView component inside the form.

You need to subclass the ListView's WindowProc property, as then specify the
ListView's Handle when calling DragAcceptFiles(). You will also have to
intercept the CM_RECREATEWND message so that you can call DragAcceptFiles()
again whenever the ListView's Handle is recreated by the VCL internals. For
example:

TWndMethod OldWndProc;

__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
OldWndProc = ListView1->WindowProc;
ListView1->WindowProc = ListViewWndProc;
DragAcceptFiles(ListView1->Handle, TRUE);
}

void __fastcal TForm1::ListViewWndProc(TMessage &Message)
{
switch( Message.Msg )
{
case WM_DROP_FILES:
{
//...
break;
}

case CM_RECREATEWND:
{
DragAcceptFiles(ListView1->Handle, FALSE);
OldWndProc(Message);
DragAcceptFiles(ListView1->Handle, TRUE);
break;
}

default:
OldWndProc(Message);
break;
}
}

> I guess I could create a CustomListView and initialize it at runtime
> but this way I can't see it in the Form editor and modify it visually.

You can if you put it into a package and then install it into the Component
Palette.


Gambit


4N

unread,
Oct 20, 2006, 3:50:38 PM10/20/06
to
> You can if you put it into a package and then install it into the
> Component Palette.

I hate this... but I guess it can't be helped.
Thanks.


Harold Howe [TeamB]

unread,
Oct 23, 2006, 4:12:34 PM10/23/06
to

It may seem like busywork, but this is the best approach from an OO
standpoint.

If you still don't want create a package, you could could create a
wrapper class that cleans up the WindowProc code that Remy posted.
Something like:

class TDropFilesHandler : TWinControl
{
public:
TDropFilesHandler(TWinControl target, TComponent Owner);
...
}

// usage


__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{

dropHandler = new TDropHandler(ListView1, this);
}

H^2

0 new messages