Solved

how do i display which line the user .. ?

Posted on 1998-02-13
9
140 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 212
Delphi - replicating a form 8 90
Delphi: ForceDirectory plain function 7 48
Delphi Yen format 3 58
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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