Page 1 of 1
Drag'n'drop MS Word DOC to TRichViewEdit
Posted: Tue Oct 21, 2008 11:49 pm
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?
Posted: Wed Oct 22, 2008 3:59 pm
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;