转自http://www.dotblogs.com.tw/larry/archive/2008/10/01/5551.aspx
方法如下...
1. 使Form全螢幕,
this.WindowState = FormWindowState.Maximized;
2. 隱藏control box 及 minimize/maximize buttons
3. 使用以下程式碼,顯示或隱藏Form上方的開始選單
Code
private const int SW_HIDE = 0x00;
private const int SW_SHOW = 0x0001;
[DllImport("coredll.dll", CharSet=CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll.dll", CharSet=CharSet.Auto)]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("coredll.dll", CharSet=CharSet.Auto)]
private static extern bool EnableWindow(IntPtr hwnd, bool enabled);
public static void ShowTaskbar()
{
IntPtr h = FindWindow("HHTaskBar", "");
ShowWindow(h, SW_SHOW);
EnableWindow(h, true);
}
public static void HideTaskbar()
{
IntPtr h = FindWindow("HHTaskBar", "");
ShowWindow(h, SW_HIDE);
EnableWindow(h, false);
}
參考文章出處:How to hide start menu?
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=639012&SiteID=1
此作法是將所有上方工作列移除, 會影嚮到其他功能,並不符合我的要求,後來又找到了另一方法可以保留TaskBar,不顯示Start Menu, ok及x
經測試結果,this.WindowState = FormWindowState.Maximized;這行不要寫,
不然Show其他Form後,在Active時上方Task Bar會不見
1.先寫FindWindow
Code
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.寫ShowStartIcon
Code
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);
}