Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

Drag-n-Drop usage?

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I have searched the web for some Drag-n-Drop examples (even with Delphi - just to broaden my search). Most of the examples are in the form of this:

 procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer) ;
 begin
    if Source is TImage then
    begin
      TImage(Source).Left := X;
      TImage(Source).Top := Y;
    end;
 end;
 procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean) ;
 begin
    Accept := (Source is TImage) ;
 end;

Well, this seems pretty useless to me, because that means dragging between VCL control to VCL control. Other Windows applications for example will not have a TImage class. So how is Delphi (and thus Lazarus) handle dragging from external (.NET, Mono, MFC, GTK2, KDE etc) applications to a VCL or LCL application? What is the value and type of Source parameter then? Where do you find the actual data being dragged in? Where do you tell it what data (mime types) you want to allow?

Regards, ? - Graeme -

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 30 lines
Hi, I have searched the web for some Drag-n-Drop examples (even with Delphi - just to broaden my search). Most of the examples are in the form of this: procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer) ; begin if Source is TImage then begin TImage(Source).Left := X; TImage(Source).Top := Y; end; end; procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean) ; begin Accept := (Source is TImage) ; end; Well, this seems pretty useless to me, because that means dragging between VCL control to VCL control. Other Windows applications for example will not have a TImage class. So how is Delphi (and thus Lazarus) handle dragging from external (.NET, Mono, MFC, GTK2, KDE etc) applications to a VCL or LCL application? What is the value and type of Source parameter then? Where do you find the actual data being dragged in? Where do you tell it what data (mime types) you want to allow?

On windows, you can only intercept the dropfiles message, which always comes from the explorer and has a well-known format.

There is no general inter-application drag and drop mechanism.

I don't see how you could implement it in the first place.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
There is no general inter-application drag and drop mechanism. I don't see how you could implement it in the first place.

I guess I'll have to dive into the Qt source code then, because they do it! In Qt you register the mime types your are interested in, say which widget accepts drops and hook the mime type list onto that.

Funny that, it seems X11 (of all things) has a much better and well thought out DND protocol that Windows. And who says Linux doesn't have standards! :-)

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
On 14 September 2010 14:12, Michael Van Canneyt wrote: > There is no general inter-application drag and drop mechanism. > I don't see how you could implement it in the first place. I guess I'll have to dive into the Qt source code then, because they do it! In Qt you register the mime types your are interested in, say which widget accepts drops and hook the mime type list onto that.

But that will only work for Qt apps.

With "general inter-application drag and drop mechanism" I meant also (and in the first place) "without regard for the toolkit used".

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
But that will only work for Qt apps. From the Qt docs:

"Interoperating with Other Applications

On X11, the public XDND protocol is used, while on Windows Qt uses the OLE standard, and Qt for Mac OS X uses the Carbon Drag Manager. On X11, XDND uses MIME, so no translation is necessary. The Qt API is the same regardless of the platform. On Windows, MIME-aware applications can communicate by using clipboard format names that are MIME types. Already some Windows applications use MIME naming conventions for their clipboard formats. Internally, Qt uses QWindowsMime and QMacPasteboardMime for translating proprietary clipboard formats to and from MIME types."

With "general inter-application drag and drop mechanism" I meant also (and in the first place) "without regard for the toolkit used".

That's what Qt seems to have achieved - if I understand their documentation correctly.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email