Wednesday, September 10, 2008

Full Screen featues in Windows mobile.

Hi Guys,

I look msdn forums last few days,in the forum many guys asked about the full screen features in windows mobile. Since i will post here my code for that.

The full screen features we can do by two ways.
1. We can do simplify in Windows mobile 5.0 or later like hide the menu,give empty text and set widows state is maximized.
2.we can do by the calling P/Invoke.
it's little interesting, because of OS API have a interesting method "SHFullScreen"

So when we pass our current form handle and window states to this method it's done.

before that we must get window handle to for current window.

so sample code below

public class WinAPI
{

internal const int SHFS_SHOWTASKBAR = 0x0001;
internal const int SHFS_HIDETASKBAR = 0x0002;
internal const int SHFS_SHOWSIPBUTTON = 0x0004;
internal const int SHFS_HIDESIPBUTTON = 0x0008;
internal const int SHFS_SHOWSTARTICON = 0x0010;
internal const int SHFS_HIDESTARTICON = 0x0020;
// Code used to hide the Windows bar

[DllImport("aygshell.dll", EntryPoint = "SHFullScreen", SetLastError = true)]
internal static extern bool SHFullScreen(IntPtr hwndRequester, int dwState);
[DllImport("coredll.dll", EntryPoint = "GetForegroundWindow", SetLastError = true)]
internal static extern IntPtr GetForegroundWindow();
[DllImport("coredll.dll")]
public static extern IntPtr GetCapture();
// Code used to hide the Windows bar
public static void FullScreen()
{
IntPtr hwnd = GetForegroundWindow();
SHFullScreen(hwnd, SHFS_HIDETASKBAR);
}
}

that's all

thank you

Thursday, September 4, 2008

Hi How to use the System State in Windows mobile

Hi Guys

here simple sample how to use the system state class in windows mobile.

Question: How to check the cradlepresent in the Windows mobile Device or Emulator ?

Answers:

SystemState cradleState = null;

private void Init()
{
cradleState = new SystemState(SystemProperty.CradlePresent);
cradleState.Changed += new ChangeEventHandler(cradleState_Changed);
}

void cradleState_Changed(object sender, ChangeEventArgs args)
{
bool isPresent =Convert.ToBoolean(SystemState.GetValue(SystemProperty.CradlePresent));
if (isPresent)
{
MessageBox.Show("Present");
}
}

thank you

All System States in WIndows mobile

Hi Guys

see here list of all System states.

using System;

