Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen app in wince 6.0 c#

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!

like image 318
Ignacio Gómez Avatar asked May 28 '12 18:05

Ignacio Gómez


1 Answers

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;
like image 104
ctacke Avatar answered Nov 15 '22 21:11

ctacke