Virtual Developer Workshop: Containerized Development with Docker

The simplest way to achieve this is to use the RegisterHotKey function. By calling this function from within your process you take precedence over the O/S. The WM_HOTKEY message that is generated by the specified key combination will be re-directed to the your processes message queue. To block the hotkey, dont process the WM_HOTKEY message that is sent to your queue. Below I have copied a constructor and destructor that demonstrate this action.

// Call the RegisterHotKey function when the application 
// is instantiated to block the ALT-TAB combination
// Note:  The m_nHotKeyID is a int which specifies the hotkey 
//        ID, the hotkey id is programmer defined
 m_nHotKeyID = 100;

 BOOL m_isKeyRegistered = RegisterHotKey(GetSafeHwnd(), m_nHotKeyID,

 ASSERT(m_isKeyRegistered != FALSE);

//lets remove the hotkey block when the application is destroyed
 BOOL m_iskeyUnregistered = UnregisterHotKey(GetSafeHwnd(), m_nHotKeyID);
 ASSERT(m_isKeyUnregistered != FALSE);
There you have it, the simplest way to block the ALT-TAB without writing a VxD.

One last thing, the hotkey block will continue as long as your application is running. When your process terminates the hotkey will return to its original functionality.


  • crash with release build

    Posted by Legacy on 12/22/2003 08:00am

    Originally posted by: Sam

    It seem that App with RegisterHotKey function will crash with release build upon second time pressing the hotkey. Who can help? Thanks!

  • API

    Posted by Legacy on 07/08/2003 07:00am

    Originally posted by: Mobeen

    I want to disable IE toolbar in my Application

  • Disabling the Alt-Tab key combination

    Posted by Legacy on 08/11/2002 07:00am

    Originally posted by: Aamod Joshi

    How to control all the KB messages

  • Does not work with Direct Input 8.0

    Posted by Legacy on 05/01/2002 07:00am

    Originally posted by: Robert


    Direct Input (DirectX 8.0) does not seem to allow ALT+TAB to be captured in the application (hotkey and global low level hook methods were tested). Allow though, the HotKey or hook does effect all of the other application in the Desktop until the application is ended.

    Any suggestions?

  • TAB Key

    Posted by Legacy on 12/24/2001 08:00am

    Originally posted by: Abhijeet Sheorey


    I am facing a serious problem in my project. I want to disable a TAB key I've written a code in PreTranslateMessage
    Function. It's Working properly but if the previous key pressed is a Shift Key and after that if a tab key is pressed it dosen't work. So how to disable a tab key.

    I want a Shift + Tab key combination in my project ( Data Entry Project ). But I don't want Tab key. Can u please help me out.

    Thanks Abhijeet.

  • How make the virus !!!!????

    Posted by Legacy on 06/28/2001 07:00am

    Originally posted by: Buggy

    Прива, я Бугги я хочу узнать как можно сделать вирус хотябы самый маленький на VC++, чтобы он записывал себя в конец какогонибудь EXE или COM файла.

    Спасибо за помощь !!!! Буг.

  • ALT+F4 and others in Win 9x

    Posted by Legacy on 03/14/2001 08:00am

    Originally posted by: J.

    I was using the command, SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, (PVOID)1, 0);
    to disable alt+esc, alt+tab and ctl+alt+del

    However, I also need to get rid of alt+F4 so the user can not close the program.

    I tried using the code posted here (altering it for F4 not Tab), but it doesn't seem to work with my SystemParametersInfo code. I can only use one or the other. I am just getting in to visual programming with a mild background in C++. Any hints, suggestions...preferably something that's not too difficult. This is for a school project, and we are told to learn Visual C++ as we go. A task that is easier said than done (at least for me).

    Yes, the RegisterHotKey did work for Alt+F4 in a Win 9x environment. It did not however, work for alt+tab.


    Posted by Legacy on 09/26/1999 07:00am

    Originally posted by: P. Kournetas

    I have used your code and it works fine...

    How can I trap and disable the following compinations:



  • How to process a WM_HOTKEY in MFC?

    Posted by Legacy on 08/14/1999 07:00am

    Originally posted by: Alvin Sia

    Instead of the existing process that Windows do when encountered ALT+TAB, I would like to do another process, say invoking a hidden application. How should I implement WM_HOTKEY keyboard event in an MFC application?

  • It does not work on DirectX based application.

    Posted by Legacy on 07/22/1999 07:00am

    Originally posted by: Kim, Hyoun Woo

    The way of using RegisterHotKey API doesn't work on DirectX based application.

    How do I make it disable ALT+TAB in DirectX based application?

    >> I've used SystemParametersInfo API also, but it's doesn't work too.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date