2011-04-18 62 views

回答

0

我最終設法在網上找到了一些我想要的代碼。這裏是:

public partial class myForm : Form 
{ 
public myForm() 
{ 
    InitializeComponent(); 
     this.GotFocus += delegate(object sender, EventArgs args) 
          { 
           //var intPtr = FindWindow("CaptureReturnForm", ""); 
           SetForegroundWindow(GetFocus()); 
           bool result = SHFullScreen(GetFocus(), SHFS_HIDESTARTICON | 
           SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON); // 0x0020); 

          }; 


    } 

    [DllImport("coredll.dll")] 
    private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 
    [DllImport("coredll.dll", EntryPoint = "SetForegroundWindow")] 
    private static extern int SetForegroundWindow(IntPtr hWnd); 
    [DllImport("coredll.dll")] 
    internal static extern IntPtr GetFocus(); 
    [DllImport("aygshell.dll")] 
    internal static extern bool SHFullScreen(IntPtr hWnd, uint dwState); 

    const uint SHFS_SHOWTASKBAR = 0x1; 
    const uint SHFS_HIDETASKBAR = 0x2; 
    const uint SHFS_SHOWSIPBUTTON = 0x4; 
    const uint SHFS_HIDESIPBUTTON = 0x8; 
    const uint SHFS_SHOWSTARTICON = 0x10; 
    const uint SHFS_HIDESTARTICON = 0x20; 
    const int HWND_TOPMOST = -1; 
    const int HWND_NOTOPMOST = -2; 

    const uint SWP_SHOWWINDOW = 0x40; 
    const uint SM_CXSCREEN = 0x0; 
    const uint SM_CYSCREEN = 0x1; 
    private const int HHTASKBARHEIGHT = 26; 
}