.NET CF如何使Form全螢幕不顯示開始選單

  • 5257
  • 0

上一篇文章的作法是將所有上方工作列移除, 會影嚮到其他功能,並不符合我的要求,

後來又找到了另一方法可以保留TaskBar,不顯示StarMenu, ok及x

經測試結果,this.WindowState = FormWindowState.Maximized;這行不要寫,
不然Show其他Form後,在Active時上方Task Bar會不見

上一篇文章的作法是將所有上方工作列移除,  會影嚮到其他功能,並不符合我的要求,
.NET CF如何使Form全螢幕不顯示上方工作列(TaskBar)

後來又找到了另一方法可以保留TaskBar,不顯示StarMenu, ok及x

經測試結果,this.WindowState = FormWindowState.Maximized;這行不要寫,
不然Show其他Form後,在Active時上方Task Bar會不見

1.先寫FindWindow

        private const string formWindowClassName = "#NETCF_AGL_BASE_";
        [DllImport("coredll.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        private static IntPtr FindWindow(string a_WindowName)
        {
            return FindWindow(formWindowClassName, a_WindowName);
        }

2.寫FindWindow

public const int SHFS_SHOWTASKBAR = 1;
        public const int SHFS_HIDETASKBAR = 2;
        public const int SHFS_SHOWSIPBUTTON = 4;
        public const int SHFS_HIDESIPBUTTON = 8;
        public const int SHFS_SHOWSTARTICON = 16;
        public const int SHFS_HIDESTARTICON = 32;

        [DllImport("aygshell.dll")]
        private extern static bool SHFullScreen(IntPtr hWnd, int dwState);

        public static bool FullScreen(IntPtr hWnd)
        {
            return SHFullScreen(hWnd, SHFS_HIDESTARTICON);
        }


        public static bool ShowStartIcon(Form a_Form, bool a_Show)
        {
            Int32 dwFlag = a_Show ? SHFS_SHOWSTARTICON : SHFS_HIDESTARTICON;
            return SHFullScreen(FindWindow(a_Form.Text), dwFlag);
        }
        

3.在欲控制程式Form的Active及Load事件Call ShowStartIcon就ok了

        private void StartForm_Activated(object sender, EventArgs e)
        {
            ShowStartIcon(this, false);
        }

 

 參考文章..
全螢幕程式,用P/Invoke的方式呼叫SHFullScreen API把左上角的Start圖示 ...