Drag'n'drop MS Word DOC to TRichViewEdit

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Drag'n'drop MS Word DOC to TRichViewEdit

Post by Marsianin »

TRichViewEdit support dropping TXT/RTF/RVF files. But I wan to make it for DOC too.
How can I detect file type user dropping and use OfficeConverters to accept it.
Should I need to parse Files property in OnDropFiles event?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, use OnDropFiles event, and insert all supported files.

For inserting a doc file, use this function:

Code: Select all

function LoadDocFile(const FileName: String; rve: TCustomRichViewEdit; 
  converter: TRVOfficeConverter): Boolean; 
var i: Integer; 
begin 
  Result := False; 
  for i := 0 to converter.ImportConverters.Count-1 do 
    if (Pos('.doc', AnsiLowerCase(converter.ImportConverters[i].Filter))>0) and converter.ImportRTF(FileName, i) then begin 
    converter.Stream.Position := 0; 
    rve.InsertRTFFromStreamEd(RVOfficeConverter1.Stream); 
    converter.Stream.SetSize(0); 
    Result := True; 
    break; 
  end; 
end;
Post Reply