I'm writing a Direct3D9 application wrapped by SlimDX. I'm trying to take my application full screen but I am having problems. I can reset the device so that it covers the entire screen, however, it seems as though the device window loses focus. The cursor belongs to that of the window beneath my device window. When I click on the screen(while in full screen mode) the window beneath my device window gets focus. This shouldn't happen.

In my c# code for managing the device I have converted DXUT(from the DirectX SDK) to c#...There is a lot of code to cover but I was hoping for a theoretical answer.

What is happening to the device as I take the app full screen? Why does the window beneath the device window get focus while the device window continues to render and cover the screen?

Could my problem have anything to do with the fact that Windows Forms draws with GDI? I found a post here that describes a problem that differs in result but may be along the same lines wrt cause.


The problem was due to the nature of controls found in Windows Forms. From MSDN:

A control can be selected and receive input focus if all the following are true: the Selectable value of ControlStyles is set to true, it is contained in another control, and all its parent controls are both visible and enabled.

The device window in my application belongs to a parent window and the parent window becomes nonvisible once fullscreen is enabled. Its possible that a conflict arose due to the 'focus rules' above. To test the theory I examined the return value from DeviceWindow.Focus()(derives from Control.Focus())...which returned false.

My solution was to create a form used for the sole purpose of fullscreen mode changes. Now, when I want to go fullscreen I reset the device with the handle to the new device window. All problems solved...

  • \$\begingroup\$ Why a new window? why were you hiding the window before? The way I've always done it (from C++ and from C# via SharpDX) is to do it in the same window, and when going to full screen, just remove the border and set the window size to the size of the screen \$\endgroup\$ – Panda Pajama Sep 11 '14 at 2:29
  • \$\begingroup\$ @PandaPajama When using one form for both 'windowed' and 'full screen' modes I was unable to give the form focus when full screen. This allowed the taskbar and other windows to receive focus during full screen mode. I read on MSDN that in order for a form to have focus it must not be contained by another control(it cannot be a child of another form). In my application, the device window(form) is a child form when 'windowed'. So...in order to go full screen I require a form that has no parent controls... \$\endgroup\$ – P. Avery Sep 11 '14 at 16:29
  • \$\begingroup\$ Did you change the swap chain to full screen mode? If you don't, you're just runnig in windowed mode on a very big window, but not really full screen \$\endgroup\$ – Panda Pajama Sep 11 '14 at 18:29
  • \$\begingroup\$ @PandaPajama in d3d9 the present params are changed to full screen mode, the device is then recreated...The device is recreated to accomodate an adapter format change...In full screen mode the adapter format can be changed to any available by the adapter(instead of the format used by the desktop's display mode). \$\endgroup\$ – P. Avery Sep 11 '14 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.