2009-12-09 3 views

답변

5

먼저 P/Invoke를 통해 작업 표시 줄을 숨겨야합니다. 여기 to convert 정말 쉽게해야합니다 C 코드는 다음과 같습니다

HWND hwndTaskbar = ::FindWindow(_T("HHTaskBar"), NULL); 
::ShowWindow(hwndTaskbar, SW_HIDE); 

당신이, 당신의 디스플레이가 얼마나 큰지를 결정하고 그 크기로 폼의 크기를 조정 Screen.PrimaryScreen를 사용 그렇게되면.

+0

는 이러한 API를 호출하기위한 몇 가지 C 번호를 적어주세요 수 있습니다. 죄송 합니다만 P/Invoke에 대해 많이 알지 못합니다. – Gopinath

+3

CF 응용 프로그램을 작성하려면 P/Invoke를 배워야합니다. 주위에는 방법이 없습니다. 이것들은 정말로 간단합니다. 나는 당신을 시작할 수있는 링크를주었습니다. 나는 당신에게 물고기, 낚싯대 만주는 것이 아닙니다. 덕분에 – ctacke

+1

. 나는 P/Invoke를 배우기 시작했다 :) – Gopinath

5

사용이 코드 :

public class FullScreenEngine 
{ 
    // Fields 
    private IntPtr _hWndInputPanel; 
    private IntPtr _hWndSipButton; 
    private IntPtr _hWndTaskBar; 
    private Rectangle _desktopArea; 

    public FullScreenEngine() 
    { 
     Init(); 
    } 

    public bool SetFullScreen(bool mode) 
    { 
     try 
     { 
      if (mode) 
      { 
       if (_hWndTaskBar.ToInt64() != 0L) 
       { 
        ShowWindow(_hWndTaskBar, SW_HIDE); 
       } 
       if (_hWndInputPanel.ToInt64() != 0L) 
       { 
        ShowWindow(_hWndInputPanel, SW_HIDE); 
       } 
       if (_hWndSipButton.ToInt64() != 0L) 
       { 
        ShowWindow(_hWndSipButton, SW_HIDE); 
       } 
       WorkArea.SetWorkArea(new RECT(Screen.PrimaryScreen.Bounds)); 
      } 
      else 
      { 
       if (_hWndTaskBar.ToInt64() != 0L) 
       { 
        ShowWindow(_hWndTaskBar, SW_SHOW); 
       } 
       if (_hWndInputPanel.ToInt64() != 0L) 
       { 
        //ShowWindow(_hWndInputPanel, SW_SHOW); 
       } 
       if (_hWndSipButton.ToInt64() != 0L) 
       { 
        ShowWindow(_hWndSipButton, SW_SHOW); 
       } 
       WorkArea.SetWorkArea(new RECT(_desktopArea)); 
      } 
     } 
     catch (Exception) 
     { 
      return false; 
     } 
     return true; 
    } 

    private bool Init() 
    { 
     try 
     { 
      _desktopArea = Screen.PrimaryScreen.WorkingArea; 
      _hWndInputPanel = FindWindowW("SipWndClass", null); 
      _hWndSipButton = FindWindowW("MS_SIPBUTTON", null); 
      _hWndTaskBar = FindWindowW("HHTaskBar", null); 
     } 
     catch (Exception) 
     { 
      return false; 
     } 
     return true; 
    } 

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

    [DllImport("coredll.dll")] 
    private static extern int ShowWindow(IntPtr hwnd, uint command); 

    [DllImport("coredll.dll")] 
    private static extern IntPtr FindWindowW(string lpClassName, string lpWindowName); 

    // Nested Types 
    public struct RECT 
    { 
     public int Left; 
     public int Top; 
     public int Right; 
     public int Bottom; 

     public RECT(Rectangle rect) : this() 
     { 
      Left = rect.Left; 
      Right = rect.Left+rect.Width; 
      Top = rect.Top; 
      Bottom = rect.Top + rect.Height; 
     } 
    } 

    private static class WorkArea 
    { 
     [DllImport("coredll.dll")] 
     private static extern bool SystemParametersInfo(uint uAction, uint uparam, ref RECT rect, uint fuWinIni); 

     private const uint WM_SETTINGCHANGE = 0x1a; 
     const uint SPI_GETWORKAREA = 48; 
     const uint SPI_SETWORKAREA = 47; 

     public static bool SetWorkArea(RECT rect) 
     { 
      return SystemParametersInfo(SPI_SETWORKAREA, 0, ref rect, WM_SETTINGCHANGE); 
     } 

     public static RECT GetWorkArea() 
     { 
      var rect = new RECT(); 
      SystemParametersInfo(SPI_GETWORKAREA, 0, ref rect, 0); 
      return rect; 
     } 
    } 
} 
관련 문제