8

I written a Kiosk style C# application using visual studio that is run on startup and should expand to full-screen and cover the task-bar.

I am doing the usual setting boarder style to none, and fill extents and it works perfectly if I just launch the application manually.

When the application launches on startup (by way of a short-cut in the startup folder in the start menu), the task-bar ends up on top of the program and clicking somewhere on the form does not bring the form back to the top.

Has anyone encountered this problem before, or know of possible workarounds.

Ondrej
  • 1,209
  • 1
  • 11
  • 21
Hugoagogo
  • 1,598
  • 16
  • 34
  • Not sure but there might be other programs interrupting it.. – Rohit Oct 21 '13 at 05:09
  • This is on a clean install of windows XP I cant remember what edition, the only stuff that has been installed is the .net distributable and some drivers for a USBCAN adapter. – Hugoagogo Oct 21 '13 at 05:24
  • What technology do you use? WPF or WinForms? – galenus Oct 21 '13 at 06:59
  • I am using winforms for this project – Hugoagogo Nov 25 '13 at 04:54
  • If it's a windows forms application, then this should help: http://stackoverflow.com/questions/2272019/how-to-display-a-windows-form-in-full-screen-on-top-of-the-taskbar – stombeur Mar 03 '14 at 13:09
  • @StephaneT I am already using that to make the window fullscreen, my issue is when the program is run on startup – Hugoagogo Apr 01 '14 at 04:14
  • I've done this before, but we configured windows to run our own exe instead of explorer.exe at startup. that way, you get a true kiosk. On WinCE this is standard, but there is software that lets you do this on win7/win8 as well. – stombeur Apr 01 '14 at 07:41

2 Answers2

3

I have also done this another time:

public class Screensize
{
    /// <summary>
    /// Selected Win AI Function Calls
    /// </summary>

    public class WinApi
    {
        [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
        public static extern int GetSystemMetrics(int which);

        [DllImport("user32.dll")]
        public static extern void
            SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
                         int X, int Y, int width, int height, uint flags);

        private const int SM_CXSCREEN = 0;
        private const int SM_CYSCREEN = 1;
        private static IntPtr HWND_TOP = IntPtr.Zero;
        private const int SWP_SHOWWINDOW = 64; // 0x0040

        public static int ScreenX
        {
            get { return GetSystemMetrics(SM_CXSCREEN); }
        }

        public static int ScreenY
        {
            get { return GetSystemMetrics(SM_CYSCREEN); }
        }

        public static void SetWinFullScreen(IntPtr hwnd)
        {
            SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
        }
    }

    /// <summary>
    /// Class used to preserve / restore state of the form
    /// </summary>
    public class FormState
    {
        private FormWindowState winState;
        private FormBorderStyle brdStyle;
        private bool topMost;
        private Rectangle bounds;

        private bool IsMaximized = false;

        public void Maximize(Form targetForm)
        {
            if (!IsMaximized)
            {
                IsMaximized = true;
                Save(targetForm);
                targetForm.WindowState = FormWindowState.Maximized;
                targetForm.FormBorderStyle = FormBorderStyle.None;
                targetForm.TopMost = false;
                WinApi.SetWinFullScreen(targetForm.Handle);
            }
        }

        public void Save(Form targetForm)
        {
            winState = targetForm.WindowState;
            brdStyle = targetForm.FormBorderStyle;
            topMost = targetForm.TopMost;
            bounds = targetForm.Bounds;
        }

        public void Restore(Form targetForm)
        {
            targetForm.WindowState = winState;
            targetForm.FormBorderStyle = brdStyle;
            targetForm.TopMost = topMost;
            targetForm.Bounds = bounds;
            IsMaximized = false;
        }
    }

and just call in your form:

screensize.Maximize(this)

I think you mean this

And now I see this post is from 2013...

Cageman
  • 513
  • 3
  • 22
  • Thanks for this, I will not get to test this for a few weeks but it looks both good as well as a pretty straight forward solution, UpVoted for now and will mark as correct after I have got a chance to fix this up. – Hugoagogo Apr 01 '14 at 04:12
0

Workaround: When starting, kill explorer.exe - you don't need it -> taskbar disappear. When needed, start it using Task Manager

Ondrej
  • 1,209
  • 1
  • 11
  • 21