?
Solved

Accessing Shortcut Key

Posted on 2005-05-16
4
Medium Priority
?
596 Views
Last Modified: 2010-05-18
How can I access the Shortcut Key of a menu item in Delphi 5.0?
0
Comment
Question by:fh2
  • 3
4 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 14011965
Do you mean how can you assign a shortcut key to a menu item?
There is a property called ShortCut for every menu item which you can assign.

or do you mean setting the caption of a menu item to include a shortcut key?
You can set the caption to be something like &File which will display File with the F underlined just like any normal window shortcut.
Then just do the usual menu selection by pressing ALT and then all the shortcut underlined letters until you get to the item you want.
0
 

Author Comment

by:fh2
ID: 14012026
How can I access the event of a shortcut key? (When a user uses a shortcut key to access a menu item)
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 1000 total points
ID: 14012090
ah ok..

The shortcuts are for the application in general rather than each menu item.
Maybe something like this. You just need to override the main forms OnShortCut event I think.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    procedure FormCreate(Sender: TObject);

  private
    procedure MyShortcut(var Msg: TWMKey; var Handled: Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.OnShortCut := MyShortcut;
end;

procedure TForm1.MyShortcut(var Msg: TWMKey; var Handled: Boolean);
begin
  // write your code here

  // tell windows to continue
  Handled := True;
end;

end.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 14012102
Take a look at the packed record structure for TWMKey to gather information as to the shortcut itself.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

809 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