XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

DXGI_MWA_NO_ALT_ENTER

Last post 03-09-2008 10:00 PM by SKuRGe911X. 4 replies.
  • 05-04-2007 6:36 AM

    DXGI_MWA_NO_ALT_ENTER

    I'm not content with the default behaviour provided by DXGI when you hit alt-enter - I want to switch to a hardcoded resolution (one provided by the user, eventually) instead of picking one closest to the size of the window's client area - so I'm trying to hook alt-enter and do the switch myself.

    However, I can't see to get DXGI to stop interfering. I'm specifying DXGI_MWA_NO_ALT_ENTER when I call MakeWindowAssociation but it still enacts a full mode change when I hit alt-enter.

    Any ideas?

  • 05-04-2007 2:23 PM In reply to

    Re: DXGI_MWA_NO_ALT_ENTER

    Hello. You've discovered a bug. I've got multiple comments to try to help you workaround:

    DXGI installs a windows message hook based on these flags; but the hook doesn't respect the flags when deciding which functionality to perform.

    Another developer proposes:

    Try DXGI_MWA_NO_WINDOW_CHANGES instead. See IDXGIFactory::MakeWindowAssociation for documentation. Seems pretty good detailing issues. But, just ask if need more clarification.

    DXGI chooses the mode based on the back buffer size, not the client area. Therefore, when the app fields WM_SIZE, don’t blindly pass the sizes passed in the message to ResizeBuffers. Instead, snap the sizes to the required mode size. If the developer doesn’t like the stretch artifacts incurred when the window is resized while windowed,  then disable window resizing via the WM_SIZING message. If the developer wants to have arbitrary back buffer sizes when windowed (i.e. track the client area size), then yes, NO_WINDOW_CHANGES and a custom alt-enter handler are required.
  • 05-11-2007 12:42 AM In reply to

    Re: DXGI_MWA_NO_ALT_ENTER

    Hello,

    I did not call MakeWindowAssociation at all, but DXGI still handle Alt+Enter (even documentation says it would not).

    So, to disable Alt+Enter, I need to call MakeWindowAssociation( hWnd, DXGI_MWA_NO_WINDOW_CHANGES|DXGI_MWA_NO_ALT_ENTER). Right?

    If I have several windows do I need call it for each one? Or just first one?

    Thanks,

    Yuriy

     

  • 05-16-2007 11:52 AM In reply to

    Re: DXGI_MWA_NO_ALT_ENTER

    Seems that MakeWIndowsAssociation is automatically called by swap chain creation with a window handle. So, yes, MakeWindowAssociation( pSwapChainDesc->OutputWindow, DXGI_MWA_NO_WINDOWS_CHANGES ) should be all that is needed. Only for windows that have a swap chain associated with them.
  • 03-09-2008 10:00 PM In reply to

    Re: DXGI_MWA_NO_ALT_ENTER

    I wanted to disable alt tab by default so i did this.
    Get the DXGI Factory         HRESULT hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory) );
    Then                 pFactory->MakeWindowAssociation(Window,DXGI_MWA_NO_WINDOW_CHANGES|DXGI_MWA_NO_ALT_ENTER|DXGI_MWA_NO_PRINT_SCREEN);
    Window being your main window m_hWnd or whatever.

    Now you set a lowlevel keyboard hook.

    TaskSwitchingDisable PROC C bShowHide:BOOL
        .if bShowHide == TRUE
            .if hKeyboardHook == NULL
                push 0
                push AppInst
                push LowLevelKeyboardProc
                push WH_KEYBOARD_LL
                call SetWindowsHookExW
                mov hKeyboardHook,eax
            .endif
        .else
            .if hKeyboardHook != NULL
                push hKeyboardHook
                call UnhookWindowsHookEx
                mov hKeyboardHook,NULL
            .endif
        .endif
        mov eax,1
        ret
    TaskSwitchingDisable ENDP

    sorry for my Masm Code...

    and the hook function is something like this...

    extern "C" LRESULT __stdcall LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
        if(nCode == HC_ACTION){
            if( 
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_VOLUME_DOWN) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_VOLUME_UP)
                ){
                   
                    return 0;
            }
            if(
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode==VK_F12)) ||
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_VOLUME_MUTE)) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_MEDIA_NEXT_TRACK) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_MEDIA_PREV_TRACK) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_MEDIA_STOP) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_MEDIA_PLAY_PAUSE) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_LAUNCH_MAIL) ||
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_LAUNCH_MEDIA_SELECT)) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_LAUNCH_APP1) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_LAUNCH_APP2) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_HOME) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_FAVORITES) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_SEARCH) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_BACK) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_FORWARD) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_REFRESH) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_BROWSER_STOP) ||
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_LWIN)) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_RWIN) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_RETURN && ((LPKBDLLHOOKSTRUCT) lParam)->flags & LLKHF_ALTDOWN) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_TAB && ((LPKBDLLHOOKSTRUCT) lParam)->flags & LLKHF_ALTDOWN) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_TAB && ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0)&& ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0)) ||
                (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_ESCAPE && ((LPKBDLLHOOKSTRUCT) lParam)->flags & LLKHF_ALTDOWN) ||
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_ESCAPE) && ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0)) ||
                ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_ESCAPE) && ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0) && ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0)) || ((((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_DELETE) && ( (((LPKBDLLHOOKSTRUCT) lParam)->flags & LLKHF_ALTDOWN) != 0 )
                && ( (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0))
                        ){
                return 1;
            }
        }
        return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
    }

    Note the (((LPKBDLLHOOKSTRUCT) lParam)->vkCode == VK_RETURN && ((LPKBDLLHOOKSTRUCT) lParam)->flags & LLKHF_ALTDOWN) part. this stops it getting to the app.

    Hope this helps.
    SKuRGe911
    SKuRGe911X
Page 1 of 1 (5 items) Previous Next