Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 438749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:42:33+00:00 2026-05-12T20:42:33+00:00

Based on this drag/drop article: http://delphi.about.com/od/adptips2005/qt/dropontimage.htm I’m trying to catch an image dragged from

  • 0

Based on this drag/drop article: http://delphi.about.com/od/adptips2005/qt/dropontimage.htm

I’m trying to catch an image dragged from Firefox onto a TPanel, I’ve got something that nearly works, but when I go to copy the file (that I thought would be temporarily created), the file did not exist, what did I miss?

procedure TformMain.FormCreate(Sender: TObject);
begin
  originalPanelWindowProc := pnMain.WindowProc;
  pnMain.WindowProc := PanelWindowProc;
  DragAcceptFiles(pnMain.Handle,true);
end;

procedure TformMain.PanelImageDrop(var Msg: TWMDROPFILES);
var
   numFiles : longInt;
   buffer : array[0..MAX_PATH] of char;
   src,dest : string;
begin
  numFiles := DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0) ;
  if numFiles > 1 then
    ShowMessage('You can drop only one image file at a time!')
  else begin
    DragQueryFile(Msg.Drop, 0, @buffer, sizeof(buffer)) ;
    src := string(AnsiString(buffer));
    dest := ExtractFilePath(Application.ExeName) + 'graphics\ ' + NewName + ExtractFileExt(src);
    ForceDirectories(ExtractFilePath(dest));
    CopyFile(PChar(src),PChar(dest),false);  (* <-- !!! src does not exist *)
  end;
end;

procedure TformMain.PanelWindowProc(var Msg: TMessage);
begin
  if Msg.Msg = WM_DROPFILES then
    PanelImageDrop(TWMDROPFILES(Msg))
  else
    originalPanelWindowProc(Msg) ;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:42:33+00:00Added an answer on May 12, 2026 at 8:42 pm

    this works for me:

    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        procedure FormCreate(Sender: TObject);
      private
        originalPanelWindowProc : TWndMethod;
        procedure PanelWindowProc (var Msg : TMessage) ;
        procedure PanelImageDrop(var Msg: TWMDROPFILES);
      public
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      originalPanelWindowProc := Panel1.WindowProc;
      Panel1.WindowProc := PanelWindowProc;
      DragAcceptFiles(panel1.Handle, true);
    end;
    
    procedure TForm1.PanelImageDrop(var Msg: TWMDROPFILES);
    var
       numFiles : longInt;
       buffer : array[0..MAX_PATH] of char;
       src,dest : string;
    begin
      numFiles := DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0) ;
      try
        if numFiles > 1 then
          ShowMessage('You can drop only one image file at a time!')
        else begin
          DragQueryFile(Msg.Drop, 0, @buffer, sizeof(buffer)) ;
          src := string(AnsiString(buffer));
          showmessage(
            src + #13 +
            booltostr(fileexists(src), true)
          );
        end;
      finally
        DragFinish(Msg.Drop);
      end;
    end;
    
    procedure TForm1.PanelWindowProc(var Msg: TMessage);
    begin
      if Msg.Msg = WM_DROPFILES then
         PanelImageDrop(TWMDROPFILES(Msg))
       else
         originalPanelWindowProc(Msg) ;
    end;
    

    delphi 2007, firefox 3.5

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on http://jqueryui.com/demos/sortable/#placeholder I am working on a drag and drop interface that allows
Based off of this Drag/Drop example If I want to increment the the value
I am trying to create a drag/drop effect on iPad (using a library based
I have made a drag-to-trigger_event page based on this guide . I'm displaying list
How easy it's to come up with a drag and drop web-based interface that'll
I started trying to implement drag-and-drop of virtual files (from a C# 4/WPF app)
I'm trying to drag and drop (slide) a Silverlight element from one part of
I want to enable drag and drop from our windows forms based application to
I am working on a web based drag and drop type application.I could drag
I'm implementing drag and drop QTreeView based on my custom model. All works fine,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.