Page 1 of 1

DirectDraw and focus (phone calls) issues

PostPosted: Jun 4, 2007 @ 6:25pm
by Kzinti
I have added a DirectDraw driver to PocketHAL and am currently getting it tested. I am getting reports that losing focus doesn't work properly. I am using DDraw in exclusive "fullscreen" mode.

Anyone has experienced anything like this?

EDIT: I found a link that explains the problem in
more details:

http://forums.microsoft.com/MSDN/ShowPo ... 9&SiteID=1

PostPosted: Jun 6, 2007 @ 4:41pm
by Kzinti
So I investigated this so far. Basically the problem is this: once you have initialized DirectDraw, you don't ever receive WM_ACTIVATE or WM_SETFOCUS/WM_KILLFOCUS messages. In fact, I am not getting any message when my app should be losing focus.

Ludimate worked around this by listening for phone calls and low battery notifications. I guess it works for these 2 cases, but I am not happy with it. Someone somewhere must have run into this before?

PostPosted: Jun 7, 2007 @ 12:14pm
by ~mono

PostPosted: Jul 6, 2007 @ 11:50pm
by Cardinal
Ya that one is something we've run into as well. I guess people don't really have to answer calls while playing our awesome games? :)

PostPosted: Sep 21, 2007 @ 11:11am
by Ludimate
An explanation and workaround for this problem:

http://forums.microsoft.com/MSDN/showpo ... 1&siteid=1

The MSDN article you cite is for Windows CE .NET 4.2. A similar article for WM5 states:

"The exclusive (full-screen) mode prevents other applications from allocating some surface types and from drawing to the primary display. The exclusive mode also prevents other windows on the system from coming to the foreground, so DirectDraw applications must watch for system events (such as incoming phone calls) so they can relinquish control back to the system when necessary."

http://msdn2.microsoft.com/en-us/library/ms847103.aspx

So, it seems to be a feature.


My solution is not to use DDSCL_FULLSCREEN cooperative level. Use DDSCL_NORMAL. Create your main window fullscreen, that is, with coordinates [0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)]. Use SHFullScreen() function to hide all interface elements. This way you have a fullscreen DirectDraw access but still can receive system messages, have working Home key etc.


I'm not sure if you are required to show everything back when your app is deactivated. I do it, just in case. Also the system may draw its UI above your window before telling you that you are deactivated. To prevent your app from overwriting parts of the UI you create an IDirectDrawClipper, set it to your primary surface, and attach you main window's HWND to it. This guarantees that you never overwrite parts of UI if they're above your window.