Click here to Skip to main content
6,305,776 members and growing! (16,122 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate

Full Screen Application: Windows CE and Pocket PC

By Oleg Levin

Making full screen application for Windows CE and Pocket PC devices
C# 2.0, Windows, Win Mobile, .NET CF, .NET, Visual Studio, Dev
Posted:7 Jun 2007
Updated:14 Jun 2007
Views:52,821
Bookmarked:45 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
14 votes for this article.
Popularity: 4.74 Rating: 4.13 out of 5
2 votes, 14.3%
1

2

3
2 votes, 14.3%
4
10 votes, 71.4%
5

Screenshot - fullpocket.jpgScreenshot - fullCE.jpg

Introduction

Many developers must include a "full screen" feature into their applications. In this article, I am focusing on Pocket PC and Windows CE devices. I've tried to introduce a universal solution for PDA software developers using the .NET Compact Framework that will enable them to include a full screen mode on both platforms, without requiring recompilation or code changes.

Background

Why do we need a full screen mode on our PDAs? My three main reasons are:

  • To disable user interaction and access other programs on the device
  • To make full use of the screen space
  • To customize forms

Using the code

There are three steps to my full screen solution.

  1. Detecting the platform type by invoking Windows API and changing the form behavior accordingly:

    Platform type detection is a simple call to SystemParametersInfo to find whether you are running on a Smartphone or a Pocket PC. You need a few constants defined and the P/Invoke marshaling code to make it work from managed code. I am using SystemParametersInfo4Strings P/Invoke to detect if the device is a Pocket PC or not.

    public enum SystemParametersInfoActions : uint
    {
        SPI_GETPLATFORMTYPE = 257, 
        // this is used elsewhere for Smartphone/PocketPC detection
    
    }
    #endregion
    
    /// 
    
    /// Get Platform Type: Pocket Pc or Windows CE
    
    /// 
    
    /// 
    
    public static string GetPlatformType()
    {
        StringBuilder platformType = new StringBuilder(50);
        if (SystemParametersInfo4Strings(
        (uint)SystemParametersInfoActions.SPI_GETPLATFORMTYPE,
            (uint)platformType.Capacity, platformType, 0) == 0)
            throw new Exception("Error getting platform type.");
        return platformType.ToString();
    }

    Platform detection method:

    /// 
    
    /// Platform Detections methods
    
    /// 
    
    internal partial class PlatformDetection
    {
        public static bool IsSmartphone()
        {
            return PInvoke.GetPlatformType() == "SmartPhone";
        }
        public static bool IsPocketPC()
        {
            return PInvoke.GetPlatformType() == "PocketPC";
        }
    }

    P/Invoke descriptions:

    //to find whether you are running on a Smartphone or a Pocket PC
    
    [DllImport("Coredll.dll", EntryPoint = "SystemParametersInfoW", 
        CharSet = CharSet.Unicode)]
    tatic extern int SystemParametersInfo4Strings(uint uiAction, 
        uint uiParam, StringBuilder pvParam, uint fWinIni);
        
    //The GetCapture function retrieves a handle to the window  
    
    [DllImport("coredll.dll")]
    private static extern IntPtr GetCapture();
    
    //The SetCapture function sets the mouse capture to
    
    //the specified window belonging to the current thread   
    
    [DllImport("coredll.dll")]
    private static extern IntPtr SetCapture(IntPtr hWnd);
    
    //This function can be used to take over certain areas of the screen
    
    //It is used to modify the taskbar, Input Panel button,
    
    //or Start menu icon.
    
    [DllImport("aygshell.dll", SetLastError = true)]
    private static extern bool SHFullScreen(IntPtr hwnd, int state);
    
    //The function retrieves the handle to the top-level 
    
    //window whose class name and window name match 
    
    //the specified strings. This function does not search child windows.
    
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern IntPtr FindWindowW(string lpClass, string
        lpWindow);
        
    //changes the position and dimensions of the specified window
    
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern IntPtr MoveWindow(IntPtr hwnd, int x, 
        int y, int w, int l, int repaint);

    This code is of the "set full screen" method:

    //if not Pocket PC platform
    
    if (!Platform.PlatformDetection.IsPocketPC()) 
    {
        //Set Full Screen For Windows CE Device
    
    
        //Normalize windows state
    
        form.WindowState = FormWindowState.Normal;
    
        IntPtr iptr = form.Handle;
        SHFullScreen(iptr, (int)FullScreenFlags.HideStartIcon);
                
        //detect taskbar height
    
        int taskbarHeight = 
            Screen.PrimaryScreen.Bounds.Height - 
            Screen.PrimaryScreen.WorkingArea.Height;
    
        // move the viewing window north taskbar 
    
        // height to get rid of the command bar 
    
        MoveWindow(iptr, 0, -taskbarHeight, 
            Screen.PrimaryScreen.Bounds.Width, 
            Screen.PrimaryScreen.Bounds.Height + taskbarHeight, 1);
    
    
        // move the task bar south taskbar height so that it's 
    
        // not visible anylonger 
    
        IntPtr iptrTB = FindWindowW("HHTaskBar", null);
        MoveWindow(iptrTB, 0, Screen.PrimaryScreen.Bounds.Height, 
            Screen.PrimaryScreen.Bounds.Width, taskbarHeight, 1);
    }
    else //pocket pc platform
    
    {
        //Set Full Screen For Pocket Pc Device
    
        form.Menu = null;
        form.ControlBox = false;
        form.FormBorderStyle = FormBorderStyle.None;
        form.WindowState = FormWindowState.Maximized;
        form.Text = string.Empty;
    }
  2. Calling the form load event's "make full screen" method:
    private void MainForm_Load(object sender, EventArgs e)
    {
        FullScreen.StartFullScreen(this);
    }
  3. Calling the form closing event's "remove full screen" method:
    private void MainForm_Closing(object sender, CancelEventArgs e)
    {
        FullScreen.StopFullScreen(this);
    }

What is next?

In addition, you can customize forms as well as set your own title with battery life and your own close button. Let's do it!

History

  • 7 June, 2007 -- Original article posted
  • 13 June, 2007 -- Updated
  • 14 June, 2007 -- Updated some more

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Oleg Levin


Member

Occupation: Software Developer
Company: SoftSolutions
Location: Israel Israel

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
GeneralHow to do MDI applications in Windows CE 5.0 (.Net) PinmemberSanShark22:12 20 Jan '09  
GeneralRe: How to do MDI applications in Windows CE 5.0 (.Net) PinmemberOleg Levin10:49 21 Jan '09  
Generalbackground image? PinmemberAlessandro1:49 7 Jul '08  
GeneralRe: background image? PinmemberOleg Levin2:32 7 Jul '08  
Generalhide the SIP keyboard icon Pinmemberram krishna pattnayak23:10 25 Mar '08  
GeneralRe: hide the SIP keyboard icon PinmemberOleg Levin5:21 26 Mar '08  
GeneralRe: hide the SIP keyboard icon Pinmemberram krishna pattnayak5:45 26 Mar '08  
GeneralRe: hide the SIP keyboard icon PinmemberOleg Levin19:36 26 Mar '08  
GeneralWhat about restoring?... PinmemberWin32nipuh21:51 7 Nov '07  
GeneralMaximized PinmemberDali Hammadi9:08 16 Aug '07  
GeneralTweak for Smartphone Mobile 5 Pinmembertban200313:12 30 Jul '07  
Questionwhy use partial class PinmemberDavid J Gu5:05 3 Jul '07  
AnswerRe: why use partial class PinmemberOleg Levin5:26 3 Jul '07  
GeneralFormWindowState.Maximized Pinmemberronzulu22:04 16 Jun '07  
GeneralMissing Information PinmemberNiteman22:18 12 Jun '07  
GeneralRe: Missing Information [modified] PinmemberOleg Levin22:32 12 Jun '07  
GeneralRe: Missing Information PinmemberNiteman22:55 12 Jun '07  
GeneralWorks for all resolutions? Pinmemberlonifasiko1:56 12 Jun '07  
GeneralRe: Works for all resolutions? PinmemberOleg Levin2:43 12 Jun '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 Jun 2007
Editor: Genevieve Sovereign
Copyright 2007 by Oleg Levin
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project