T
tristanbannon
This took me a while to figure out because everyone says something
different, and none of them worked for me. So when i got it, I decided
to post the solution to prevent it from happening to others. Here we
go.
You have to do two things. First, find the taskbar, then move it.
Then move you're main window. , assuming a screen size of 240x320.
Also, you have to make a bunch of Win32 API calls to do it.
[Flags()]
public enum FullScreenFlags : int
{
SwHide = 0,
ShowTaskbar = 0x1,
HideTaskbar = 0x2,
ShowSipButton = 0x4,
HideSipButton = 0x8,
SwRestore = 9,
ShowStartIcon = 0x10,
HideStartIcon = 0x20
}
// Win32 API Calls
[DllImport("coredll.dll")]
private static extern IntPtr GetCapture();
[DllImport("coredll.dll")]
private static extern IntPtr SetCapture(IntPtr hWnd);
[DllImport("aygshell.dll", SetLastError=true)]
private static extern bool SHFullScreen(IntPtr hwnd, int state);
[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr FindWindowW(string lpClass, string
lpWindow);
[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr MoveWindow(IntPtr hwnd, int x, int y, int
w, int l, int repaint);
public static IntPtr GetHWnd(Control c)
{
IntPtr hOldWnd = GetCapture();
c.Capture = true;
IntPtr hWnd = GetCapture();
c.Capture = false;
SetCapture(hOldWnd);
return hWnd;
}
public static void SetFullScreen(Control c)
{
IntPtr iptr = SystemHooks.GetHWnd(c);
SHFullScreen(iptr, (int)FullScreenFlags.HideStartIcon);
// move the viewing window north 24 pixels to get rid of the command
bar
MoveWindow(iptr, 0, -24, 240, 344, 1);
// move the task bar south 24 pixels so that its not visible anylonger
IntPtr iptrTB = FindWindowW("HHTaskBar", null);
MoveWindow(iptrTB, 0, 320, 240, 24, 1);
}
public static void UnsetFullScreen(Control c)
{
IntPtr iptr = SystemHooks.GetHWnd(c);
SHFullScreen(iptr, (int)FullScreenFlags.ShowStartIcon);
MoveWindow(iptr, 0, 0, 240, 296, 1);
IntPtr iptrTB = FindWindowW("HHTaskBar", null);
MoveWindow(iptrTB, 0, 296, 240, 24, 1);
}
'Control c' is the main control you're passing in, which should be your
main view. From your window class, call SetFullScreen(this). Have fun.
different, and none of them worked for me. So when i got it, I decided
to post the solution to prevent it from happening to others. Here we
go.
You have to do two things. First, find the taskbar, then move it.
Then move you're main window. , assuming a screen size of 240x320.
Also, you have to make a bunch of Win32 API calls to do it.
[Flags()]
public enum FullScreenFlags : int
{
SwHide = 0,
ShowTaskbar = 0x1,
HideTaskbar = 0x2,
ShowSipButton = 0x4,
HideSipButton = 0x8,
SwRestore = 9,
ShowStartIcon = 0x10,
HideStartIcon = 0x20
}
// Win32 API Calls
[DllImport("coredll.dll")]
private static extern IntPtr GetCapture();
[DllImport("coredll.dll")]
private static extern IntPtr SetCapture(IntPtr hWnd);
[DllImport("aygshell.dll", SetLastError=true)]
private static extern bool SHFullScreen(IntPtr hwnd, int state);
[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr FindWindowW(string lpClass, string
lpWindow);
[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr MoveWindow(IntPtr hwnd, int x, int y, int
w, int l, int repaint);
public static IntPtr GetHWnd(Control c)
{
IntPtr hOldWnd = GetCapture();
c.Capture = true;
IntPtr hWnd = GetCapture();
c.Capture = false;
SetCapture(hOldWnd);
return hWnd;
}
public static void SetFullScreen(Control c)
{
IntPtr iptr = SystemHooks.GetHWnd(c);
SHFullScreen(iptr, (int)FullScreenFlags.HideStartIcon);
// move the viewing window north 24 pixels to get rid of the command
bar
MoveWindow(iptr, 0, -24, 240, 344, 1);
// move the task bar south 24 pixels so that its not visible anylonger
IntPtr iptrTB = FindWindowW("HHTaskBar", null);
MoveWindow(iptrTB, 0, 320, 240, 24, 1);
}
public static void UnsetFullScreen(Control c)
{
IntPtr iptr = SystemHooks.GetHWnd(c);
SHFullScreen(iptr, (int)FullScreenFlags.ShowStartIcon);
MoveWindow(iptr, 0, 0, 240, 296, 1);
IntPtr iptrTB = FindWindowW("HHTaskBar", null);
MoveWindow(iptrTB, 0, 296, 240, 24, 1);
}
'Control c' is the main control you're passing in, which should be your
main view. From your window class, call SetFullScreen(this). Have fun.