Thursday, August 19, 2010

How to detect screen rotation on windows mobile

You need to add the next references:

Microsoft.WindowsMobile
Microsoft.WindowsMobile.Status


Add the next code to your form load:

Microsoft.WindowsMobile.Status.SystemState MyScreenOrientationMonitor = new Microsoft.WindowsMobile.Status.SystemState(Microsoft.WindowsMobile.Status.SystemProperty.DisplayRotation);

MyScreenOrientationMonitor.Changed += new Microsoft.WindowsMobile.Status.ChangeEventHandler(ScreenRotatingDetector_Changed);


Finally add the specified event handler that fires when the screen has changed:

void ScreenRotatingDetector_Changed(object sender, Microsoft.WindowsMobile.Status.ChangeEventArgs args)
{
//Send a message to the screen
MessageBox.Show("Rootating......");
}

No comments:

Post a Comment