devxlogo

Putting Hints in Status Bar

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-assignend;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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist