Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

how to disable alt+tab ,alt+f4

Posted on 2000-03-04
8
Medium Priority
?
1,197 Views
Last Modified: 2013-11-20
how to disable alt+tab ,alt+f4
0
Comment
Question by:zhangyunchao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:RAVID
ID: 2584687
Hi,

In the resource select the Acceslerator option and add a new accelerator with the alt option ticked and the key as VK_F4 and give some ID say ID_MY_ALY_F4 now through class wizard map the command for this ID and add the code u want.
Try similar way for alt+tab.

Hope this helps
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2586769
Hi,

RAVID: I think your solution only works for ALT-F4, not for ALT-TAB.

zhangyunchao, to disable ALT-TAB you can register ALT-TAB as a hotkey of your application using RegisterHotKey() like this:

CMainFrame::Create(...)
{
 ...
 if( !RegisterHotKey( m_hWnd, 1, MOD_ALT, VK_TAB ) )
 {
  TRACE( "Error occured with RegisterHotKey()\n", GetLastError() );
 }
 ...
}

hopt that helps,

ZOPPO
0
 

Accepted Solution

by:
cclain earned 400 total points
ID: 2587074
Try this very usefull function which disable CTRL+ALT+DEL and ALT+TAB:

int nOldVal;
SystemParametersInfo (SPI_SCREENSAVERRUNNING, 1, &nOldVal, 0);//Turns keys off

to turn keys on, simply call:
SystemParametersInfo (SPI_SCREENSAVERRUNNING, 0, &nOldVal, 0);

Alt+f4 can be disabled in your application. For exemple, in a dialog box, you need to override
OnOk and OnCancel functions.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 31

Expert Comment

by:Zoppo
ID: 2587094
Hi cclain,

your suggestion only works with Win9x, not with WinNT, so I think you should not post this as answer unless you know zhangyunchao only needs it for Win9x

ZOPPO
0
 

Expert Comment

by:cclain
ID: 2587239
You're right, but I'm new here and I think I don't understand exactly the comment-answer rules.
I thought comments were supposed to comment answers and to ask (zhangyunchao) questions. Moreover, I've seen a lot of answers in the comment section, so how these people get experts points ? Eventualy zhangyunchao can reject my answer, and you still can add comments, so I don't prevent someone from getting points...

Anyway my suggestion only works with Win9x. I would use a hook with WinNT by calling SetWindowsHook
Here's a sample that disable Alt+Tab

LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam){
    // By returning a non-zero value from the hook procedure, the
    // message does not get passed to the target window
    KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
    BOOL bControlKeyDown = 0;    switch (nCode)    {        case HC_ACTION:
        {            // Check to see if the CTRL key is pressed
            bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
            // Disable ALT+TAB
            if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN)
                return 1;            break;        }        default:
            break;    }    return CallNextHookEx (hHook, nCode, wParam, lParam);
}
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2587256
Yes, of course a global hook would be a way too, but I think it's quite a overhead ...

ZOPPO
0
 

Expert Comment

by:cclain
ID: 2587284
I think we really need more explanations. Only zhangyunchao knows...
0
 
LVL 1

Author Comment

by:zhangyunchao
ID: 2656638
but ZOPPO is right too.

0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

647 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