Re: drag & drop from other apps

From: Peter Below (TeamB) (100113.1101_at_compuXXserve.com)
Date: 11/22/03

  • Next message: Claude Daneluzzo: "Re: Shutting down an app"
    Date: Sat, 22 Nov 2003 23:38:04 +0100
    
    

    In article <3fbfa188$1@newsgroups.borland.com>, P.Mach wrote:
    > Is there an easy way to drag something from other app and drop it in my app?
    > For instance, to drag a file-icon from the Windows Explorer, drop it in my
    > app so that my app gets the file name? I have read a few articles on the
    > subject, but it seems quite complex. Are there any published samples?
    > Thanks for your help.

    Making a drop target for files is fairly easy, you call the DragAcceptFiles
    API function for a window that should accept dragged files from Explorer and
    handle the WM_DROPFILES message to actually get the file(s). A full OLE
    drag&drop implementation (needed for things other than files or when you want
    to create a drag source) is more involved. Here are a couple of URLs for that.

      http://www.melander.dk ( http://users.on.net/johnson/delphi/ as alternative)
      http://www.undu.com/LIBS/DnD.zip
      http://www.wideman-one.com/gw/tech/Delphi/dragdrop/
      OLE Drag and Drop Components http://www.unitoops.com/

    Dropping files on a memo.

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;

    type
      TMemo = class( StdCtrls.TMemo )
      private
        { Private declarations }
        procedure wmDropFiles( Var msg: TWMDropFiles );
          message WM_DROPFILES;
      protected
        procedure CreateWnd; override;
        procedure DestroyWnd; override;
      end;

      TForm1 = class(TForm)
        Memo1: TMemo;
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    uses shellapi;

    {$R *.DFM}

    { TMemo }

    procedure TMemo.CreateWnd;
    begin
      inherited;
      DragAcceptFiles( handle, true );
    end;

    procedure TMemo.DestroyWnd;
    begin
      DragAcceptFiles( handle, false );
      inherited;
    end;

    procedure TMemo.wmDropFiles(var msg: TWMDropFiles);
    var
      filename: Array [0..MAX_PATH] of Char;
    begin
      DragQueryFile( msg.Drop, 0, filename, sizeof( filename ));
      Lines.Loadfromfile( filename );
      DragFinish( msg.Drop );
    end;

    >

    --
    Peter Below (TeamB)  
    Use the newsgroup archives :
    http://www.mers.com/searchsite.html
    http://www.tamaracka.com/search.htm
    http://groups.google.com
    http://www.prolix.be
    

  • Next message: Claude Daneluzzo: "Re: Shutting down an app"

    Relevant Pages

    • Re: Multi windowed programs
      ... Jamie Kahn Genet wrote: ... for drag 'n' drop and related actions. ... If it's a single pane app, ... onto today's large screens without overlap. ...
      (comp.sys.mac.misc)
    • Re: Why no Newsreader.app? AND MORE!
      ... one is a simple drag and the other is either cmd-l followed by a drag ... have permissions to move the app, it can take a LOT longer as you enter ... multiple hard drives, ... Why would you have duplicate apps and home folders??? ...
      (comp.sys.mac.apps)
    • Re: My G5 & Leopard
      ... It offers a great deal over winders. ... all without having to save and drag, ... With a Mac you _can_ use it as an app centric menu driven ...
      (comp.sys.mac.advocacy)
    • Re: Search for component which makes drag & drop possible
      ... if your doing this with in the same app then you should be able to us ... a window to accept A drag and drop of a name string. ...
      (alt.comp.lang.borland-delphi)
    • Re: OCX, Classes, DLLs - Which?
      ... classes are easier to "drag and drop" from app to app. ... fwiw, in SourceSafe, I have a folder that contains quite a few of these ... its folder to the project I'm working on, ...
      (microsoft.public.vb.general.discussion)