当窗口状态最大化时,窗口位于任务栏后面

时间:2012-09-10 12:30:58

标签: c# wpf windowstate

  

可能重复:
  Borderless application on maximize is hiding behind the task bar in Win 7 and Win 8

我的windowstyle是none,我最大化窗口窗口在任务栏后面 我无法正确看到窗口。 我尝试这个但它不起作用:

this.MaxHeight = SystemParameters.VirtualScreenHeight;
this.MaxWidth = SystemParameters.VirtualScreenWidth;

1 个答案:

答案 0 :(得分:0)

你可以开始的东西:

    [DllImport("user32.dll")]
    private static extern int FindWindow(string lpszClassName, string lpszWindowName);
    [DllImport("user32.dll")]
    private static extern int ShowWindow(int hWnd, int nCmdShow);
    private const int SW_HIDE = 0;
    private const int SW_SHOW = 1;

    public void WindowsToolbar(bool visible)
    {
        int hWnd = FindWindow("Shell_TrayWnd", "");
        ShowWindow(hWnd, visible ? SW_SHOW : SW_HIDE);
    }

    public void HideTaskBarIfNeeded(Form form)
    {
        if (Screen.PrimaryScreen.Equals(Screen.FromRectangle(Screen.GetBounds(form))))
        {
            WindowsToolbar(false);
        }
    }