Solved

MainMenu + hint

Posted on 2006-07-18
3
464 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

19 Experts available now in Live!

Get 1:1 Help Now