[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Status Bar with Line Count

Posted on 1998-03-09
16
Medium Priority
?
358 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 40 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

656 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