Solved

how do i display which line the user .. ?

Posted on 1998-02-13
9
141 Views
Last Modified: 2010-04-04
how do i display which line , row and column
the cursor is on and where
the selected text is found after the user uses the find dialog to find the text in the MDI child form?
0
Comment
Question by:superboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1359186
In a memo field, or reach-edit field, or what?
0
 

Author Comment

by:superboy
ID: 1359187
i need to do this in the memo which is in the MDI Child..
0
 
LVL 5

Accepted Solution

by:
inter earned 10 total points
ID: 1359188

The current line for Memo1 can be found by:(for both selected and non selected- note that this returns the begining line of the selected text if present)

LineNo := SendMessage( Memo1.Handle, EM_LINEFROMCHAR, -1, 0);

Igor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:superboy
ID: 1359189
how abt the row and col in the memo?
0
 
LVL 5

Expert Comment

by:inter
ID: 1359190
Ok, now:

The current character from the begining of the memo can be found by:

 SendMessage(HeaderEdit.Handle, EM_GETSEL,LongInt(@st),LongInt(@en));

here st(DWord) gives the starting position of the selection and en(DWord) gives the end position of selection. If there is no selection st is equal to en.

So the complete procedure to find the coordinates is

procedure GetRowCol(M : TMemo; var Row, Col:Integer);
var
 st,en : Dword;
begin
  SendMessage(HeaderEdit.Handle, EM_GETSEL,LongInt(@st),LongInt(@en));
  Row := SendMessage( HeaderEdit.Handle, EM_LINEFROMCHAR, -1, 0);
  Col := st - SendMessage( HeaderEdit.Handle, EM_LINEINDEX, Row, 0);
end;

Here row and col are 0 based
Is that OK?
Igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1359191
Sorry the HeaderEdit in procedure must be replaced with M.

Igor
0
 

Author Comment

by:superboy
ID: 1359192
is there a way to correctly show the rows and colums
as my memo is set to alignment center which shows the
cursor to be center...
after u do a align left, right, the column , row does not change....is there a way to change the rows and column shown
to where the cursor is everytime u do align left, right, etc?
0
 
LVL 5

Expert Comment

by:inter
ID: 1359193
This is a bit problematic my friend! Since windows makes the alignement it does this with pixel accuracy which means you actually may at column 4.5 for example. And since in most of the FONTS the characters have different width what you seek is not possible. Here the normal DOS editor (character based) logic does not work. However we may roughly compute it for taAlignCenter and taAlignRight IF you choose the fixed width font such as 'Terminal' font.

for taAlignCenter
// we find the empty space width of current row which is found as
// previously
Xwidth := (Memo1.ClientWidth - TextWidth(Memo1.Lines[Row])) div 2;
NewCol := Round(Col + XWidth / Memo1.Font.Size);

for taAlignRight

Xwidth := (Memo1.ClientWidth - TextWidth(Memo1.Lines[Row]));
NewCol := Round(Col + XWidth / Memo1.Font.Size);

I want to note again that this is only true for FIXED width fonts, with variable size fonts it is not possible!
Igor


0
 

Author Comment

by:superboy
ID: 1359194
thanx..i understand yr point..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question