Fullscreen ?

E

Engin AYDOGAN

I want to make my application to use the whole screen, searched through
msdn and it suggests to use `WindowState = FormWindowState.Maximized;'
in the (only) Form of the program, but it doesn't work. I still can see
the taskbar and title bar. I've tried placing above statment to few
places (i.e. in c-tor/onLoad of the form, etc), still no go.

Any ideas ?
 
B

Buthrakaur

Hi, it's possible to create a fullscreen app using SHFullScreen
function from aygshell.dll. Take a look on following code snippet:



public static bool SetTaskBarEnabled(bool enabled)
{
IntPtr hwnd = Win32Window.FindWindow("HHTaskBar", null);
return Win32Window.EnableWindow(hwnd, enabled);
}

[DllImport("aygshell.dll", EntryPoint="SHFullScreen",
SetLastError=true)]
private static extern bool SHFullScreen(IntPtr apphwnd, int state);


const int SHFS_SHOWTASKBAR = 0x1;
const int SHFS_HIDETASKBAR = 0x2;
const int SHFS_SHOWSIPBUTTON = 0x4;
const int SHFS_HIDESIPBUTTON = 0x8;
const int SHFS_SHOWSTARTICON = 0x10;
const int SHFS_HIDESTARTICON = 0x20;
const int SWP_NOZORDER = 0x4;
private const int HHTASKBARHEIGHT = 26;
/* private const int SHFS_HIDETASKBAR = &H2;
private const int SWP_NOZORDER = &H4;*/

public static bool HideTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_HIDETASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
0, width, height + HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}

public static bool SetStartButtonVisible(bool visible, IntPtr hwnd)
{
if (hwnd.ToInt32() > 0)
{
return SHFullScreen(hwnd, visible ? SHFS_SHOWSTARTICON :
SHFS_HIDESTARTICON);
}
else
{
return false;
}
}

public static bool ShowTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_SHOWTASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
HHTASKBARHEIGHT, width, height - HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}



Engin AYDOGAN napsal:
 
E

Engin AYDOGAN

Thanks but that seems totally platform dependent. And I believe there
should be a neat and simple way of doing this.
Hi, it's possible to create a fullscreen app using SHFullScreen
function from aygshell.dll. Take a look on following code snippet:



public static bool SetTaskBarEnabled(bool enabled)
{
IntPtr hwnd = Win32Window.FindWindow("HHTaskBar", null);
return Win32Window.EnableWindow(hwnd, enabled);
}

[DllImport("aygshell.dll", EntryPoint="SHFullScreen",
SetLastError=true)]
private static extern bool SHFullScreen(IntPtr apphwnd, int state);


const int SHFS_SHOWTASKBAR = 0x1;
const int SHFS_HIDETASKBAR = 0x2;
const int SHFS_SHOWSIPBUTTON = 0x4;
const int SHFS_HIDESIPBUTTON = 0x8;
const int SHFS_SHOWSTARTICON = 0x10;
const int SHFS_HIDESTARTICON = 0x20;
const int SWP_NOZORDER = 0x4;
private const int HHTASKBARHEIGHT = 26;
/* private const int SHFS_HIDETASKBAR = &H2;
private const int SWP_NOZORDER = &H4;*/

public static bool HideTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_HIDETASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
0, width, height + HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}

public static bool SetStartButtonVisible(bool visible, IntPtr hwnd)
{
if (hwnd.ToInt32() > 0)
{
return SHFullScreen(hwnd, visible ? SHFS_SHOWSTARTICON :
SHFS_HIDESTARTICON);
}
else
{
return false;
}
}

public static bool ShowTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_SHOWTASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
HHTASKBARHEIGHT, width, height - HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}



Engin AYDOGAN napsal:
I want to make my application to use the whole screen, searched through
msdn and it suggests to use `WindowState = FormWindowState.Maximized;'
in the (only) Form of the program, but it doesn't work. I still can see
the taskbar and title bar. I've tried placing above statment to few
places (i.e. in c-tor/onLoad of the form, etc), still no go.

Any ideas ?
 
T

Tore Stensby

