Marking the whole table row and the whole table column of a focused table cell
Marking the whole table row and the whole table column of a focused table cell
Hello,
my code for marking the whole table row and the whole table column of a focused table cell works as long as I put the code into a panel (.sbTabZeilefaerbenClick (Sender: TObject)).
But if I set it in .memoRVDblClick (Sender: TCustomRichView; ClickedWord: TRVUnicodeString; Style: Integer) I get an 'Abstract Error'.
What can I do - when I click on a cell - the whole table row and the whole table column of the focused cell are highlighted in yellow?
Jürgen
(D7 and TRichViewEdit 17.6)
// Code is OK (I must first focus the cell, then click below panel-button):
procedure TForm1.sbTabZeilefaerbenClick (Sender: TObject);
var i, j, h color: integer;
cs, rs, itemNo, Data: integer; // Color the entire font background
begin // This procedure is wg. an abstract error if the content is captured elsewhere
// Does table have the cursor?
if (not memo.CanChange) or (not memo.GetCurrentItemEx (TRVTableItemInfo, rve,
TCustomRVItemInfo (rveTable))) then begin
ShowMessage ('This option is intended to provide better orientation in a table,' + # 10 +
'by using the focused line u. Column turns yellow (discolored). '+ # 10);
exit;
end;
try
ItemNo: = rveTable.GetMyItemNo;
memo.BeginUndoGroup (rvutModifyItem);
memo.SetUndoGroupMode (True);
memo.BeginItemModify (ItemNo, Data);
// Determine the focused line here
cs: = - 1; rs: = - 1;
rveTable.GetNormalizedSelectionBounds (true, rveTzeile1, rveTspalte1, CS, RS);
if (cs = -1) and (rs = -1) then exit;
// Determine the focused cell color
hColor: = rveTable.cells [rveTzeile1, rveTspalte1] .color;
if hFarbe = clWhite then hFarbe: = 11993087 else hFarbe: = clWhite;
// Color all cells in the table white
For j: = 0 to rveTable.Rows.Count-1 do
for i: = 0 to rveTable.Rows [rveTzeile1] .Count-1 do
rveTable.SetCellColor (clWhite, j, i);
// Color focused cells in a row
for j: = 0 to rveTable.Rows [rveTzeile1] .Count-1 do
rveTable.SetCellColor (hFarbe, rveTzeile1, j);
// Color focused cells in a column
for j: = 0 to rveTable.Rows.Count-1 do
rveTable.SetCellColor (hFarbe, j, rveTspalte1);
finally
memo.EndItemModify (ItemNo, Data);
memo.SetUndoGroupMode (False);
memo.Change;
if memo.GetCurrentItemEx (TRVTableItemInfo, rve, TCustomRVItemInfo (rveTable)) then rveTable.EditCell (rveTzeile1, rveTspalte1);
end;
end; // of .sbTabZeilefaerbenClick
procedure TForm1.memoRVDblClick(Sender: TCustomRichView; ClickedWord: TRVUnicodeString; Style: Integer);
begin //Wenn memo.onDblClick vorliegt, wird dies Procedure nicht mehr durchlaufen
if Screen.Cursor=crHandPoint then begin
HyperlinkInfo;
HyperlinkAusfuehren;
end;
//sbTabZeilefaerbenClick (Self); //abstract error - Delphi ist frozen
end;
my code for marking the whole table row and the whole table column of a focused table cell works as long as I put the code into a panel (.sbTabZeilefaerbenClick (Sender: TObject)).
But if I set it in .memoRVDblClick (Sender: TCustomRichView; ClickedWord: TRVUnicodeString; Style: Integer) I get an 'Abstract Error'.
What can I do - when I click on a cell - the whole table row and the whole table column of the focused cell are highlighted in yellow?
Jürgen
(D7 and TRichViewEdit 17.6)
// Code is OK (I must first focus the cell, then click below panel-button):
procedure TForm1.sbTabZeilefaerbenClick (Sender: TObject);
var i, j, h color: integer;
cs, rs, itemNo, Data: integer; // Color the entire font background
begin // This procedure is wg. an abstract error if the content is captured elsewhere
// Does table have the cursor?
if (not memo.CanChange) or (not memo.GetCurrentItemEx (TRVTableItemInfo, rve,
TCustomRVItemInfo (rveTable))) then begin
ShowMessage ('This option is intended to provide better orientation in a table,' + # 10 +
'by using the focused line u. Column turns yellow (discolored). '+ # 10);
exit;
end;
try
ItemNo: = rveTable.GetMyItemNo;
memo.BeginUndoGroup (rvutModifyItem);
memo.SetUndoGroupMode (True);
memo.BeginItemModify (ItemNo, Data);
// Determine the focused line here
cs: = - 1; rs: = - 1;
rveTable.GetNormalizedSelectionBounds (true, rveTzeile1, rveTspalte1, CS, RS);
if (cs = -1) and (rs = -1) then exit;
// Determine the focused cell color
hColor: = rveTable.cells [rveTzeile1, rveTspalte1] .color;
if hFarbe = clWhite then hFarbe: = 11993087 else hFarbe: = clWhite;
// Color all cells in the table white
For j: = 0 to rveTable.Rows.Count-1 do
for i: = 0 to rveTable.Rows [rveTzeile1] .Count-1 do
rveTable.SetCellColor (clWhite, j, i);
// Color focused cells in a row
for j: = 0 to rveTable.Rows [rveTzeile1] .Count-1 do
rveTable.SetCellColor (hFarbe, rveTzeile1, j);
// Color focused cells in a column
for j: = 0 to rveTable.Rows.Count-1 do
rveTable.SetCellColor (hFarbe, j, rveTspalte1);
finally
memo.EndItemModify (ItemNo, Data);
memo.SetUndoGroupMode (False);
memo.Change;
if memo.GetCurrentItemEx (TRVTableItemInfo, rve, TCustomRVItemInfo (rveTable)) then rveTable.EditCell (rveTzeile1, rveTspalte1);
end;
end; // of .sbTabZeilefaerbenClick
procedure TForm1.memoRVDblClick(Sender: TCustomRichView; ClickedWord: TRVUnicodeString; Style: Integer);
begin //Wenn memo.onDblClick vorliegt, wird dies Procedure nicht mehr durchlaufen
if Screen.Cursor=crHandPoint then begin
HyperlinkInfo;
HyperlinkAusfuehren;
end;
//sbTabZeilefaerbenClick (Self); //abstract error - Delphi ist frozen
end;
Re: Marking the whole table row and the whole table column of a focused table cell
Does really nobody know what a solution could look like, if you click in a rveTabelle (rve: RichViewEdit) to get the 'cross' - in the intersection of which the focused cell is located?
My solution requires 2 steps:
1. Click on the cell
2. Click the switch '.sbTabZeilefaerbenClick'.
My solution requires 2 steps:
1. Click on the cell
2. Click the switch '.sbTabZeilefaerbenClick'.
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Marking the whole table row and the whole table column of a focused table cell
Sorry for the delay.
When a cell is being edited, TRichViewEdit creates a special editor for this cell (cell inplace editor).
It is created you start edit cell, and it is destroyed when you move the caret from this cell.
There is a problem: you cannot destroy an inplace editor from inside its keyboard/mouse/drag events, because of VCL design.
Workaround: use PostMessage.
Example can be found in TRichView\Demos\DelphiUnicode\Assorted\Graphics\DragImg\
This demo uses PostMessage to move the caret in OnDragOver event.
When a cell is being edited, TRichViewEdit creates a special editor for this cell (cell inplace editor).
It is created you start edit cell, and it is destroyed when you move the caret from this cell.
There is a problem: you cannot destroy an inplace editor from inside its keyboard/mouse/drag events, because of VCL design.
Workaround: use PostMessage.
Example can be found in TRichView\Demos\DelphiUnicode\Assorted\Graphics\DragImg\
This demo uses PostMessage to move the caret in OnDragOver event.
Re: Marking the whole table row and the whole table column of a focused table cell
First Thanks.
The example in
TRichView\Demos\DelphiUnicode\Assorted\Graphics\DragImg\
is dragging a TImage to TRichViewEdit.
This does not fit my circumstances.
I want to have a row and column that intersect in the focused cell.
The example in
TRichView\Demos\DelphiUnicode\Assorted\Graphics\DragImg\
is dragging a TImage to TRichViewEdit.
This does not fit my circumstances.
I want to have a row and column that intersect in the focused cell.
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Marking the whole table row and the whole table column of a focused table cell
That demo shows how to solve your problem: running from inside mouse/drag event a code that cannot be executed inside this event.
But ok, I'll make a project for you tomorrow.
But ok, I'll make a project for you tomorrow.
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Marking the whole table row and the whole table column of a focused table cell
Attached.
I used OnRVMouseDown (with ssDouble in Shift check) instead of OnRVDblClick, because OnRVDblClick is not called when users click on an empty space.
I used OnRVMouseDown (with ssDouble in Shift check) instead of OnRVDblClick, because OnRVDblClick is not called when users click on an empty space.
- Attachments
-
- HighlightCell.zip
- (50.03 KiB) Downloaded 1701 times
Re: Marking the whole table row and the whole table column of a focused table cell
Thank you very much for your effort.
Unfortunately, I must have expressed myself incorrectly.
Your solution corresponds to mine.
I need 2 steps to get the 'cross':
1. Click in wanted cell
2. Click at 'sbTabZeilefaerben' button to run code.
Result: The 'cross' is created as posted by you.
It's the same in your example:
1. Click in the wanted cell
2. Click at 'Highlight' button.
But I want the cross to be created when I double click in a cell.
Can you help me with that ?
But first celebrate and enjoy christmas in peace and rest (without looking into your email account).
I wish you a happy, relaxed and uplifting Christmas. I once more many thanks for your immeditley help.
Jürgen
Unfortunately, I must have expressed myself incorrectly.
Your solution corresponds to mine.
I need 2 steps to get the 'cross':
1. Click in wanted cell
2. Click at 'sbTabZeilefaerben' button to run code.
Result: The 'cross' is created as posted by you.
It's the same in your example:
1. Click in the wanted cell
2. Click at 'Highlight' button.
But I want the cross to be created when I double click in a cell.
Can you help me with that ?
But first celebrate and enjoy christmas in peace and rest (without looking into your email account).
I wish you a happy, relaxed and uplifting Christmas. I once more many thanks for your immeditley help.
Jürgen
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Marking the whole table row and the whole table column of a focused table cell
In my demo, this highlighting works both when you click on the button and when you double click in the cell.
Re: Marking the whole table row and the whole table column of a focused table cell
Sorry, sorry, sorry.
Your solution is different and works perfectly. I tried your example without looking into the code enough because I saw the 'Highlight' button.
I had double-clicked in a cell, but in anticipation I forgot that I had to do Shift + double-click.
Sorry again for my hasty feedback.
Jürgen
Your solution is different and works perfectly. I tried your example without looking into the code enough because I saw the 'Highlight' button.
I had double-clicked in a cell, but in anticipation I forgot that I had to do Shift + double-click.
Sorry again for my hasty feedback.
Jürgen
-
- Site Admin
- Posts: 17554
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Marking the whole table row and the whole table column of a focused table cell
My example does not require to press Shift key.
The check
in OnRVMouseDown allows detecting a double click. Shift is the parameter name, not the Shift button.
To detect only left mouse button double click, the condition must be changed to:
But I found a bug in the code. rveTable.GetNormalizedSelectionBounds must be moved before try...except, otherwise an exception may occur when the caret is to the left or right side of the table (because rveTzeile1, rveTspalte1 will not be assigned in this case).
I attached a fixed version.
The check
Code: Select all
if ssDouble in Shift then
To detect only left mouse button double click, the condition must be changed to:
Code: Select all
if (Button = mbLeft) and (ssDouble in Shift) then
I attached a fixed version.
- Attachments
-
- HighlightCell2.zip
- (50.04 KiB) Downloaded 1903 times
Re: Marking the whole table row and the whole table column of a focused table cell
Thanks for your help.