View Issue Details

IDProjectCategoryView StatusLast Update
0004179JEDI VCL00 JVCL Componentspublic2008-10-29 06:20
ReporterAndrew ShkuropiyAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionsuspended 
Platformwin32OSWindowsOS VersionXP SP2
Product Version3.30 
Target VersionFixed in Version 
Summary0004179: TJvRichEdit - is there any way to catch WM_DROPFILES message?
Descriptioni'm trying to use TJvRichEdit to catch pictures from Windows Explorer by dragging graphic files into rich text. I tried to use this API in TForm.OnCreate

DragAcceptFiles(JvRichEdit1.Handle, True);

to enable receiving of WM_DROPFILES notifications, that contains information about files dragged into RichEdit. After that I used message hook (TApplication.OnMessage) to catch message WM_DROPFILES adressed to JvRichEdit1.Handle, but it's not catching this message when I'm trying to dragdrop files from explorer. It's working on standard VCL TRichEdit, but it doesn't on TJvRichEdit.

Maybe I need to set up some additional properties of TJvRichEdit?
Can you advice something how to enable that messages?
TagsNo tags attached.

Activities

remkobonte

2007-07-16 13:25

developer   ~0013585

Last edited: 2007-07-16 13:26

If you set all of the following properties to true, you won't get a WM_DROPFILES notification:

 * AllowInPlace
 * AllowObjects
 * OleDragDrop

If you set one or more of these to false, it should work.

Note that changing these values will recreate the rich edit controls window, so you have to call DragAcceptFiles again

Andrew Shkuropiy

2007-07-29 14:17

reporter   ~0013605

Thank you, it's working if either AllowObjects or OleDragDrop set to false. But how to catch file's drag-drop if I need to display/operate OLE in TJvRichEdit?

Is there any other way to catch drag-drop events from Windows Explorer on TJvRichEdit?

remkobonte

2007-08-08 16:38

developer   ~0013622

Then you have to alter TRichEditOleCallback.QueryAcceptData; The following code is largely copied from JvDragDrop.pas:

function TRichEditOleCallback.QueryAcceptData(const dataObj: IDataObject;
  var cfFormat: TClipFormat; reco: DWORD; fReally: BOOL;
  hMetaPict: HGLOBAL): HRESULT;
var
  DragH: Integer;
  Medium: TStgMedium;
  Name: string;
  Count, Len: Integer;
begin
  Result := S_OK;

  if dataObj.GetData(FileDropFormatEtc, Medium) = S_OK then
  try
    try
      if not fReally then
      begin
        Result := S_False;
        Exit;
      end;

      DragH := Integer(GlobalLock(Medium.hGlobal));
      try
        Count := DragQueryFile(DragH, Cardinal(-1), nil, 0);
        if Count = 1 then
        begin
          Len := DragQueryFile(DragH, 0, nil, 0);
          if Len > 0 then
          begin
            SetLength(Name, Len + 1);
            DragQueryFile(DragH, 0, PChar(Name), Len + 1);
            SetLength(Name, Len);
            FRichEdit.Lines.LoadFromFile(Name);

            Result := S_False;
            Exit;
          end;
        end;
      finally
        GlobalUnlock(Medium.hGlobal);
      end;
    finally
      ReleaseStgMedium(Medium);
    end;
  except
    Result := E_FAIL;
  end;
end;

Andrew Shkuropiy

2007-08-11 03:01

reporter   ~0013625

Thank you again! It works with such TFormatEtc record:

var FileDropFormatEtc: TFormatEtc;

begin
 ...
  FileDropFormatEtc.cfFormat := CF_HDROP;
  FileDropFormatEtc.ptd := nil;
  FileDropFormatEtc.dwAspect := DVASPECT_CONTENT;
  FileDropFormatEtc.lindex := 0;
  FileDropFormatEtc.tymed := TYMED_HGLOBAL;
...


Don't you know, the developers of TJvRichEdit planned to extract some general OLEDragDrop events from IRichEditOLECallback interface in future versions of JVCL or not? (Something like TJvRichEdit.OnFileDrop, OnFileAccept etc)

These events can greately extend possibilities of RichEdit, especially for novices (like me), who still don't know all fine points of IRichEditOleCallback.

obones

2007-10-12 08:17

administrator   ~0013929

What should I do with this issue?

obones

2008-02-21 06:47

administrator   ~0014251

Any news?

obones

2008-10-29 06:20

administrator   ~0014928

No news, closing the issue. Please create a new one if this is still present in the latest SVN version.

Issue History

Date Modified Username Field Change
2007-07-13 08:37 Andrew Shkuropiy New Issue
2007-07-16 13:25 remkobonte Note Added: 0013585
2007-07-16 13:26 remkobonte Note Edited: 0013585
2007-07-29 14:17 Andrew Shkuropiy Note Added: 0013605
2007-08-08 16:38 remkobonte Note Added: 0013622
2007-08-11 03:01 Andrew Shkuropiy Note Added: 0013625
2007-10-12 08:17 obones Note Added: 0013929
2007-10-12 08:17 obones Status new => feedback
2008-02-21 06:47 obones Note Added: 0014251
2008-10-29 06:20 obones Status feedback => resolved
2008-10-29 06:20 obones Resolution open => suspended
2008-10-29 06:20 obones Assigned To => obones
2008-10-29 06:20 obones Note Added: 0014928