Making an application full screen for Windows CE 4.2 using C# .net

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.
 
R

Russ

Very cool, but I am missing the "SystemHooks" class \ struct where do I
get it from?
 
T

tristanbannon

yeah i just cut it out of a class i called SystemHooks.

Unfortunately, i found out that if you're implementing your GUI by
using a stack (ie. pushing several different views onto the stack as
different windows), you get weird results on the second push. i'm
still tryign to fix that kink. anybody got any solutions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top