Drag & Drop Problems - Need Advice

General TRichView support forum. Please post your questions here
Post Reply
parad0x
Posts: 14
Joined: Fri Feb 17, 2006 11:40 pm

Drag & Drop Problems - Need Advice

Post by parad0x »

I have TRichViewEdit set up to be used as a Viewer only, ie: I have Read Only set to true and I hide the caret.

The problems I am having is that I now need to accept Drag & Drop but I can't because Read Only is True!

How can I detect that a File is over the RichEdit control and switch Read Only to False so it can accept it then turn it back on (True)?

I have also another problem closely related, the files I am trying to Drag & Drop are with the Extension - .NFO and .DIZ these are not opening at all so how can I somehow Register them? or make RichViewEdit view them once Dragged & Dropped? Is there something I must do using AcceptDrapDropFormats?

Many thanks, I hope you can help me

parad0x
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, you can use OnOleDragEnter, OnOleDragLeave, OnOleDrop and OnChange events:

Code: Select all

procedure TForm3.RichViewEdit1OleDragEnter(Sender: TCustomRichView;
  const DataObject: IDataObject; Shift: TShiftState; X, Y: Integer;
  PossibleDropEffects: TRVOleDropEffects;
  var DropEffect: TRVOleDropEffect);
begin
  RichViewEdit1.ReadOnly := False;
end;

procedure TForm3.RichViewEdit1OleDragLeave(Sender: TObject);
begin
  RichViewEdit1.ReadOnly := True;
end;

var Dropping: Boolean = False;

procedure TForm3.RichViewEdit1OleDrop(Sender: TCustomRichView;
  const DataObject: IDataObject; Shift: TShiftState; X, Y: Integer;
  PossibleDropEffects: TRVOleDropEffects; var DropEffect: TRVOleDropEffect;
  var DoDefault: Boolean);
begin
  if DropEffect<>rvdeNone then
    Dropping := True
  else
    RichViewEdit1.ReadOnly := True;
end;

procedure TForm3.RichViewEdit1Change(Sender: TObject);
begin
  if Dropping then begin
    Dropping := False;
    RichViewEdit1.ReadOnly := True;
  end;
end;
You may wish to disallow drag&drop from this editor, include rvoDisallowDrag in RichViewEdit1.Options.

Besides, take a look at this demo: http://www.trichview.com/forums/viewtopic.php?t=132
It's quite an advanced one, but may be it does what you need.
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The only way to allow pasting files with other extensions is processing OnDropFiles event.
New help file (available for registered users) has an example how to use this event.
parad0x
Posts: 14
Joined: Fri Feb 17, 2006 11:40 pm

Post by parad0x »

Hi thanks Sergey for your time,

I have managed to resolve this now by trapping WMDROPFILES which allows me to open both .DIZ and .NFO and .TXT with no problems everytihng else is ignored.

Thanks

parad0x
Post Reply