Engin AYDOGAN said:
I want to make my application to use the whole screen, searched through
msdn and it suggests to use `WindowState = FormWindowState.Maximized;' in
the (only) Form of the program, but it doesn't work. I still can see the
taskbar and title bar. I've tried placing above statment to few places
(i.e. in c-tor/onLoad of the form, etc), still no go.

Any ideas ?

In my app, I use this on one of my forms:
Private Sub frmSkjermLock_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.WindowState = FormWindowState.Maximized
End Sub

And i have set the property FormBorderStyle to None in the designer.



ToreS
 
E

Engin AYDOGAN

Tore said:
In my app, I use this on one of my forms:
Private Sub frmSkjermLock_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.WindowState = FormWindowState.Maximized
End Sub

And i have set the property FormBorderStyle to None in the designer.
I'm doing the same. But when I deploy (into Win CE 5.0) and start my
application, it starts like a usual app with title bar and taskbar is
visible.

I create the form and pass it to the event loop.

Application.Run(new Form1());

And

private void Form1_Load(object sender, EventArgs e)
{
System.Console.Write( "load\n" );
MinimizeBox = false;
MaximizeBox = false;
////////////////////////////////////////
WindowState = FormWindowState.Maximized;
}

It still runs like a normal app.
 
B

Buthrakaur

I see, I silently presumed you're talking about PPC platform, but
you're targetting WinCE if I understand it right. My previous snippet
is designed for PPC. If I remember right, I had to P/Invoke
SetWindowPos to fill the whole screen with my window on WinCE device.

Rectangle scrrect = Screen.PrimaryScreen.Bounds;
Win32Window.SetWindowPos(win, HWND.TOPMOST, 0, 0, scrrect.Width,
scrrect.Height, SWP.NOZORDER);



Engin AYDOGAN napsal:
Thanks but that seems totally platform dependent. And I believe there
should be a neat and simple way of doing this.
Hi, it's possible to create a fullscreen app using SHFullScreen
function from aygshell.dll. Take a look on following code snippet:



public static bool SetTaskBarEnabled(bool enabled)
{
IntPtr hwnd = Win32Window.FindWindow("HHTaskBar", null);
return Win32Window.EnableWindow(hwnd, enabled);
}

[DllImport("aygshell.dll", EntryPoint="SHFullScreen",
SetLastError=true)]
private static extern bool SHFullScreen(IntPtr apphwnd, int state);


const int SHFS_SHOWTASKBAR = 0x1;
const int SHFS_HIDETASKBAR = 0x2;
const int SHFS_SHOWSIPBUTTON = 0x4;
const int SHFS_HIDESIPBUTTON = 0x8;
const int SHFS_SHOWSTARTICON = 0x10;
const int SHFS_HIDESTARTICON = 0x20;
const int SWP_NOZORDER = 0x4;
private const int HHTASKBARHEIGHT = 26;
/* private const int SHFS_HIDETASKBAR = &H2;
private const int SWP_NOZORDER = &H4;*/

public static bool HideTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_HIDETASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
0, width, height + HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}

public static bool SetStartButtonVisible(bool visible, IntPtr hwnd)
{
if (hwnd.ToInt32() > 0)
{
return SHFullScreen(hwnd, visible ? SHFS_SHOWSTARTICON :
SHFS_HIDESTARTICON);
}
else
{
return false;
}
}

public static bool ShowTaskBarForWindow(IntPtr hwnd)
{
Rectangle rect = Win32Window.GetWindowRect(hwnd);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
SHFullScreen(hwnd, SHFS_SHOWTASKBAR);
Win32Window.SetWindowPos(hwnd, OpenNETCF.Win32.HWND.TOPMOST, 0,
HHTASKBARHEIGHT, width, height - HHTASKBARHEIGHT, SWP.NOZORDER);
return true;
}



Engin AYDOGAN napsal:
I want to make my application to use the whole screen, searched through
msdn and it suggests to use `WindowState = FormWindowState.Maximized;'
in the (only) Form of the program, but it doesn't work. I still can see
the taskbar and title bar. I've tried placing above statment to few
places (i.e. in c-tor/onLoad of the form, etc), still no go.

Any ideas ?
 
V

vikash

please remove any instance of MainMenu from the designer, hope it will
work.


thanks n regards
vikash
 

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

Similar Threads


Top