Hi,

Am Dienstag, den 03.01.2006, 22:17 +0000 schrieb C Western:
> You might be interested in the attached fragment, which I posted to the 
> mailing list a while back. It simulates the windows file Drag and drop 
> calls using gtk calls. I would supply a patch to put it in the LCL, only 
> I am not sure where to put it.
> Colin

function DroppedFiles(var Message: TMessage):TStringList;
var
  i: Integer;
begin
  Result := TStringList.Create;
  try
    Result.Text := PChar(Message.lParam);
    for i := 0 to Result.Count-1 do
      if Pos('file://', Result[i]) = 1 then
        Result[i] := Copy(Result[i], 8, Length(Result[i]));

dnd urls look like:

file://foo.bar.com/path/to/file/on/local/disk

You put into the string list:
foo.bar.com/path/to/file/on/local/disk


And, are you sure you want to keep the hostname in? I'd do something
like check if it matches fqdn (or is empty to support broken clients)
and if not, set a failed flag, but if so, strip the hostname off (since
no pascal function can handle file paths like that anyways :))

You forgot to call gtk_drag_finish in the DropCallBack (or I'm blind :))

Note that selection data can contain _multiple_ urls. so split on (I
think) #13#10 (or whatever it is) and handle all.

And what does the loop over the targets do in DropCallBack ? the target
item doesn't seem to be used for anything in that function ^^

Note also that accepting "text/plain" and "STRING" targets is a horrible
workaround to support broken clients (after all, it could just be text -
and if it is pasted from a edit box, it's "UTF8_STRING", I think), and
there should be a comment which says so (since you never know, all
broken clients could vanish one day ;) yeah, as if....) 

I'd call the DragAcceptFiles "RegisterDragAcceptFiles" or so :)

Other than that, looks nice.

cheers,
   Danny


_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to