Solved

Status Bar with Line Count

Posted on 1998-03-09
16
349 Views
Last Modified: 2010-04-06
Hi,
    i'm writing a LaTeX graphical editor and it would be really helpful if it had a status bar at the bottom with the line number at which the cursor is located. Either this or a small window on the toolbar with the line count. Is there an easy way to do this?
Cheers, Nik
0
Comment
Question by:NikWhit
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360307
Use TStatusBar component. Do you use TCanvas fo drawing?
0
 
LVL 4

Expert Comment

by:d003303
ID: 1360308
Yo,
if you are using Delphi 2 or 3 you can use the TStatusBar object and split it with the Panels property. Play around with the sizes and get the layout you need.

Slash/d003303
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360309
That's fine for the status bar, but how do I get the current line number from the TMemo object?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:NikWhit
ID: 1360310
Sorry, correction. I don't seem to have a TStatusBar component available. Could I use a TPanel object? If so, how do I make a small window on it to disply the linenumber, and how do I get the  line number from the TMemo component?
Seeing as I'm messing you around I'll stick the points up.
Cheers, Nik.

0
 

Expert Comment

by:wtamviset
ID: 1360311
You can find the current line number  of memo edit from Perform Method.
CurLine :=  perform(EM_LINEFROMCHAR, SelStart, 0) + 1;

If you need to show the Curline in status bar you can write code  
in Event  OnClick and OnKeyUP of the Memo.
This is example

 Procedure Form1.Memo1Onclick(Sender :TObject);
 Begin
     CurLine :=  Memo1.perform(EM_LINEFROMCHAR, SelStart, 0) + 1;
     Panel1.Caption := Format('Line: %d ',CurLine);
 End;

and  do same in OnKeyUP event

0
 

Expert Comment

by:wtamviset
ID: 1360312
Edit my example Code:
I think you know what I wrong. I forget VAR

Procedure Form1.Memo1Onclick(Sender :TObject);
Var  CurLine
Begin
       CurLine :=  Memo1.perform(EM_LINEFROMCHAR, Memo1.SelStart, 0) + 1;
       Panel1.Caption := Format('Line: %d ',CurLine);
End;
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360313
Sorry, Wtamviset,
     When I try and run the code, it gives me a syntax error on the line :  CurLine :=  Memo1.perform....
     TMemo does not have a perform method on my version of Delphi. Any suggestions?
     Cheers, Nik.

0
 

Expert Comment

by:wtamviset
ID: 1360314
What you Delphi version ?
In Delphi 2/3  TMemo have  the Perform method . Try to see your delphi help. You will see Perform . Sure.!!
The Error syntax mean  there are some wrong code . Not mean Tmemo does hot have perform method.  Please check your code careful!.

VAR  CurLine :Integer;
CurLine :=  Memo1.perform(EM_LINEFROMCHAR, Memo1.SelStart, 0) + 1;

See Memo1.Selstart  and CurLine is Integer;
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360315
I'm afraid I only have Delphi  version 1.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360316
Yo NikWhit, try it this way :

TMemo Row & Col position

 Row := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, Memo1.SelStart, 0);
 Col := Memo1.SelStart - SendMessage(Memo1.Handle, EM_LINEINDEX, Row, 0);

 The returned values are zero-based.

Regards, Zif.


0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360317
Yo Zif,
    When I try to run your code, it gives me an unknown identifier  at  EM_LINEFROMCHAR. Is there any reason for this?
Cheers...

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360318
? I tried it in D1 & D2, in both versions it worked...

Did you do this : 1. Put a memo on form
                         2. Put button on form
                         3. Put in button click event the code?

Which version are you using?
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360319
Sorry, Zif, my mistake,
    I hadn't included messages in the uses statement. Sorry!
Stick in an answer and you'll get the points...

0
 
LVL 8

Accepted Solution

by:
ZifNab earned 10 total points
ID: 1360320
Hi NikWhit

Try it this way :

       TMemo Row & Col position

        Row := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, Memo1.SelStart, 0);
        Col := Memo1.SelStart - SendMessage(Memo1.Handle, EM_LINEINDEX, Row, 0);

        The returned values are zero-based.

  Don't forget to assign the needed units in the uses clausule.

 Regards, Zif.

PS. Can I see some day the endresult of your editor?
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1360321
ZifNab,
    Cheers for the help. You can have a copy of it when I've finished it... Should be done in about 3 / 4 weeks. It's not going to be massively functional, but hopefully useful to some. If you drop me your e-mail address, I'll mail you a copy.
Nik
nw4696@bris.ac.uk

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360322
Hi Nik, thanks! Tom.Deprez@uz.kuleuven.ac.be

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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