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

  • SEARCH
  • Home
  • 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 3848310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:40:58+00:00 2026-05-19T16:40:58+00:00

This topic obviously has been hitted over and over again here, but now I

  • 0

This topic obviously has been hitted over and over again here, but now I just run out of options from my point of view.

OS: Windows XP SP3

So, here is Drag and Drop example for RichEdit I use in my app:

procedure TForm1.AcceptFiles( var msg : TMessage ); // or TWMDROPFILES
const
  cnMaxFileNameLen = 255;
var
  i,
  nCount     : integer;
  acFileName : array [0..cnMaxFileNameLen] of char;
begin
  // find out how many files we're accepting
  nCount := DragQueryFile( msg.WParam, // or msg.Drop
                           $FFFFFFFF,
                           acFileName,
                           cnMaxFileNameLen );

  // query Windows one at a time for the file name
  for i := 0 to nCount-1 do
  begin
    DragQueryFile( msg.WParam, { or msg.Drop} i,
                   acFileName, cnMaxFileNameLen );

    // do your thing with the acFileName
    MessageBox( Handle, acFileName, '', MB_OK );
  end;

  // let Windows know that you're done
  DragFinish( msg.WParam ); // or msg.Drop
end;

Problem is that after some recent changes ( unforutinetly I do not use any SVN so I cannot track which commit was introducing this issue ) Drag and Drop do not work any more.

I have run breakpoints without success in every event that might be somehow related ( called ):

RichEditMouseOver;

RichEditChange;

FormClick;

My app is processing these WM’s:

procedure WMDropFiles(var Msg: TWMDROPFILES); message WM_DROPFILES;

procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;

procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;

procedure WMGetMinMaxInfo(var AMsg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;

procedure CMDialogKey(var Msg: TCMDialogKey ); message CM_DIALOGKEY;

On blank project with TRichEdit on form – all is working OK.

Also tried changing DragAcceptFiles() Form1.Handle to RichEdit.Handle – still no luck.

When echo’ing nCount and acFileName parameters, acFileName do not have File Path of Dragged file … Why????

Currently I just have no clue what makes the acFileName parameter losing Dragged files path. Could you suggest where problem is hiding?

  • 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-19T16:40:58+00:00Added an answer on May 19, 2026 at 4:40 pm

    I’m afraid I’m not an expert on how Dragging and Dropping files actually works. So I can’t go through your code an figure out what’s wrong.

    What I can do is give you the code that I use. It works for me now under Delphi 2009 on XP, Vista and Windows 7. It also worked when I was previously using Delphi 4 on Windows 98 and Windows XP.

    Maybe you can figure out what’s wrong in your code using this, or you might want to try using or adapting this code. It is originally from the book: “Delphi 3 – User Interface Design”, pages 169 – 171.

    If I’ve left out an important routine, let me know in a comment and I’ll edit my answer to include it.

    type
      TMainForm = class(TForm)
        procedure WMDropFiles(var WinMsg: TMessage);
                  message wm_DropFiles;
        procedure AppMessageHandler(var Msg: TMsg; var Handled: Boolean);
    
    procedure TMainForm.FormShow(Sender: TObject);
    begin
      DragAcceptFiles(Handle, true);
      Application.OnMessage := AppMessageHandler;
    end;
    
    procedure TLogoAppForm.WMDropFiles(var WinMsg: TMessage);
    const
      BufSize = 255;
    var
      TempStr : array[0..BufSize] of Char;
      NumDroppedFiles, I: integer;
      Filenames: TStringList;
    begin
      NumDroppedFiles := DragQueryFile(TWMDropFiles(WinMsg).Drop, $ffffffff, nil, 0);
      if NumDroppedFiles >= 1 then begin
        Filenames := TStringList.Create;
        for I := 0 to NumDroppedFiles - 1 do begin
          DragQueryFile(TWMDropFiles(WinMsg).Drop, I, TempStr, BufSize);
          Filenames.Add(TempStr);
        end;
        OpenFiles(Filenames, '');
        Filenames.Free;
      end;
      DragFinish(TWMDropFiles(WinMsg).Drop);
      WinMsg.Result := 0;
    end;
    
    procedure TLogoAppForm.AppMessageHandler(var Msg: TMsg; var Handled: Boolean);
    begin
      if (Msg.Message = WM_DropFiles) and IsIconic(Application.Handle) then begin
        Perform(Msg.Message, Msg.Wparam, Msg.lParam);
        Handled := true;
      end
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is slightly off topic of programming but still has to do with my
I've been hearing conflicting facts about this topic. What is correct?
I browsed around here on Stackoverflow and found this topic : https://stackoverflow.com/questions/279/aspnet-visual-studio-and-subversion-how-to-integrate However that
Are out parameters a bad thing in .NET? Any good articles/discussions on this topic?
Related to This topic I wonder if anyone has made the Microsoft Charting library
I have heard mixed responses on this topic, so what is a sure fire
I didn't see any similar questions asked on this topic, and I had to
There doesn't seem to be much info on this topic so I'm going to
There's a lot of conflicting information about this topic. So let's try to agree
Ok, so I wanted to get opinions on this topic. I have a dumb

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.