SHFullscreen: can hide Start Menu but not Taskbar. Help!

B

Beau Randall

I've scoured usenet trying to find out how to make an app run in kiosk
mode.

From what I've seen the following should produce my desired result,
that is remove the taskbar and start menu from the app, but it only
removes the start menu. I've spent a half day playing with this code
to no avail, could someone use this to make a test CF app and see
what's wrong here? Or a working sample, but keep in mind I culled
this from supposedly working samples...

Thanks. - Beau

*****************************************************************************

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

namespace KioskTest
{
public class SHAPI
{
public const int SHFS_SHOWTASKBAR = 1;
public const int SHFS_HIDETASKBAR = 2;
public const int SHFS_SHOWSIPBUTTON = 4;
public const int SHFS_HIDESIPBUTTON = 8;
public const int SHFS_SHOWSTARTICON = 16;
public const int SHFS_HIDESTARTICON = 32;

[DllImport("aygshell.dll")]
private extern static bool SHFullScreen(IntPtr hWnd, int dwState);

public static bool FullScreen(IntPtr hWnd)
{
return SHFullScreen(hWnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR);
}

[DllImport("coredll.dll")]
internal static extern int SetForegroundWindow(IntPtr hWnd);

}

public class API
{
[DllImport("coredll.dll", EntryPoint="FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string
lpWindowName);

public static IntPtr FindWindow(string windowName)
{
return FindWindow(null, windowName);
}
}

public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
System.Windows.Forms.Button button1 = new
System.Windows.Forms.Button();
button1.Location = new System.Drawing.Point(48, 80);
button1.Size = new System.Drawing.Size(128, 48);
button1.Text = "button1";
button1.Click += new System.EventHandler(this.button1_Click);
this.Controls.Add(button1);

this.ClientSize = new System.Drawing.Size(240, 320);
this.Text = "KioskMode";

}

protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}

static void Main()
{
System.Windows.Forms.Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
IntPtr hWnd = API.FindWindow(this.Text);
if(hWnd != IntPtr.Zero)
{
this.MaximizeBox = false;

this.MinimizeBox = false;

this.Focus();

SHAPI.SetForegroundWindow(hWnd);
SHAPI.FullScreen(hWnd);
}
}
}
}
 
C

C Enright

All you should need to do is remove the MainMenu control
from the applications main form. Then in the form load
event:

this.WindowState = FormWindowState.Maximized;

This will give you a full screen mode....


-----Original Message-----
I've scoured usenet trying to find out how to make an app run in kiosk
mode.

From what I've seen the following should produce my desired result,
that is remove the taskbar and start menu from the app, but it only
removes the start menu. I've spent a half day playing with this code
to no avail, could someone use this to make a test CF app and see
what's wrong here? Or a working sample, but keep in mind I culled
this from supposedly working samples...

Thanks. - Beau

********************************************************* ********************

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

namespace KioskTest
{
public class SHAPI
{
public const int SHFS_SHOWTASKBAR = 1;
public const int SHFS_HIDETASKBAR = 2;
public const int SHFS_SHOWSIPBUTTON = 4;
public const int SHFS_HIDESIPBUTTON = 8;
public const int SHFS_SHOWSTARTICON = 16;
public const int SHFS_HIDESTARTICON = 32;

[DllImport("aygshell.dll")]
private extern static bool SHFullScreen (IntPtr hWnd, int dwState);

public static bool FullScreen(IntPtr hWnd)
{
return SHFullScreen(hWnd,
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR);
}

[DllImport("coredll.dll")]
internal static extern int
SetForegroundWindow(IntPtr hWnd);
}

public class API
{
[DllImport("coredll.dll", EntryPoint="FindWindow")]
private extern static IntPtr FindWindow (string lpClassName, string
lpWindowName);

public static IntPtr FindWindow(string windowName)
{
return FindWindow(null, windowName);
}
}

public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
System.Windows.Forms.Button button1 = new
System.Windows.Forms.Button();
button1.Location = new System.Drawing.Point(48, 80);
button1.Size = new System.Drawing.Size(128, 48);
button1.Text = "button1";
button1.Click += new System.EventHandler(this.button1_Click);
this.Controls.Add(button1);

this.ClientSize = new System.Drawing.Size(240, 320);
this.Text = "KioskMode";

}

protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}

static void Main()
{
System.Windows.Forms.Application.Run(new Form1());
 
B

Beau Randall

Thanks for the response.

I've seen mentions of this and had tried it but it did not work for me.
Then again I did not play with the MainMenu

I've created a bare bones app, removed the MainMenu (which I actually
need), and set this problem. Still nothing, both the taskbar and
mainmenu remain. I should probably mention I'm using I'm using PPC 2002
w/ VS.NET 2003.

Could you post a program which literally works that I could cut and
paste?

For this test this is all have in InitializeComponent -

private void InitializeComponent()
{
this.WindowState = FormWindowState.Maximized;
this.Text = "Form1";
}
 
B

Beau Randall

Got it. I had to use MoveWindow to reposition the window over the
taskbar - which indeed had been moved to the background.
 
Joined
Aug 30, 2010
Messages
2
Reaction score
0
hi Beau Randall

i tried your code and it's run perfectly,
but i need to disappear start menu for all of application.

history:
i develop lock screen for handheld when i open and i need to disappear start menu only not task bar ,when i tried you code ,it's run prefectly.
but when open onther program such as MobileCalculator.exe , the start menu it appear agian. please help me
 

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