Solved

Status Bar with Line Count

Posted on 1998-03-09
16
345 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wininet read php file from internet issue 6 81
Intraweb download file link ? 1 108
Find and Replace Stream with 0s 8 56
Multi-layered image in FireMonkey 9 15
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

17 Experts available now in Live!

Get 1:1 Help Now