trichview.support
Re: OnsavecomponenttoFile event |
Author |
Message |
Sergey Tkachenko |
Posted: 02/21/2003 22:42:47 Well, now I see the question about saving TRXGifAnimator. I am not sure if DrawControl solution will work for it, but there is even simpler solution. shmp has already answered, but may be my answer will still be useful. procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView; Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat; var OutStr: String); var FileName: String; begin case SaveFormat of rvsfHTML: begin if SaveMe is TRxGifAnimator then begin FileName := Sender.RVData.GetNextFileName( 'img', Path, '.gif', Sender.imgSaveNo, True); TRXGifAnimator.SaveToFile(FileName); FileName := ExtractRelativePath(Path, FileName); OutStr := Format('<IMG src="%s" width=%d height=%d>', [FileName, TControl(SaveMe).Width, TControl(SaveMe).Height]); endl end; end; end; All my code assumes that images get numbered file names, img1.gif, img2.gif and so on. But, if you'll store image file names in item names, write FileName := GetControlName(Sender, TControl(SaveMe)); instead of FileName := Sender.RVData.GetNextFileName( 'img', Path, '.gif', Sender.imgSaveNo, True); where function GetControlName(RichView: TCustomRichView; ctrl: TControl): String; function GetControlName_(RVData: TCustomRVData; ctr: TControl; var Name: String): Boolean; var i,r,c: Integer; table: TRVTableItemInfo; begin Result := False; for i := 0 to RVData.ItemCount-1 do case RVData.GetItemStyle(i) of rvsComponent: begin Result := TRVControlItemInfo(RVData.GetItem(i)).Control=ctrl; if Result then begin Name := RVData.GetItemText(i); exit; end; end; rvsTable: begin table := TRVTableItemInfo(RVData.GetItem(i)); for r := 0 to table.Rows.Count-1 do for c := 0 to table.Rows[r].Count-1 do if table.Cells[r,c]<>nil then begin Result := GetControlName_(table.Cells[r,c].GetRVData, ctrl, Name); if Result then exit; end; end; end; end; begin Result := ''; GetControlName_(RichView.RVData, ctrl, Result); end; include RVItem in uses. |
Powered by ABC Amber Outlook Express Converter