Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6225871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:55:26+00:00 2026-05-24T08:55:26+00:00

With default Windows settings, accelerator keys are not meant to be shown on dialogs

  • 0

With default Windows settings, accelerator keys are not meant to be shown on dialogs until the user presses the ALT key.

Delphi’s TLabel control does not obey this convention, as shown below:

Although both label and check box have an accelerator key specified, the check box correctly hides it, but the label does not. Of course, when ALT is pressed, the accelerator shows for the check box, but it’s the behaviour prior to that which is incorrect.

My understanding of why this happens is that the VCL code that implements this behaviour is contained in TWinControl, for example the UpdateUIState method, and relies on sending the underlying windowed control a WM_CHANGEUISTATE message. Since TLabel is not windowed, it misses out on this handling.

Can anybody suggest a way to achieve the desired behaviour for non-windowed controls?

Update 1

I’ve just discovered that group boxes and radio groups don’t respond to UI state either.

Update 2

QC#97044.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:55:27+00:00Added an answer on May 24, 2026 at 8:55 am

    I think I’ve worked out a way of handling it.

    function HideAccelFlag(Control: TControl): Integer;
    begin
      //ask the top level window about its UI state
      while Assigned(Control.Parent) do begin
        Control := Control.Parent;
      end;
      if (Control.Perform(WM_QUERYUISTATE, 0, 0) and UISF_HIDEACCEL)=UISF_HIDEACCEL then begin
        Result := DT_HIDEPREFIX;
      end else begin
        Result := 0;
      end;
    end;
    
    type
      TUIStateAwareLabel = class(TLabel)
      protected
        procedure DoDrawText(var Rect: TRect; Flags: Longint); override;
      end;
    
    procedure TUIStateAwareLabel.DoDrawText(var Rect: TRect; Flags: Integer);
    begin
      if ShowAccelChar then begin
        Flags := Flags or HideAccelFlag(Self);
      end;
      inherited;
    end;
    

    I make sure that I always create TUIStateAwareLabel rather than TLabel by hooking the form streaming mechanism with TReader.OnFindComponentClass.

    Dealing with TCustomGroupBox descendents is more messy. For them I resorted to copying the source code of TCustomGroupBox.Paint into my descendent and making use of HideAccelFlag again.

    Next task is to write it up as a QC report.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows forms application that contains per-user settings. I'm using Properties.Settings.Default.Upgrade() to
By default on Windows Git places global .gitconfig in c:\documents and settings\user\ How can
I use _vimrc to configure my vim 7.2 (windows) default settings. One setting set
By default in windows application setting are saved in this directory: %USERPROFILE%\Local Settings\Application Data\<Company
I'm using wxWidgets 2.8.9, built with the default settings under Windows XP, VC9. And
By default Windows (XP) shows the underlined hotkeys only, when ALT is pressed. This
I have a Windows (not Web) NET 1.1 app which can accept the settings
By default netbeans stores it's settings in a directory called .netbeans under the user's
It seems to use default color from Windows settings which is blue by default.
What approach do you recommend for persisting user settings in a WPF windows (desktop)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.