CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    60

    Disable Alt + Space

    Hi,
    I want to disable the menu that pop-up's in the header when i use the alt+space bar key in .Net. Basically i dont want the menu to be listed.Is there any property for that or is there any api call to disable that. Please help me out in that. Thanks in advance.

    Vinoth

  2. #2
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Disable Alt + Space

    add the following code to the form you dont want the alt + space menu in.

    Code:
    const int WM_SYSCOMMAND = 0x0112,
        SC_KEYMENU = 0xF100;
    protected override void WndProc(ref Message m) {
        if(m.Msg == WM_SYSCOMMAND && m.WParam == (IntPtr)SC_KEYMENU) {
            return;
        }
        base.WndProc(ref m);
    }

  3. #3
    Join Date
    Oct 2006
    Posts
    123

    Thumbs up Re: Disable Alt + Space

    Quote Originally Posted by MadHatter
    add the following code to the form you dont want the alt + space menu in.

    Code:
    const int WM_SYSCOMMAND = 0x0112,
        SC_KEYMENU = 0xF100;
    protected override void WndProc(ref Message m) {
        if(m.Msg == WM_SYSCOMMAND && m.WParam == (IntPtr)SC_KEYMENU) {
            return;
        }
        base.WndProc(ref m);
    }
    thanks,but why u use 0x0112 and 0xF100 in assign variable and wat its mean ?
    and wat is the function of m.Msg and WndProc(ref m) ?
    Last edited by honeyboy_20; October 31st, 2006 at 11:14 PM.

  4. #4
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Disable Alt + Space

    they are the win32 windows messages that you're handling (defined in winuser.h).

    WndProc is the method used to handle the main message queue.

    alt + space generates the wm_syscommand / sc_keymenu notification used to pop up the window's context menu.

    by returning (not allowing base.WndProc to process the message) you stop the message from being sent / handled by the window.
    Last edited by MadHatter; November 1st, 2006 at 12:14 AM.

  5. #5
    Join Date
    Oct 2006
    Posts
    123

    Re: Disable Alt + Space

    thanks .............

  6. #6
    Join Date
    Sep 2003
    Posts
    60

    Re: Disable Alt + Space

    it worked for me, thanks a lot..... thanks once again....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured