This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

A Windows Mobile user chooses a device as a communications tool, not a game platform. Every Windows Mobile game, no matter how compelling, should be designed to anticipate interruption from an incoming message. The game should get out of the way when a phone call or text message arrives, and resume when communication completes.

Other sources of interruptions can include low battery warnings, calendar notifications, network status alerts, and events generated by other applications operating in the background.

The flexibility and extensibility are part of the reason that the Windows Mobile platform is so popular, but that flexibility and extensibility are challenges for you as a game developer.

The State and Notifications Broker

Your game program can monitor the state of the device and respond to state changes using the State and Notifications Broker(SNAPI).

SNAPI stores device, system, and application information in the registry and notifies applications when that information changes.

The State and Notification Broker can be used to monitor any registry key in the system. The general categories of notifications include:

  • System state information, such as features present (camera, keyboard), active application, cradled state, battery state.

  • Message information, such as count of unread, last received, account info.

  • Tasks and appointments information, such as upcoming, overdue, location.

  • Windows Media Player information, such as currently playing album, artist.

  • Phone information, such as signal information, operator information, call information, multiline information.

  • Connections information related to bluetooth, cellular, network, etc.

Game applications can use the broker to know when to pause the game and save the game state, such as when a message arrives or when device power is running out.

Setting up the State and Notifications Broker

The following code snippet shows how to set up SNAPI for later use.

Copy Code
#include <regext.h>
#include <snapi.h>
HREGNOTIFY hregNotifyPhone = NULL; //Create handle

hr = RegistryNotifyWindow( 
	SN_PHONEINCOMINGCALL_ROOT, //defined in snapi.h
	g_hWnd,  //handle to our window to receive msg
	WM_STATECHANGE, //app defined message to send
	SC_PHONESTATUS, //app defined value
); //Don’t forget to close this

Using the State and Notifications Broker

The following code snippet shows the use of SNAPI within the applications message loop to manage application state changes based on phone status.

Copy Code
	//We get a WM_STATECHANGE message when a call comes in. 
	if (lParam == SC_PHONESTATUS && wParam &
		//Lose Focus will clean up game state,
		//leave full screen mode, and call 
		//SetWindowPos() to un-show our window
	return 0;
	// <snip> Rest of message loop

See Also