WM_ACTIVATE Not Sent with DirectDraw?


  • Hi,

    When running a DirectDraw full screen application, WM_ACTIVATE (nor WM_SETFOCUS) events are not sent after the application enters full screen exclusive mode, by using the common DirectDraw initialization code. This is terrible because incoming calls or low battery warnings do not appear and there's no way for the application to know.
    The problem happens both in the WM5 and WM6 emulators and in an Axim X51v.

    A search in the documentation confirms that WM_ACTIVATE should be sent as usual:
    "DirectDraw takes control of window activation events for full-screen, exclusive mode applications, sending WM_ACTIVATE messages to the window handle registered through the SetCooperativeLevel method as needed. DirectDraw only sends activation events to the top-level window. If your application creates child windows that require activation event messages, it is your responsibility to subclass the child windows."

    The same app, which is single-window and simple, if switched to alternatively using GAPI or GETRAWFRAMEBUFFER receives all WM_ACTIVATIONs as normal.

    Do you have any idea on what could be causing this? Is it a know bug in WM5/6?
    Thanks for any info.

    Jorge Diogo

    Friday, June 01, 2007 5:05 PM

All replies

  • 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."

    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.


    Hope this helps.

    Thursday, September 20, 2007 8:11 PM
  • SHFullScreen() - how I can implement this function? this is call back function..
    Monday, February 18, 2008 8:33 AM
  • It's not a callback.  It's a regular function:

    Call it with your main window handle, and combine all the SHFS_HIDE... flags.

    Monday, February 18, 2008 10:44 AM
  • thx, DONE
    Monday, February 18, 2008 11:33 AM