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 1000247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:28:57+00:00 2026-05-16T07:28:57+00:00

I have been trying to register 3 hotkeys. I followed this example (or this

  • 0

I have been trying to register 3 hotkeys.
I followed this example (or this).

The code is working IF I register a single hotkey.
However, if I try to register 3 hotkeys, only the last registered one is working:

procedure TFrmSettings.FormCreate;
begin
 atomN:= GlobalAddAtom(pchar('atomN'));    
 atomT:= GlobalAddAtom(pchar('atomT'));
 atomH:= GlobalAddAtom(pchar('atomH'));
end;


procedure TFrmSettings.test1;
begin
 RegisterHotShortCut(Handle, atomN, hotN.HotKey);        // first registered 
 RegisterHotShortCut(Handle, atomH, hotH.HotKey);        // second registered 
 RegisterHotShortCut(Handle, atomT, hotT.HotKey);        // third - only this works
end;

RegisterHotShortCut is declared in the web page above mentioned.

function RegisterHotShortCut(const h:THandle; const Atom: integer; const ShortCut: TShortCut): Boolean;
VAR
  key : Word;
  Shift: TShiftState;
begin
  Windows.UnregisterHotKey(h, Atom);                                                    
  ShortCutToKey(ShortCut, key, shift);
  Result:= RegisterHotKey(h, Atom, ShiftState2Modifier(Shift), key);
end;

If in the code above, I comment the last line, then the previous hotkey (hotH) is working. This means that I declared everything right but the last hotkey takes control over (unregisters) the others.

Or saying it in other way, pressing the key combination for the for first registered shortcuts do not make the program to enter the TFrmSettings.HotyKeyMsg(VAR msg: TMessage) procedure.

Any hints?
Thanks.


Edit1:

  1. There are simple snippets that seems to work for other but I really need to let the user to change the shortcut so I need the ShortCutToKey procedure.

  2. I should declare an atom for each global shortcut. Right?


Edit2:
SOLVED
The above code fails ONLY if I use the “GlobalAddAtom” function. If instead of atoms I use just numbers 1, 2 and 3, the code works. If I use 4,5,6, the code fails again.
Problem (semi) solved.

  • 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-16T07:28:58+00:00Added an answer on May 16, 2026 at 7:28 am

    SOLVED The above code fails ONLY if I use the “GlobalAddAtom” function. If instead of atoms I use just numbers 1, 2 and 3, the code works. If I use 4,5,6, the code fails again. Problem (semi) solved.

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

Sidebar

Related Questions

I have been trying to get a basic reorderlist working following this guide ->
I have been trying to make a cash register like code, where the user
In my example code below, you can see that I have been trying to
I have been trying to find a code snippet to do an unsharp mask
I have been trying to find out why the following lines of code do
I have been trying to replicate the buffer overflow example3 from this article aleph
I am sure this has been asked already, but I have been trying all
I have been trying to understand segmented memory and I came across this statement
I have been trying to figure out how all this validation works, but I
I have been trying to make a simple app with 3 fields like this:

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.