Solved

how do i display which line the user .. ?

Posted on 1998-02-13
9
136 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
  • 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
 

Author Comment

by:superboy
ID: 1359189
how abt the row and col in the memo?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now