Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how do i display which line the user .. ?

Posted on 1998-02-13
9
Medium Priority
?
144 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 40 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
Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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