trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Demo] Replacing controls with text

 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Fri Aug 11, 2006 7:17 pm    Post subject: [Demo] Replacing controls with text Reply with quote

http://www.trichview.com/support/files/controls2text.zip

Shows how to change controls to their text value



2008-Dec-11: updated for compatibility with TRichView 11 and Delphi 2009.


Last edited by Sergey Tkachenko on Thu Dec 11, 2008 3:48 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Fri Aug 24, 2007 5:24 pm    Post subject: Reply with quote

Similar code can be used to change controls to images.
In this code, GetControlGraphic is your function returning graphic representation of the given control. You can use DrawControl function from CtrlImg unit, but it is not able to create images for all types of controls.

Code:
{ Inserting graphic item in RVData at the ItemNo position }
{ some undocumented functions are used }
procedure InsertGraphicItem(RVData: TCustomRVData; ItemNo: Integer;
  ItemName: TRVRawByteString; gr: TGraphic; VAlign: TRVVAlign;
  PageBreak, NewLine, NewPara: Boolean);
var Item: TRVGraphicItemInfo;
begin
  Item := TRVGraphicItemInfo.CreateEx(RVData, gr, VAlign);
  Item.SameAsPrev := not NewPara;
  if NewLine and not NewPara then
    Item.BR := True;
  if PageBreak then
    Item.PageBreakBefore := True;
  Item.Inserting(RVData, ItemName, False);
  RVData.Items.InsertObject(ItemNo, ItemName, Item);
  Item.Inserted(RVData, ItemNo);
end;


Code:
{ Changes all controls in RVData (and its sub-data) to their graphic
  representations }
procedure ControlsToGraphics(RVData: TCustomRVData);
var i,r,c: Integer;
    Control: TControl;
    ControlName: TRVAnsiString;
    ControlTag: Integer;
    ControlVAlign: TRVVAlign;
    table: TRVTableItemInfo;
    PageBreak, NewLine, NewPara: Boolean;
    Graphic: TBitmap;
begin
  for i := 0 to RVData.ItemCount-1 do
    case RVData.GetItemStyle(i) of
      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
                ControlsToGraphics(table.Cells[r,c].GetRVData);

        end;
      rvsComponent:
        begin
          RVData.GetControlInfo(i, ControlName, Control, ControlVAlign, ControlTag);
          Graphic := GetControlGraphic(Control);
          PageBreak := RVData.PageBreaksBeforeItems[i];
          NewLine := RVData.IsFromNewLine(i);
          NewPara := RVData.IsParaStart(i);
          RVData.DeleteItems(i, 1);
          // you can copy tag as well
          InsertGraphicItem(RVData, i, ControlName, Graphic, ControlVAlign,
            PageBreak, NewLine, NewPara);
        end;
    end;
end;


2008-Dec-11: Updated for compatibility with TRichView 11
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group