Solved

Status Bar with Line Count

Posted on 1998-03-09
16
351 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
[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
  • 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
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!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

742 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