Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Pascal
Expertise: Beginner
Aug 27, 1998

Putting Hints in Status Bar

Question:
I am using the application.onhint example from the Delphi help files to put all hints in my status bar. It works on all but one form. I'm using the Client Server version of Delphi 3.

Thanks in advance.

Neil Griffiths
Junior Developer, Information Solution LTD
Ireland

Answer:
I'll answer the question so long as you send me a couple of pints of Harp's. Never mind...

This solution could be as simple as making sure that your status bar's (if you're using TStatusBar) SimpleText property is set to true. Check this first. Then check to see if you're doing the text assignment properly. In any case, let's take a look at some theory, shall we?

You have to remember that methods can be reassigned as long as the "replacement" procedures have the _exact_ same declaration structure as the method. The reason this works is because events are simply method pointer variables that don't represent anything but a pointer to a type of procedure. For instance, OnHint will be defined as:

property OnHint : TNotifyEvent;
where TNotifyEvent = procedure(Sender : TObject) of object; What this boils down to is that as long as a procedure fits the required declaration structure of a method, you can reassign the method. But as I said above, it has to be exact.

Let's look at some code that I use for my applications:

procedure TForm1.Create(Sender : TObject);
begin
  Application.OnHint := ShowHint; //re-assign
end;

procedure TForm1.ShowHint(Sender : TObject);
begin
  StatusBar1.SimpleText := Application.Hint;
end;
This is pretty straight-forward stuff. So as long as you follow the example above, you shouldn't have any problems.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date