DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Select a whole line in TSynEdit, TMemo or TRichEdit

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
m_b
Member


Joined: 23 Jun 2004
Posts: 15

PostPosted: 04/08/04 14:03    Post subject: Select a whole line in TSynEdit, TMemo or TRichEdit Reply with quote

How can I select a whole line in TSynEdit, TMemo or TRichEdit if I've got it's index?
I know that I can use the SelStart and SelLength, but when I do that if the line is longer than the component width - the component scrolls to the end of the line, and this is really annoying to the user - he has to scroll back, what I want is to select the whole line without scrolling to the end of it. So, any suggestions???

m_b
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 412
Location: Tehran, Iran

PostPosted: 04/08/04 15:09    Post subject: Reply with quote

The following code may help you.

Code:
function SelectLine(EditHandle: THandle; LineIndex: Integer; CaretInView: Boolean): Boolean;
var
  LineStart: Integer;
  LineLength: Integer;
begin
  Result := False;
  LineStart := SendMessage(EditHandle, EM_LINEINDEX, LineIndex, 0);
  if LineStart >= 0 then
  begin
    LineLength := SendMessage(EditHandle, EM_LINELENGTH, LineStart, 0);
    SendMessage(EditHandle, EM_SETSEL, LineStart, LineStart + LineLength);
    if CaretInView then SendMessage(EditHandle, EM_SCROLLCARET, 0, 0);
    Result := True;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if not SelectLine(Memo1.Handle, SpinEdit1.Value, False) then
    ShowMessage('Line index out of bounds');
end;
Back to top
View user's profile Send e-mail Visit poster's website
m_b
Member


Joined: 23 Jun 2004
Posts: 15

PostPosted: 05/08/04 11:07    Post subject: Reply with quote

I'm sorry Kambiz, but this function does nothing, I've tried it with SynEdit and Memo, and nothing gets selected... Is there another way?
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 412
Location: Tehran, Iran

PostPosted: 05/08/04 11:34    Post subject: Reply with quote

I have no idea about SynEdit, but I'm sure the function works for TMemo and TRichEdit.

Maybe the HideSelection property of the memo is True, and you don't see the selection.
Back to top
View user's profile Send e-mail Visit poster's website
m_b
Member


Joined: 23 Jun 2004
Posts: 15

PostPosted: 05/08/04 16:18    Post subject: Reply with quote

You know, that may be possible, I'll check that and let you know if it worked...
Back to top
View user's profile
m_b
Member


Joined: 23 Jun 2004
Posts: 15

PostPosted: 08/08/04 14:35    Post subject: Reply with quote

Yep, it works with memo & richedit, but not in synedit... Does anyone know how to get it to work with synedit?
Back to top
View user's profile
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group