Solved

Status Bar with Line Count

Posted on 1998-03-09
16
344 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

18 Experts available now in Live!

Get 1:1 Help Now