Thanks.
If you want to have the text in a certain line use:
var Buffer: string;
LineNumber: integer;
...
LineNumber:=x;
Buffer:=Memo1/Richedit1.Lines[x-1];
...
Gabriel
Lars <papr...@gkss.de> schrieb in im Newsbeitrag:
7k7qmp$m4...@forums.borland.com...
function MemoCursorLine(AnEditControl : TCustomEdit) : Longint;
begin
With AnEdit do
Result := 1+Perform(EM_LINEFROMCHAR, SelStart+SelLength, 0);
end;
function MemoCursorCol(AnEditControl : TCustomEdit) : Longint;
begin
With AnEdit do
Result := 1 + SelStart + SelLength - Perform(EM_LINEINDEX,
Perform(EM_LINEFROMCHAR, SelStart+SelLength, 0), 0);
end;
function MemoCountSelectedLines(AMemo : TMemo) : Longint;
begin
result := Ord(SelLength > 0);
With AMemo do
Result := result + Perform(EM_LINEFROMCHAR, SelStart + SelLength, 0)
- Perform(EM_LINEFROMCHAR, SelStart, 0);
end;
I copied this from somewhere I hope it helps.
Gabriel Siemoneit schrieb in Nachricht <7k7rj7$m5...@forums.borland.com>...
>Hi Lars
>
>If you want to have the text in a certain line use:
>
>var Buffer: string;
> LineNumber: integer;
>...
>LineNumber:=x;
>Buffer:=Memo1/Richedit1.Lines[x-1];
>...
>
>Gabriel
>
>
>Lars <papr...@gkss.de> schrieb in im Newsbeitrag:
>7k7qmp$m4...@forums.borland.com...
Grega Stamac schrieb in Nachricht <37677589...@sis.si>...
>This is how you get the current position in a memo:
>
>function MemoCursorLine(AnEditControl : TCustomEdit) : Longint;
>begin
> With AnEdit do
> Result := 1+Perform(EM_LINEFROMCHAR, SelStart+SelLength, 0);
>end;
>
>function MemoCursorCol(AnEditControl : TCustomEdit) : Longint;
>begin
> With AnEdit do
> Result := 1 + SelStart + SelLength - Perform(EM_LINEINDEX,
>Perform(EM_LINEFROMCHAR, SelStart+SelLength, 0), 0);
>end;
>
>function MemoCountSelectedLines(AMemo : TMemo) : Longint;
>begin
> result := Ord(SelLength > 0);
> With AMemo do
> Result := result + Perform(EM_LINEFROMCHAR, SelStart + SelLength, 0)
> - Perform(EM_LINEFROMCHAR, SelStart, 0);
>end;
>
>I copied this from somewhere I hope it helps.
>
>Lars wrote:
>
Have a look at the EM_CHARFROMPOS and EM_SETSEL messages in the online help.
For TMemo, you could also use the SelStart property.
GUIDO GYBELS
Programmer (GDG GROEP BELGIUM)
Lars heeft geschreven in bericht <7k812v$m5...@forums.borland.com>...
I have a listview and a richedit.
When I click on line in the Listview, it gets the line number (First_Rec which
I have already determined) of the richedit and takes the user at the beginning
of the line.
RAWDATA is my richedit ListView1 is my Listview
type
Record_Unit=record
Rec_Unit:String[9];
First_Rec:Integer;
Count:Integer;
end;
MyRC=array[1..200] of Record_Unit;
var
RCUN:^MyRC;
procedure TRecCount.ListView1Click(Sender: TObject);
var
r,i:Integer;
z:LongInt;
s:String;
begin
if ListView1.ItemFocused=nil then
MessageDlg('No Selection',MtInformation,[mbOK],0)
else
begin
r:=ListView1.Items.IndexOf(ListView1.ItemFocused)+1;{r is the index of
an array I use to get the line number in my richedit}
RawData.SetFocus;
s:=RawData.Lines[RCUN^[r].First_Rec-1]; {s is the line number in my
richedit}
z:=RawData.GetTextLen;
i:=RawData.FindText(s,0,z,[stMatchcase]);
if i=-1 then MessageDlg('New Record',MtInformation,[mbOK],0)
else RawData.SelStart:=i;
end;
end;
with richedit1 do begin
selstart := perform( em_lineindex, linenumber, 0 );
perform( em_scrollcaret, 0, 0 );
end;
The EM_LINEINDEX message returns the character index of the first character on
a given line, assigning that to selstart moves the caret to that position. The
control will only automatically scroll the caret into view if it has the focus,
thus the EM_SCROLLCARET.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
>Thanx, but my problem is that I have(!!!) the correct line number but I
>cannot move the cursor to this line.
>E.g.: There is a long text in the Memo/RichEdit, the cursor is in the last
>line and the required line is not visible. How to move the cursor and make
>the invisible line visible???
Try this...
RichEdit.SelStart := Perform(EM_LINEINDEX, CurrentLine, 0);
Perform(EM_SCROLLCARET, 0, 0);
I hope it works... <g>
If not, it's a simple fix.
John McTaggart
it works. But have a look at John McTaggart's and Peter Below's advices.
It's better ;)
Henry Clarius schrieb in Nachricht <3767DB9C...@epa.gov>...
>> I try to go to a specific line in a TMemo or TRichEdit but I don't know
how
>> it works. In TRichEdit I can use the FindText-method but I don't know the
>> text in the line, I only know the number of the line.
>> Can anybody help me???
>> I'm using D4 Prof. UpdatePack 3
>>
>> Thanks.
>
but one question: why do you use the second Perform(EM_SCROLLCARET, 0, 0)? I
tried it without and it works great.
Lars
Lars
Lars schrieb in Nachricht <7ka8b5$on...@forums.borland.com>...