Hello,
we have problem to determine the y coord of controls which are inside a table cell, which are longer than the screen height of the Richview.
We are using
TRichView(c.Parent).GetItemCoords(TRichView(c.Parent).FindControlItemNo(c), x, y);
y has the correct value if the height of the table cell isn't higher than the height of the Richview component. Otherwise I get a wrong value.
Any ideas?
What I want to do is, that the Richview scroll to the control if the control get the focus. Can I do this with another method like for example Richview.ControlInView(c) or something else?
Best wishes
Bernhard
Coordinate of Controls whicht are inside table cells
-
- Posts: 104
- Joined: Mon Nov 26, 2007 1:49 pm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
GetItemCoords returns coordinates related the cell inplace editor.
They can be recalculated, but I suggest this method:
where
They can be recalculated, but I suggest this method:
Code: Select all
var RVData:TCustomRVData;
ItemNo: Integer;
FindControlLocation(RichViewEdit1.RVData, c, RVData, ItemNo);
RichViewEdit1.GetItemCoordsEx(TCustomRVFormattedData(RVData), ItemNo, 0, True, ControlCoords)
// if you need client coordinates in RichViewEdit:
R.TopLeft := RichViewEdit1.DocumentToClient(R.TopLeft);
R.BottomRight := RichViewEdit1.DocumentToClient(R.BottomRight);
Code: Select all
function FindControlLocation(RVData: TCustomRVData; ctrl: TControl;
var CtrlRVData: TCustomRVData;
var CtrlItemNo: Integer): Boolean;
var i,r,c: Integer;
table: TRVTableItemInfo;
begin
Result := False;
for i := 0 to RVData.Items.Count-1 do
case RVData.GetItemStyle(i) of
rvsComponent:
begin
Result := TRVControlItemInfo(RVData.GetItem(i)).Control=ctrl;
if Result then begin
CtrlRVData := RVData.GetSourceRVData;
CtrlItemNo := 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 := FindControlLocation(table.Cells[r,c].GetRVData, ctrl, CtrlRVData, CtrlItemNo);
if Result then
exit;
end;
end;
end;
end;