namespace Microsoft.WindowsMobile.Status
{
// Summary:
// Specifies the device-wide system properties
public enum SystemProperty
{
// Summary:
// Gets the name of the application that was previously active and the name
// of the application that is currently active, separated by the 'Escape' character
// ('\e').
ActiveApplication = 0,
//
// Summary:
// Gets the orientation of the display, specified as the number of degrees,
// ranging from 0 to 360. Portrait = 0. Landscape = 90 or -90.
DisplayRotation = 1,
//
// Summary:
// Gets a value indicating whether a keyboard is attached and enabled.
KeyboardPresent = 2,
//
// Summary:
// Gets a value indicating whether the device is connected to a cradle.
CradlePresent = 3,
//
// Summary:
// Gets a value indicating whether a camera is attached and enabled.
CameraPresent = 4,
//
// Summary:
// Gets the number of unread SMS messages.
MessagingSmsUnread = 5,
//
// Summary:
// Gets the number of unread MMS messages
MessagingMmsUnread = 6,
//
// Summary:
// Gets the number of unplayed voice mail messages.
MessagingVoiceMailTotalUnread = 7,
//
// Summary:
// Gets the number of unplayed voice mail messages for line 1.
MessagingVoiceMail1Unread = 8,
//
// Summary:
// Gets the number of unplayed voice mail messages for line 2
MessagingVoiceMail2Unread = 9,
//
// Summary:
// Gets the number of unread ActiveSync e-mail messages.
MessagingActiveSyncEmailUnread = 10,
//
// Summary:
// Gets the total number of unread e-mail messages from all POP3/IMAP accounts.
MessagingTotalEmailUnread = 11,
//
// Summary:
// Gets the number of unread e-mail messages from all non-ActiveSync messaging
// accounts.
MessagingOtherEmailUnread = 12,
//
// Summary:
// Gets the name of the e-mail account that was last active.
MessagingLastEmailAccountName = 13,
//
// Summary:
// Gets the name of the SMS messaging account.
MessagingSmsAccountName = 14,
//
// Summary:
// Gets the name of the MMS messaging account.
MessagingMmsAccountName = 15,
//
// Summary:
// Get the name of the Outlook e-mail messaging account.
MessagingActiveSyncAccountName = 16,
//
// Summary:
// Gets the number of active tasks.
TasksActive = 17,
//
// Summary:
// Gets the number of high priority tasks that are currently active.
TasksHighPriority = 18,
//
// Summary:
// Gets the number of active tasks that are due today.
TasksDueToday = 19,
//
// Summary:
// Gets the number of overdue tasks.
TasksOverdue = 20,
//
// Summary:
// Gets the subject of the next Appointment.
CalendarNextAppointmentSubject = 21,
//
// Summary:
// Gets the location of the next Appointment.
CalendarNextAppointmentLocation = 22,
//
// Summary:
// Gets the starting time of the next Appointment.
CalendarNextAppointmentStart = 23,
//
// Summary:
// Gets the ending time of the next Appointment.
CalendarNextAppointmentEnd = 24,
//
// Summary:
// Gets the album artist's name of the currently playing track in Windows Media
// Player.
MediaPlayerAlbumArtist = 25,
//
// Summary:
// Gets the title of the track currently playing in Windows Media Player. For
// example, "128Kbps"
MediaPlayerTrackBitrate = 26,
//
// Summary:
// Gets the title of the track currently playing in Windows Media Player.
MediaPlayerTrackTitle = 27,
//
// Summary:
// Gets the album title of the currently playing track in Windows Media Player.
MediaPlayerAlbumTitle = 28,
//
// Summary:
// Gets the artist's name of the currently playing track in Windows Media Player.
MediaPlayerTrackArtist = 29,
//
// Summary:
// Gets the number of the current track playing in Windows Media Player.
MediaPlayerTrackNumber = 30,
//
// Summary:
// Gets the genre of the currently playing track in Windows Media Player.
MediaPlayerTrackGenre = 31,
//
// Summary:
// Gets the elapsed time (in milliseconds) of the currently playing track in
// Windows Media Player.
MediaPlayerTrackTimeElapsed = 32,
//
// Summary:
// Gets the remaining battery power level, expressed as a percentage of fully
// charged.
PowerBatteryStrength = 33,
//
// Summary:
// Gets the current battery state (for example, it is low, and charging). This
// enumeration allows a bitwise combination of its member values.
PowerBatteryState = 34,
//
// Summary:
// Gets the remaining backup battery power level, expressed as a percentage
// of fully charged.
PowerBatteryBackupStrength = 35,
//
// Summary:
// Gets the current backup battery state (for example, it is low, and charging).
// This enumeration allows a bitwise combination of its member values.
PowerBatteryBackupState = 36,
//
// Summary:
// Gets the current time. This Date/Time value updates once per minute.
Time = 37,
//
// Summary:
// Gets the current date. This Date/Time value changes once per day. Monitor
// this property to perform actions on a daily basis. Note: Do not use Date
// to get an accurate clock time; instead, use Time.
Date = 38,
//
// Summary:
// Get the phone signal strength, expressed as a percentage of full strength.
PhoneSignalStrength = 39,
//
// Summary:
// Gets the name of the mobile operator (i.e., the mobile phone company, or
// carrier).
PhoneOperatorName = 40,
//
// Summary:
// Gets the name of the person you are talking to on the phone. This value is
// not set when you are talking on a conference call.
PhoneTalkingCallerName = 41,
//
// Summary:
// Gets the number of active phone calls.
PhoneActiveCallCount = 42,
//
// Summary:
// Gets the localized name of the current sound profile. (Smartphone only)
PhoneProfileName = 43,
//
// Summary:
// Gets the non-localized name of the current sound profile. For example, "Normal",
// "Silent", "Car", "Headset", "Loud", "Meeting", or "Speakerphone". (Smartphone
// only)
PhoneProfile = 44,
//
// Summary:
// Gets the cell broadcast message
PhoneCellBroadcast = 45,
//
// Summary:
// Gets a value indicating whether there is a conflict with the next Appointment.
CalendarNextAppointmentHasConflict = 46,
//
// Summary:
// Gets the mobile device owner's name.
OwnerName = 47,
//
// Summary:
// Gets the mobile device owner's phone number.
OwnerPhoneNumber = 48,
//
// Summary:
// Gets the mobile device owner's e-mail address.
OwnerEmail = 49,
//
// Summary:
// Gets the text notes entered by the owner of the mobile device.
OwnerNotes = 50,
//
// Summary:
// Gets ActiveSync's current synchronization state.
ActiveSyncStatus = 51,
//
// Summary:
// Gets the number of missed phone calls.
PhoneMissedCalls = 52,
//
// Summary:
// Gets a value indicating whether a headset is present
HeadsetPresent = 53,
//
// Summary:
// Gets a value indicating whether a car kit is present
CarKitPresent = 54,
//
// Summary:
// Gets a value indicating whether the speakerphone is active
SpeakerPhoneActive = 55,
//
// Summary:
// Gets a value indicating whether the phone supports multiple lines.
PhoneMultiLine = 56,
//
// Summary:
// Gets a value indicating whether the Subscriber Identity Module (SIM) memory
// is full.
PhoneSimFull = 57,
//
// Summary:
// Gets a value indicating whether the Subscriber Identity Module (SIM) is installed
// in the mobile device.
PhoneNoSim = 58,
//
// Summary:
// Gets a value indicating whether the Subscriber Identity Module (SIM) is invalid.
PhoneInvalidSim = 59,
//
// Summary:
// Gets a value indicating whether the Subscriber Identity Module (SIM) is blocked.
PhoneBlockedSim = 60,
//
// Summary:
// Gets a value indicating whether the phone's radio is turned off.
PhoneRadioOff = 61,
//
// Summary:
// Gets a value indicating whether the mobile device has a phone.
PhoneRadioPresent = 62,
//
// Summary:
// Gets a value indicating whether the phone's ringer is off (i.e., if it rings
// and/or vibrates).
PhoneRingerOff = 63,
//
// Summary:
// Gets a value indicating whether line 1 is selected.
PhoneLine1Selected = 64,
//
// Summary:
// Gets a value indicating whether line 2 is selected.
PhoneLine2Selected = 65,
//
// Summary:
// Gets a value indicating whether the phone is currently in roaming mode.
PhoneRoaming = 66,
//
// Summary:
// Gets a value indicating whether call forwarding is enabled on line 1.
PhoneCallForwardingOnLine1 = 67,
//
// Summary:
// Gets a value indicating whether there was a new missed call.
PhoneMissedCall = 68,
//
// Summary:
// Gets a value indicating whether the phone has an active cellular data connection.
PhoneActiveDataCall = 69,
//
// Summary:
// Gets a value indicating whether the call barring feature is enabled.
PhoneCallBarring = 70,
//
// Summary:
// Gets a value indicating whether a phone call is currently on hold.
PhoneCallOnHold = 71,
//
// Summary:
// Gets a value indicating whether a conference call is currently in progress.
PhoneConferenceCall = 72,
//
// Summary:
// Gets a value indicating whether there is an incoming (ringing) call.
PhoneIncomingCall = 73,
//
// Summary:
// Gets a value indicating whether the phone is currently attempting to connect
// an outgoing call.
PhoneCallCalling = 74,
//
// Summary:
// Gets a value indicating whether the phone currently has GPRS coverage.
PhoneGprsCoverage = 75,
//
// Summary:
// Gets a value indicating whether the phone is not currently connected to a
// network.
PhoneNoService = 76,
//
// Summary:
// Gets a value indicating whether the phone is currently searching for service
// on a network.
PhoneSearchingForService = 77,
//
// Summary:
// Gets a value indicating whether the phone is currently registered on its
// home network.
PhoneHomeService = 78,
//
// Summary:
// Gets a value indicating whether the phone currently has 1xRTT coverage.
Phone1xRttCoverage = 79,
//
// Summary:
// Gets a value indicating whether there is currently a phone call in the talking
// state.
PhoneCallTalking = 80,
//
// Summary:
// Gets a value indicating whether call forwarding is currently active on line
// 2.
PhoneCallForwardingOnLine2 = 81,
//
// Summary:
// Gets the next Appointment.
CalendarNextAppointment = 82,
//
// Summary:
// Gets the user's availability (e.g., Free, Busy, Tenative, Out of Office)
// status for the next Appointment.
CalendarNextAppointmentBusyStatus = 83,
//
// Summary:
// Gets the next Appointment's categories.
CalendarNextAppointmentCategories = 84,
//
// Summary:
// Gets the current Appointment.
CalendarAppointment = 85,
//
// Summary:
// Gets the current Appointment's subject.
CalendarAppointmentSubject = 86,
//
// Summary:
// Gets the current Appointment's location.
CalendarAppointmentLocation = 87,
//
// Summary:
// Gets the current Appointment's starting time.
CalendarAppointmentStartTime = 88,
//
// Summary:
// Gets the current Appointment's ending time.
CalendarAppointmentEndTime = 89,
//
// Summary:
// Gets a value indicating whether the current Appointment has a scheduling
// conflict with an existing Appointment.
CalendarAppointmentHasConflict = 90,
//
// Summary:
// Gets the user's availability (free/busy status) for the time-slot taken by
// the current Appointment.
CalendarAppointmentBusyStatus = 91,
//
// Summary:
// Gets the current Appointment's categories.
CalendarAppointmentCategories = 92,
//
// Summary:
// Gets the Appointment that is currently displayed on the Home Screen.
CalendarHomeScreenAppointment = 93,
//
// Summary:
// Gets the subject of the Appointment that is currently displayed on the Home
// Screen.
CalendarHomeScreenAppointmentSubject = 94,
//
// Summary:
// Gets the location of the Appointment that is currently displayed on the Home
// Screen.
CalendarHomeScreenAppointmentLocation = 95,
//
// Summary:
// Gets the starting time of the Appointment that is currently displayed on
// the Home Screen.
CalendarHomeScreenAppointmentStartTime = 96,
//
// Summary:
// Gets the ending time of the Appointment that is currently displayed on the
// Home Screen.
CalendarHomeScreenAppointmentEndTime = 97,
//
// Summary:
// Gets a value indicating whether the Appointment that is currently displayed
// on the Home Screen has a scheduling conflict.
CalendarHomeScreenAppointmentHasConflict = 98,
//
// Summary:
// Gets the user's availability (free/busy status) for the Appointment displayed
// on the Home Screen.
CalendarHomeScreenAppointmentBusyStatus = 99,
//
// Summary:
// Gets the categories of the Appointment that is currently displayed on the
// Home Screen.
CalendarHomeScreenAppointmentCategories = 100,
//
// Summary:
// Gets the name of the person who is currently placing the incoming call.
PhoneIncomingCallerName = 101,
//
// Summary:
// Gets the name of the last caller to place an incoming call.
PhoneLastIncomingCallerName = 102,
//
// Summary:
// Gets the incoming call's phone number (Caller ID).
PhoneIncomingCallerNumber = 103,
//
// Summary:
// Gets the last incoming call's phone number (Caller ID).
PhoneLastIncomingCallerNumber = 104,
//
// Summary:
// Gets the name of the property that matches the Caller ID, e.g. "h" for "Home
// Telephone".
PhoneIncomingCallerContactPropertyName = 105,
//
// Summary:
// Gets the name of the property that matches the last Caller ID, e.g. "h" for
// "Home Telephone".
PhoneLastIncomingCallerContactPropertyName = 106,
//
// Summary:
// Gets the CEPROPID of the property that matches the Caller ID, for example,
// PIMPR_HOME_TELEPHONE_NUMBER.
PhoneIncomingCallerContactPropertyID = 107,
//
// Summary:
// Gets the CEPROPID of the property that matches the last Caller ID, for example,
// PIMPR_HOME_TELEPHONE_NUMBER.
PhoneLastIncomingCallerContactPropertyID = 108,
//
// Summary:
// Gets the Contact that matches the Caller ID.
PhoneIncomingCallerContact = 109,
//
// Summary:
// Gets the Contact that matches the last Caller ID.
PhoneLastIncomingCallerContact = 110,
//
// Summary:
// Gets the currently connected caller's phone number.
PhoneTalkingCallerNumber = 111,
//
// Summary:
// Gets the name of the property of the contact who is on the active phone call,
// e.g. "h" for "Home Telephone".
PhoneTalkingCallerContactPropertyName = 112,
//
// Summary:
// Gets the CEPROPID of the property of the contact who is on the active phone
// call, for example, PIMPR_HOME_TELEPHONE_NUMBER.
PhoneTalkingCallerContactPropertyID = 113,
//
// Summary:
// Gets the contact who is on the active phone call.
PhoneTalkingCallerContact = 114,
//
// Summary:
// Gets a value indicating the number of connections that are currently connected.
ConnectionsCount = 115,
//
// Summary:
// Gets a value indicating the number of Bluetooth connections that are currently
// connected.
ConnectionsBluetoothCount = 116,
//
// Summary:
// Gets a semicolon delimited string containing the description of each of the
// Bluetooth connections.
ConnectionsBluetoothDescriptions = 117,
//
// Summary:
// Gets a value indicating the number of cellular connections that are currently
// connected.
ConnectionsCellularCount = 118,
//
// Summary:
// Gets a semicolon delimited string containing the description of each cellular
// connection.
ConnectionsCellularDescriptions = 119,
//
// Summary:
// Gets a value indicating the number of network connections that are currently
// connected.
ConnectionsNetworkCount = 120,
//
// Summary:
// Gets a semicolon delimited string containing the description of each network
// connection.
ConnectionsNetworkDescriptions = 121,
//
// Summary:
// Gets a semicolon delimited string containing the adapter name of each network
// connection.
ConnectionsNetworkAdapters = 122,
//
// Summary:
// Gets a value indicating the number of desktop connections that are currently
// connected.
ConnectionsDesktopCount = 123,
//
// Summary:
// Gets a semicolon delimited string containing the description of each desktop
// connection.
ConnectionsDesktopDescriptions = 124,
//
// Summary:
// Gets a value indicating the number of network connections that are currently
// connected.
ConnectionsProxyCount = 125,
//
// Summary:
// Gets a semicolon delimited string containing the description of each proxy
// connection.
ConnectionsProxyDescriptions = 126,
//
// Summary:
// Gets a value indicating the number of modem connections that are currently
// connected.
ConnectionsModemCount = 127,
//
// Summary:
// Gets a semicolon delimited string containing the description of each modem
// connection.
ConnectionsModemDescriptions = 128,
//
// Summary:
// Gets a value indicating the number of connections of unknown type that are
// currently connected.
ConnectionsUnknownCount = 129,
//
// Summary:
// Gets a semicolon delimited string containing the description of each connections
// of unknown type.
ConnectionsUnknownDescriptions = 130,
//
// Summary:
// Gets a value indicating the number of virtual private network connections
// that are currently connected.
ConnectionsVpnCount = 131,
//
// Summary:
// Gets a semicolon delimited string containing the description of each virtual
// private network connection.
ConnectionsVpnDescriptions = 132,
//
// Summary:
// Gets the current "All Day Event" Appointment.
CalendarEvent = 133,
//
// Summary:
// Gets the subject of the current "All Day Event" Appointment.
CalendarEventSubject = 134,
//
// Summary:
// Gets the location of the current "All Day Event" Appointment.
CalendarEventLocation = 135,
//
// Summary:
// Gets the starting time of the current "All Day Event" Appointment. This will
// be the starting day of an Appointment Event that spans multiple days.
CalendarEventStartTime = 136,
//
// Summary:
// Gets the ending time of the current "All Day Event" Appointment. This will
// be the starting day of an Appointment Event that spans multiple days.
CalendarEventEndTime = 137,
//
// Summary:
// Gets a value indicating whether the user's availability (free/busy) status
// conflicts with the current "All Day Event".
CalendarEventHasConflict = 138,
//
// Summary:
// Gets the user's availability (free/busy status) for the current "All Day
// Event".
CalendarEventBusyStatus = 139,
//
// Summary:
// Gets the categories for the current "All Day Event".
CalendarEventCategories = 140,
}
}


thank you