trichview.com

trichview.support




Re: OnSaveComponentToFile & <form></form>


Return to index


Author

Message

Sergey Tkachenko

Posted: 12/21/2004 13:38:46


Well, obviously you need to find the first and the last control.

Before saving, enumerate all items and assign FirstControl and LastControl

variables.

You can do it using a recursive procedure, or using undocumented EnumItems

method of RVData.


uses CRVData, RVItem;


Add in the form declaration:


    FirstControl, LastControl: TControl;

    procedure FindFirstLastControlProc(RVData: TCustomRVData; ItemNo:

Integer;

      var UserData1: Integer; const UserData2: String;

      var ContinueEnum: Boolean);


Before the HTML saving, call:


    v := 0;

   FirstControl := nil;

   LastControl := nil;

    RichViewEdit1.RVData.EnumItems(FindFirstLastControlProc, v, '');


procedure TForm1.FindFirstLastControlProc(RVData: TCustomRVData;

  ItemNo: Integer; var UserData1: Integer; const UserData2: String;

  var ContinueEnum: Boolean);

begin

  if RVData.GetItemStyle(ItemNo)=rvsComponent then begin

    LastControl := TRVControlItemInfo(RVData.GetItem(ItemNo)).Control;

    if FirstControl=nil then

      FirstControl := LastControl;

  end;

  ContinueEnum := True;

end;


procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;

  Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;

  var OutStr: String);

begin

  case SaveFormat of

   rvsfHTML:

       begin

         if SaveMe=FirstControl then

           OutStr := '<form>'

         else

           OutStr := '';

         // add HTML control representation to OutStr here.

         // ...

         if SaveMe=LastControl then

           OutStr := OutStr+'</form>';

       end;

   end;

end;


I am afraid this method does not work good, if the first and the last

controls are in different table cells.

Possible alternative solutions:

- allow adding special controls which will be saved in HTML as '<form>' and

'</form>';

- use a special protected text with rvteoHTMLCode in Options to insert

'<form>' and '</form>'.

In these ways, user can control where the form starts and ends.


>

> Dear Sergey,

>

> I'd like to add a '<form>'-tag before the first component and add behind

> the last component a '</form>'-tag.

>

> For example:

> I add TButton, TEdit and a TMemo in TRichViewEdit. The '<form>'-tag should

> before the TButton and the '</form>'-tag should be after the TMemo.

>

> Could you help me out???

>

> Thanks.

>

> Pieter E.

>

>

> "Sergey Tkachenko" <svt@trichview.com> wrote:

> >But where do you want to insert <form> and </form>?

> >

> >>

> >> Dear Sergey,

> >>

> >> When I convert a TRichViewEdit with some TControls to HTML with the

> >OnSaveComponentToFile

> >> event there is nog '<form>' & '</form>'-tag.

> >>

> >> Is there a way to set the result in a HTML formtag? (<form>bla

bla</form>)

> >>

> >> Thanks.

> >>

> >> Pieter E.

> >

> >

>





Powered by ABC Amber Outlook Express Converter