Solved

how do i display which line the user .. ?

Posted on 1998-02-13
9
137 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

912 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

25 Experts available now in Live!

Get 1:1 Help Now