Full Screen Control on a Pocket PC


Feb 19, 2004
Melton Mowbray, England
I recently ran into a very annoying problem whilst developing for the Pocket PC. How to create an application that was full screen? The simple answer to this is you create a Form with it's WindowState property set to Maximised and set the Menu property to null. I wasn't happy with this however as although I didn't want the TaskBar and the SIP Icon, I still wanted to allow a menu.

Solution 1
Many places I looked suggested that the way to get around this was to use the SHFullScreen API. The way this works is by moving the items passed into dwState below the object with the windows handle passed into hwndRequester. I'm not going to go into too much detail, but sufficed to say I could not get this method to work to a satisfactory standard. The problem is that many things can cause the Z Order to be changed back to it's initial state which causes the SIP Icon to suddenly re-appear. One annoying thing that used to trigger this was selecting a top level MenuItem, then not selecting a child MenuItem, but instead clicking back on the form.
NB. SHFullScreen is generally in aygshell.dll however it's in coredll.dll on the Pocket PC
Visual Basic:
Declare Function SHFullScreen Lib "aygshell" (ByVal hwndRequester As Long, ByVal dwState As Long) As Boolean
private extern static bool SHFullScreen(IntPtr hWnd, long dwState);
Solution 2
Still determined to come up with the effect I wanted I continued on experimenting/researching. Eventually I came across some articles which used a differen't method. Namely moving the items off screen so that the form can be resize in thier place. The solution I came up with uses the following three API Calls...
public static extern int FindWindow(string LPClassName, string LPWindowName);

public static extern int GetWindowRect(int hwnd, ref RECT rc);

public static extern int MoveWindow(int hWnd, int X, int Y, int cx, int cy);
The basic theory is as follows. The constructor of the class gathers the required info for each item. This information is the Handle and its Location. This information is then stored for later use. A reference to the form is stored as it's possible its handle will change.
public ScreenHelper(System.Windows.Forms.Form mainForm) 
	_parent = mainForm;
	hiddenItems = new ScreenItem();
	GetWindowRect(FindWindow(null, _parent.Text), ref rtFormDefault);

	hWndSipButton = FindWindow("MS_SIPBUTTON", null);
	GetWindowRect(hWndSipButton, ref rtSipButton);

	hWndTaskBar = FindWindow("HHTaskBar", null);
	GetWindowRect(hWndTaskBar, ref rtTaskBar);

	hWndSip = FindWindow("SipWndClass", null);
	GetWindowRect(hWndSip, ref rtSip);
There are two other public methods, they are ChangeItemVisibility and ResetScreen.

I won't cover the code too much here as its in the file, but essentially ChangeItemVisibility accepts a flagged enum, which allows you to alter whether an item is displayed on screen or not. The ResetScreen method is very important as it replaces all the items in their correct positions. It is very important that this message is called before the application is closed otherwise the user may have to reset their device in order to get the items back.

To use the class successfully in an application you will need to call ChangeItemVisibilty each time the application gets control and call ResetScreen when your application looses control. To-do this I override the OnActivated and OnDeactivated events. It's also worth noting that OnDeactivated is not called when you call Application.Exit(), so be sure to add an extra call to ResetScreen() before calling it.

Well I'm no Guru, but I thought that since this problem caused me a lot of headaches, I'd share the solution I came up with. Attached is a sample project which contains my ScreenHelper class. Feel free to use it or any parts at your descretion, no guarantee implied etc, etc. Comments, suggestions, bug reports all welcome.

The following is a list of the main articles that helped me create my ScreenHelper class.


  • FullScreen.zip
    32.7 KB · Views: 82
Last edited:
Top Bottom