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

  • Home
  • SEARCH
  • 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 7817087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:06:51+00:00 2026-06-02T06:06:51+00:00

I have a combobox with items – hotkeys. I want to associate each one

  • 0

I have a combobox with items – hotkeys. I want to associate each one to a Win32 hotkey, e.g. F2 to VK_F2 and then call that one with RegisterHotkey. What’s the best way to do this? I looked up stuff and perhaps hexadecimal values could help, but it doesn’t say how to use them. Thanks.

I’m sorry I couldn’t provide more information but I don’t know what else should I include :/

  • 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-06-02T06:06:53+00:00Added an answer on June 2, 2026 at 6:06 am

    You can use TextToShortCut, and then decode the returned TShortCut into the required values for RegisterHotKey:

    var
      Shortcut: TShortCut;
      Flags: Cardinal;
      Key  : Word;
      Shift : TShiftState;
    begin
      ShortCut := TextToShortCut(ComboBox1.Items[ComboBox1.ItemIndex]);
      Flags := 0;
      Key   := 0;
      Shift  := [];
      ShortCutToKey(Shortcut, Key, Shift);
      if ssCtrl in Shift then
        Flags := Flags or MOD_CONTROL;
      if ssShift in Shift then
        Flags := Flags or MOD_SHIFT;
      if ssAlt in Shift then
        Flags := Flags or MOD_ALT;
    
      // You should check the return value of RegisterHotKey - it returns
      // a BOOL indicating success or failure. Omitted because your 
      // question isn't about using RegisterHotKey.
      RegisterHotKey(Application.Handle, YourHotKeyID, Flags, Key );
    end;
    

    TextToShortCut and ShortCutToKey are both defined in the Menus unit.

    YourHotKeyID is a value between $0000-$BFFF you define that will be passed to your app in the wParam when you receive the WM_HOTKEY message.

    With all that being said, you should reconsider your choice of UI controls. If you use a THotKey, the user can just press the key combination they want to use (instead of scrolling through a list). You can then use the THotKey.HotKey in place of the ShortCut variable in the sample code (you can pass it directly to ShortCutToKey, and eliminate the ShortCut variable entirely):

    ShortCutToKey(HotKey1.HotKey, Key, Shift);
    // ... remainder of code
    

    And, in anticipation of your soon-to-come comment :), how to catch and handle the WM_HOTKEY message and how to handle multiple hotkeys you have registered should be a new question. This one was specifically about a combobox and a hotkey; how to handle the hotkey being pressed is totally different.

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

Sidebar

Related Questions

I want to have a select-only ComboBox that provides a list of items for
I have a combobox with about 20 items. I want to associate up to
I have a WPF app that has a combobox with lookup items. The combobox
(I'm using Cairngorm) I have a combobox that displays items form an XMLListCollection that's
I want to select combobox items by their string value but I have a
I have a user control that contains a combobox. I want to be able
I have a combobox that I populate like this: this.reqTypeInput.Items.Add(new RequestType(Label 1, Value1)); this.reqTypeInput.Items.Add(new
I have stored the indexes of comboBox items in to array. Now when I
I have a combobox from which i need to programmatically disable items depending on
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items

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.