×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how do you underscore file menu shortcuts?

how do you underscore file menu shortcuts?

how do you underscore file menu shortcuts?

(OP)

How do you show up the underscore beneath the letter key that activates a file menu item?
I notice in my app (and in Delphi interestingly), I only see the underscore once I have pressed ALT, whereas in the likes of Word, Firefox and many others, they are there permanently.

I've used the ampersand in the caption to set the ALT+key to activate them.
 

Steve (Delphi 2007 & XP)

RE: how do you underscore file menu shortcuts?

I think the reason they created that functionality is that windows will determine a unique letter at runtime for you to press in the event that your menus are dynamic.

In my D2006 the menu has a property called AutoHotkeys which governs the assignment.  It doesn't talk about the persistence.

RE: how do you underscore file menu shortcuts?

You mean the underscore that appears on most typical applications in a persistent way?  For a caption of an actionable control (menu item, button, checkbox, radiobox, etc), all you need to do is type a & before the letter you want, and it will make it into a hotkey for the app.

For example, most apps tend to have a "File menu" option.  To hotkey the F, you enter the menu item caption as "&File", and then the F will be underscored.  When the app runs, pressing ALT+F will activate that particular option.

----------
Measurement is not management.

RE: how do you underscore file menu shortcuts?

(OP)

Yes I mean that underscore, and I have the ampersand set, like you say, for example, &File, and press ALT and F and it activates the File menu.
However, what I mean is, for example, while I'm typing this in Firefox up on the Filefox menu, the F of File is showing an underscore, as is the E of Edit etc, without me pressing ALT.

But in my app, while it is running none of the menu items are showing the underscore.
If I press ALT, then sure enough, File is highlighted and all the underscores appear.

What I'd like is the underscores to show without pressing ALT, so you can see what the keypress should be before pressing ALT.

Steve (Delphi 2007 & XP)

RE: how do you underscore file menu shortcuts?

Quote:


However, what I mean is, for example, while I'm typing this in Firefox up on the Filefox menu, the F of File is showing an underscore, as is the E of Edit etc, without me pressing ALT.

I really have no idea.  The underscores are always persistent for me, both within Delphi (TD2006) and within any apps that I create.  That seems to be default since I know I haven't touched any setting to change that.

Speaking of which, is there some setting within the IDE that you might have changed?

----------
Measurement is not management.

RE: how do you underscore file menu shortcuts?

(OP)

I've not changed any settings in Delphi, certainly not knowingly anyway!

Looking at more apps on this PC, I note that Word also has the persistent underscores, but Windows and Internet Explorer don't, nor does Notepad++ or Notepad.

I'm thinking it might be a windows setting, and that Firefox and Word have them permanently programmed in?
 

Steve (Delphi 2007 & XP)

RE: how do you underscore file menu shortcuts?

Okay I found out:

Quote:


I'm thinking it might be a windows setting, and that Firefox and Word have them permanently programmed in?

This is indeed correct to a point.  This is an XP eye candy setting, which is consistent for the menus on anything programmed with the XP style menu systems.

Right click on the Desktop, then click properties.  Select the appearance tab, and click the Effects button.  Uncheck the last option: "Hide underlined letters...until I
press the Alt key" and you should get something consistent with what you are looking for.

----------
Measurement is not management.

RE: how do you underscore file menu shortcuts?

(OP)

Cool, yes that's exactly the effect I want, thanks.

But...I'm wondering if I can force that effect, like Firefox and Word does, without the user needing to make the setting?

Is it for example possible to Set the menu captions to include one character of underlined text, which would simulate the effect?

 

Steve (Delphi 2007 & XP)

RE: how do you underscore file menu shortcuts?

Hi Steve you can force this behaviour:

point the OnAdvancedDrawItem method of each menu item to this method:

CODE

procedure TFrm_main.AdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
begin
 if odnoAccel in State then
  State := State - [odnoAccel];
 TMenuItem(Sender).OnAdvancedDrawItem := nil;
 DrawMenuItem(TMenuItem(Sender), ACanvas, ARect, State);
 TMenuItem(Sender).OnAdvancedDrawItem :=  AdvancedDrawItem;
end;


Cheers,
Daddy

-----------------------------------------------------
 What You See Is What You Get
Never underestimate tha powah of tha google!

RE: how do you underscore file menu shortcuts?

(OP)
I've pasted the proc into my app:

CODE

procedure TMainForm.AdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
begin
 if odnoAccel in State then      // this proc to force underscore on menu items
  State := State - [odnoAccel];
 TMenuItem(Sender).OnAdvancedDrawItem := nil;
 DrawMenuItem(TMenuItem(Sender), ACanvas, ARect, State);
 TMenuItem(Sender).OnAdvancedDrawItem :=  AdvancedDrawItem;
end;

And set all my menu items as in the pic, but no joy?
 

Steve (Delphi 2007 & XP)

RE: how do you underscore file menu shortcuts?

forgot to say:

you must set the Ownerdraw property of the main menu to True.

/Daddy

-----------------------------------------------------
 What You See Is What You Get
Never underestimate tha powah of tha google!

RE: how do you underscore file menu shortcuts?

(OP)

Cool, that's great many thanks again!
 

Steve (Delphi 2007 & XP)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close