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?
Drag'n'drop MS Word DOC to TRichViewEdit
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, use OnDropFiles event, and insert all supported files.
For inserting a doc file, use this function:
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;