Force persistent underscores in MainMenu, like Word has.

Posted on 2009-12-17
Last Modified: 2012-05-08

I have received from my previous question an url about how to force
underscores in the MainMenu.  This is the link:

I have read it, and came to the conclussion that I have set this procedure below to every menu-item I got!!!

procedure TMainForm.AdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
 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;

So I have 20 menu-items, so I have to add 20 times AdvancedDrawItem-procedure.
Isn't there a better way?

Question by:peterkiers
    LVL 22

    Expert Comment

    by:Ferruccio Accalai
    mmm, if you could replace your TMainmenu with a TJvMainMenu you shoul solve it without using any AdvancedDrawItem procedure, as TJvMainMenu already shows shortcuts directly without pressing any alt key (using of course the '&' in the caption)
    LVL 1

    Author Comment

    Ok, where can I find this component?
    LVL 22

    Accepted Solution

    It's in JVCL library, but if you don't have it already installed maybe is not so convenient to install the whole library just to use that component.

    First give a try to this, reported at this link
    LVL 1

    Author Comment

    Thnx, Peter Kiers.

    500 points are comming to you...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    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…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now