Question

This question might show a fundamental misunderstanding of DirectX programming in Windows, but I'm having a bit of an issue I can't figure out. My program, when running in full screen, sometimes gets in a weird state and I have to force close the app (CTRL+ALT+DEL).

The problem is that when I hit CTRL+ALT+DEL, task manager appears, but I can't use the mouse; the keyboard works at first, but if I click on the Task Manager window with my mouse, it loses focus and I can no longer regain focus. The app also does not minimize itself (Windows app programming issue?)

Is it possible that my app is stealing the exclusive possession of the mouse? I am using DirectInput, but the mouse input is not handled by the app at all. Furthermore, this problem only happens when running the app fullscreen. If I run it in a Window, everything is fine.

If it matters, the tools I'm using are MS Visual Studio 12, Windows 8, and DirectX 9.

Was it helpful?

Solution

The solution to this was to unacquire all input devices and stop the rendering routines when the focus was lost from the application. I just set the app to keep track of whether or not it has focus, and to adjust the value appropriately in the Windows message pump for the appropriate messages. Specifically, I set focus to "off" when I receive the following messages:

WM_SIZE (when wParam = SIZE_MINIMIZED), WM_KILLFOCUS, WM_ENTERSIZEMOVE, and WM_ENTERMENULOOP

I set focus back on for the following messages:

WM_SIZE (all other cases), WM_SETFOCUS, WM_EXITSIZEMOVE, WM_ACTIVATEAPP with wParam set to true, and WM_EXITMENULOOP

WM_KILLFOCUS is adequate to solve the problem for ALT-CTRL-DELETE-ing out of the application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top