Solved

MainMenu + hint

Posted on 2006-07-18
3
478 Views
Last Modified: 2010-04-05
Hi,

What's the best way to display messages in the statusbar
when the user goes thru the menu-items of the MainMenu?

I have allready made a procedure for the Toolbar - buttons, but I don't
know how for the MainMenu-items!

 private
    { Private declarations }
    procedure MyHint(Sender: TObject);

(*-----------------------------------------------*)
procedure TMainForm.MyHint(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := Application.Hint;
end;
(*-----------------------------------------------*)
procedure TMainForm.FormShow(Sender: TObject);
begin
  Application.OnHint := MyHint;
  ShowHint           := True;
  ToolButton1.Hint   := 'New|New Connection';
  ToolButton2.Hint   := 'Open|Open Connection';
  ToolButton3.Hint   := 'Save|Save current connection file';
  ToolButton4.Hint   := 'Print|Print';
  ToolButton5.Hint   := 'Copy|Copy the selection into Clipboard';
  ToolButton6.Hint   := 'Paste|Insert Clipboard contents';
end;
(*-----------------------------------------------*)


Thanks in advance...

Greetings,

Peter Kiers






0
Comment
Question by:peterkiers
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 17130341
Set the hint for each menu item, then catch the applications OnHint event, eg;

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Menus, ExtCtrls;

type
  TForm1            =  class(TForm)
    MainMenu1:      TMainMenu;
    File1:          TMenuItem;
    Test1:          TMenuItem;
    procedure       FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
     procedure      DisplayHint(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnHint:=DisplayHint;
end;

procedure TForm1.DisplayHint(Sender: TObject);
begin
 // Set whatever status control text
  Caption:=GetLongHint(Application.Hint);
end;

end.

Regards,
Russell
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 17130362
Looking at your code, you are already catching the Application's OnHint, so just set each menu items' .Hint property and you should be set

Russell
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17130400
Thanks Russell.

Peter
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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