View previous topic :: View next topic |
Author |
Message |
snorkel
Joined: 16 May 2008 Posts: 7
|
Posted: Mon May 19, 2008 2:33 am Post subject: Synedit conversion issue |
|
|
Hi,
Currently converting my app from synedit and I have run into a issue.
In synedit I could get the top line number of a selected block of text like this:
seltop:= editor.BlockBegin.Line;
Reading the docs I thought I could use:
editor.SelRect.Top
But this does not seem to work, it always comes back as a zero value.
I noticed in the docs it said the selection mode must be mscolumn, so at form create I set this, but it still did not seem to work.
Anyone have some insight for me?
Thanks,
Snorkel |
|
Back to top |
|
|
snorkel
Joined: 16 May 2008 Posts: 7
|
Posted: Tue May 20, 2008 7:15 am Post subject: nevermid |
|
|
I figured it out, in case anyone else runs into this you need to do:
editor.StrPosToCaretPos(editor.SelStart);
This returns a tpoint and the tpoint.y is the top line of the selected block of text. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Mon May 26, 2008 5:37 pm Post subject: |
|
|
Hello,
There is function:
Code: | function TCustomSyntaxMemo.GetSelectedLines(var FirstLine, LastLine: integer): integer;
begin
if SelectMode = msColumn then
begin
FirstLine := FBlock.Top;
LastLine := FBlock.Bottom;
end else
begin
FirstLine := StrPosToCaretPos(FSelStart).Y;
with StrPosToCaretPos(FSelStart + FSelLength) do
if (X = 0) and (Y > 0) then
LastLine := Y - 1
else
LastLine := Y;
if LastLine < FirstLine then
LastLine := FirstLine;
end;
Result := LastLine - FirstLine + 1;
end; |
You may see that start of selected block depends on selection mode (normal/columnar), so I recommend to use this function of editor.
Michael. |
|
Back to top |
|
|
|