Click here to Skip to main content
15,896,493 members
Articles / Mobile Apps / Windows Mobile

Having full screen without accessing the SHFullScreen API

Rate me:
Please Sign up or sign in to vote.
4.70/5 (12 votes)
26 Oct 2002CPOL2 min read 182.2K   731   40  
Add full screen capability in your PocketPC applications.
#include "FullScreen.h"

int InitFullScreen (void)
{
	int	Result = 0;

	__try
	{
		if (SystemParametersInfo(SPI_GETWORKAREA, 0, &rtDesktop, NULL) == 1)
		{
			// Successful obtain the system working area (Desktop)
			SetRect(&rtNewDesktop, 0, 0, 240, 320);

			// Change system setting
			SystemParametersInfo(SPI_SETWORKAREA, 0, &rtNewDesktop, SPIF_UPDATEINIFILE);
		}

		// Find the Input panel window handle
		hWndInputPanel = FindWindow(TEXT("SipWndClass"), NULL);
		// Checking...
		if (hWndInputPanel != NULL)
			// Get the original Input panel window size
			GetWindowRect(hWndInputPanel, &rtInputPanel);

		// Find the SIP Button window handle
		hWndSipButton = FindWindow(TEXT("MS_SIPBUTTON"), NULL);
		// Checking...
		if (hWndSipButton != NULL)
			// Get the original Input panel window size
			GetWindowRect(hWndSipButton, &rtSipButton);

		// Find the Taskbar window handle
		hWndTaskBar = FindWindow(TEXT("HHTaskBar"), NULL);
		// Checking...
		if (hWndTaskBar != NULL)
			// Get the original taskbar window size
			GetWindowRect(hWndTaskBar, &rtTaskBar);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		// PUT YOUR ERROR LOG CODING HERE

		// Set return value
		Result = 1;
	}

	return Result;
}

int DoFullScreen (bool mode)
{
	int	Result = 0;

	__try
	{
		if (mode)
		{
			// Update window working area size
			SystemParametersInfo(SPI_SETWORKAREA, 0, &rtNewDesktop, SPIF_UPDATEINIFILE);

			if (NULL != hWndTaskBar)
			{
				// Hide the TaskBar
				MoveWindow(hWndTaskBar, 
						   0, 
						   rtNewDesktop.bottom, 
						   rtTaskBar.right - rtTaskBar.left, 
						   rtTaskBar.bottom - rtTaskBar.top, 
						   false);
			}

			if (NULL != hWndInputPanel)
			{
				// Reposition the input panel 
				MoveWindow(hWndInputPanel,
						   0,
						   rtNewDesktop.bottom - (rtInputPanel.bottom - rtInputPanel.top), 
						   rtInputPanel.right - rtInputPanel.left, 
						   rtInputPanel.bottom - rtInputPanel.top,
						   false);
			}

			// Ensure the SIP button is found (Only for PocketPC)
			if (NULL != hWndSipButton)
			{
				// Hide the input panel 
				MoveWindow(hWndInputPanel,
						   0,
						   rtNewDesktop.bottom, 
						   rtSipButton.right - rtSipButton.left, 
						   rtSipButton.bottom - rtSipButton.top,
						   false);
			}
		}
		else
		{
			// Update window working area size
			SystemParametersInfo(SPI_SETWORKAREA, 0, &rtDesktop, SPIF_UPDATEINIFILE);

			// Restore the TaskBar
			if (NULL != hWndTaskBar)
			{
				MoveWindow(hWndTaskBar, 
						   rtTaskBar.left, 
						   rtTaskBar.top,
						   rtTaskBar.right - rtTaskBar.left,
						   rtTaskBar.bottom - rtTaskBar.top,
						   false);
			}

			// Restore the input panel
			if (NULL != hWndInputPanel)
			{
				MoveWindow(hWndInputPanel, 
						   rtDesktop.left,
						   rtDesktop.bottom - (rtInputPanel.bottom - rtInputPanel.top) - (rtTaskBar.bottom - rtTaskBar.top), 
						   rtInputPanel.right - rtInputPanel.left,
						   rtInputPanel.bottom - rtInputPanel.top,
						   false);
			}

			// Ensure the SIP button is found (Only for PocketPC)
			if (NULL != hWndSipButton)
			{
				// Hide the input panel 
				MoveWindow(hWndSipButton,
						   rtSipButton.left,
						   rtSipButton.top, 
						   rtSipButton.right - rtSipButton.left, 
						   rtSipButton.bottom - rtSipButton.top,
						   false);
			}
		}
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		// PUT YOUR ERROR LOG CODING HERE

		// Set return value
		Result = 1;
	}

	return Result;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
Passion to be a software architect and solution researcher in enterprise solutions by simplify and unify the existing complex manual paper works into an automated environment friendly, comprehensive and dynamic workflow process system.

Comments and Discussions