• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Alt Key - & Menu Items

I notice that by default (windows behavior), a menu does not have its menu items (first Character) underlined for the Alt-F hot keys, UNTIL you press the Alt button.

When you move away from your application, to another application, the underlines go away, and when you move back, you have to hit the ALT button again.

Is there a flag, or winAPI call or something that can change this behavior - to keep it on at all times?

Or would i have to explicitly call a ALT Key press in my forms OnActivate  - if so, what is the best code to do this?

Thanks
0
geocoins-software
Asked:
geocoins-software
  • 5
  • 3
1 Solution
 
rohypnolCommented:
They shortcuts may not display by default in XP but they still work (Alt+F still opens File if the caption of the menu item is &File). As you probably noticed, to make a key shortcut for a menu item, prefix that character with the & sign, so your menu items should look like: &File, &Edit, &Window, &Save, Save &as...
0
 
ziolkoCommented:
use SystemParametersInfo() with SPI_GETMENUUNDERLINES

ziolko.
0
 
ziolkoCommented:
of course SPI_SETMENUUNDERLINES

ziolko.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ziolkoCommented:
this should do the trick:

type
  TBOOL = record
    fBoolean: Boolean;
    FDummy: array[0..2] of Byte;
  end;

procedure TForm1.Button9Click(Sender: TObject);
var setting: TBOOL;
begin
  SystemParametersInfo(SPI_GETMENUUNDERLINES, 0, @setting, 0);
  Memo1.Lines.Add(BoolToStr(setting.fBoolean, True));
  setting.fBoolean := True; //False
  SystemParametersInfo(SPI_SETMENUUNDERLINES, 0, Pointer(setting), 0);
end;

True means that it will be always underlined, False means only when Ctrl key is pressed.

ziolko.
0
 
geocoins-softwareAuthor Commented:
ziolko,  what is the full call

 SystemParametersInfo(SPI_SETMENUUNDERLINES, ?,?,?)

Thanks
0
 
geocoins-softwareAuthor Commented:
Someone (Norrit) on DelphiPages just explained to me:

"This is default windows behaviour...

Right Click the desktop and choose [properties] [appearance] [Effects]
This feature is checked by default, which explains your behaviour..."


however, I will awards the points to first person who shows how to do this via code...

thanks
0
 
ziolkoCommented:
>>however, I will awards the points to first person who shows how to do this via code...
see my last comment, however I've noticed that change takes affect after first press of Ctrl button

ziolko.
0
 
ziolkoCommented:
and if you want make it system wide you have to use SPIF_UPDATEINIFILE or SPIF_SENDCHANGE instead of 0 as last param

ziolko.
0
 
geocoins-softwareAuthor Commented:
THANKS!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now