Click here to Skip to main content
15,895,462 members
Articles / Programming Languages / C#

Windows Mobile Programming Tricks on the .NET Compact Framework: Part 1

Rate me:
Please Sign up or sign in to vote.
4.64/5 (8 votes)
23 Feb 2011CPOL4 min read 41.1K   668   24  
The article provides and describes some useful code snippets for Windows Mobile/CE developers.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BeeMobile
{
    public class SIP
    {
        [DllImport("coredll.dll", SetLastError = true)]
        private static extern IntPtr FindWindow(string caption, string className);

        [DllImport("coredll.dll", SetLastError = true)]
        private static extern bool ShowWindow(IntPtr hwnd, int state);

        private const int SW_HIDE = 0;
        private const int SW_SHOW = 1;

        [DllImport("coredll.dll")]
        private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);

        /// <summary>
        /// Hides the SIP (Software Input Panel) button.
        /// </summary>
        static public void HideSIP()
        {
            IntPtr hSipWindow = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON");
            if (hSipWindow != IntPtr.Zero)
            {
                IntPtr hSipButton = GetWindow(hSipWindow, 5);
                if (hSipButton != IntPtr.Zero)
                {
                    bool res = ShowWindow(hSipButton, SW_HIDE);
                }
            }
        }

        /// <summary>
        /// Shows the SIP (Software Input Panel) button.
        /// </summary>
        static public void ShowSIP()
        {
            IntPtr hSipWindow = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON");
            if (hSipWindow != IntPtr.Zero)
            {
                IntPtr hSipButton = GetWindow(hSipWindow, 5);
                if (hSipButton != IntPtr.Zero)
                {
                    bool res = ShowWindow(hSipButton, SW_SHOW);
                }
            }
        }
    }
}

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
G&M Dynamics, s.r.o.
Slovakia Slovakia
I work for Bee Mobile.

Web site: http://beemobile4.net
Facebook site: http://facebook.com/BeeMobile
YouTube Channel: http://youtube.com/beemobile4dotnet

Comments and Discussions