Fullscreen app in wince 6.0 c#

醉酒当歌 提交于 2019-12-09 10:31:11

问题


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!


回答1:


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;



回答2:


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



来源:https://stackoverflow.com/questions/10788957/fullscreen-app-in-wince-6-0-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!