8

I have my app and want to make it run in full-screen mode, no task-bar. I found out how to hide the windows bar but when I start my app it doesn't cover the space of the windows task-bar, despite this last is hidden.

I found this but it didn't work. I couldn't find examples of this regarding to wince. I have FormBorderStyle = None, and WindowsState = Maximized

SOLUTION:

I find a way of doing it. An important tip is to have the WindowState = Normal(it took me some time to find this problem). If you have WindowState = Maximized you can't set the Form's height to the maximum display's height.

I wrote this code to probe it and it work ok. Is a Form with two buttons: button1(fullscreen) and button2(restore default screen)

    public partial class Form1 : Form
    {
        public Form1(){
               InitializeComponent();            
        }

    [DllImport("Coredll")]
    internal static extern IntPtr FindWindow(String lpClassName, String lpWindowName);

    [DllImport("coredll.dll")]
    internal static extern bool EnableWindow(IntPtr hwnd, Boolean bEnable);

    [DllImport("coredll.dll")]
    private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);


    public static bool EnableTaskBar(Boolean enable)
    {
        IntPtr hwnd;
        hwnd = FindWindow("HHTaskBar", "");

        if (enable) SetHHTaskBar();
        else HideHHTaskBar();

        return EnableWindow(hwnd, enable);
    }

    public static void HideHHTaskBar()
    {
        IntPtr iptrTB = FindWindow("HHTaskBar", null);
        MoveWindow(iptrTB, 0, Screen.PrimaryScreen.Bounds.Height,
        Screen.PrimaryScreen.Bounds.Width, 26, true);
    }

    public static void SetHHTaskBar()
    {
        IntPtr iptrTB = FindWindow("HHTaskBar", null);
        MoveWindow(iptrTB, 0, 294,
        Screen.PrimaryScreen.Bounds.Width, 26, true);
    }


    private void button1_Click(object sender, EventArgs e)
    {
        EnableTaskBar(false);
        this.Width = Screen.PrimaryScreen.Bounds.Width;
        this.Height = Screen.PrimaryScreen.Bounds.Height;
        this.Left = 0;
        this.Top = 0;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        EnableTaskBar(true);
    }
}

Hope it helps others with the same problem!

Thanks for the help!

Community
  • 1
  • 1
Ignacio Gómez
  • 1,587
  • 4
  • 23
  • 41

2 Answers2

8

After hiding the task bar, explicitly set the size and position of your Form:

myForm.Width = Screen.PrimaryScreen.Bounds.Width;
myForm.Height = Screen.PrimaryScreen.Bounds.Height;
myForm.Left = 0;
myForm.Top = 0;
ctacke
  • 66,480
  • 18
  • 94
  • 155
  • I tried that with no luck. It is the same. It shows the app but it don't cover the space of the task-bar – Ignacio Gómez May 28 '12 at 19:29
  • So is it clipping the bottom of your Form? Is your Form size actually getting set to the screen height? What's the exact behavior of the failure? – ctacke May 29 '12 at 02:35
  • I could figure it out! Your solution wasn't working because I had my *WindowState=Maximized*. When I changed it to *Normal* it work ok with your solution. I edit my question adding the solution to an example. Thanks for your help! – Ignacio Gómez May 29 '12 at 12:26
0

I've always used SHFullScreen to achieve this when required. You will need to use PInvoke to call it.

Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56