trichview.com

trichview.support




Re: Embedded control as CurItemNo


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/26/2002 18:21:12


This question was asked some time ago.


Answer is below:


==========


Assign this code to the control's OnClick:


// assuming that editor's name = RichViewEdit1.

procedure TForm1.DoControlClick(Sender: TObject);


    procedure FindControlLocation(var RVData: TCustomRVData; var ItemNo:

Integer);

    var table: TRVTableItemInfo;

        r,c: Integer;

    begin

      if ItemNo<0 then

        ItemNo := RVData.FindControlItemNo(TControl(Sender));

      if ItemNo<0 then begin

        RVData := nil;

        ItemNo := -1;

        end

      else if RVData.GetItemStyle(ItemNo)=rvsComponent then begin

        // found

        end

      else begin

        table := TRVTableItemInfo(RVData.GetItem(ItemNo));

        table.GetCellWhichOwnsControl(TControl(Sender), r,c, ItemNo);

        RVData := table.Cells[r,c].GetRVData;

        FindControlLocation(RVData, ItemNo);

      end;

    end;


var RVData: TCustomRVData;

    ItemNo : Integer;

begin

  RVData := RichViewEdit1.RVData;

  ItemNo := -1;

  FindControlLocation(RVData, ItemNo);

  if (RVData is TRVTableCellData) then

    TRVTableCellData(RVData).Edit;

  TCustomRVFormattedData(RVData.GetRVData).SetSelectionBounds(ItemNo, 1,

ItemNo, 1);

end;


Well, I think that I need to add FindControlLocation to the methods of

RichView.


==========


> After clicking on an embedded control, CurItemNo still seems to return the

> last selected text item instead of the item containing the control. Is

this

> the intended behavour or am I missing something or is it a bug? I need be

> able to get at the tag of the item double clicked on even if it is an

> embedded control item.

>

>





Powered by ABC Amber Outlook Express Converter