M
maximilian
hallo
how can i disable the systemmenu with c#
how can i disable the systemmenu with c#
Jim Wilson said:Just to clarify, when you say "disable the system menu" do you mean the
Pocket PC pull-down "start" menu (shown when a user clicks in the top-left
corner of the screen)? If that's the case there are basically 2 ways to get
rid of it.
[The complete answer is pretty long so I'll split it into two parts]
Part I: The easiest way is to display your application form in fullscreen
mode.
class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Menu = null; // Must get rid of menu for Maximized to take affect
this.WindowState = FormWindowState.Maximized; // Set window to
Mazimized
}
// ...
}
[Continued in next message]
maximilian said:hallo
how can i disable the systemmenu with c#
Jim Wilson said:Just to clarify, when you say "disable the system menu" do you mean the
Pocket PC pull-down "start" menu (shown when a user clicks in the top-left
corner of the screen)? If that's the case there are basically 2 ways to get
rid of it.
[The complete answer is pretty long so I'll split it into two parts]
Part I: The easiest way is to display your application form in fullscreen
mode.
class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Menu = null; // Must get rid of menu for Maximized to take affect
this.WindowState = FormWindowState.Maximized; // Set window to
Mazimized
}
// ...
}
[Continued in next message]
maximilian said:hallo
how can i disable the systemmenu with c#
Jim Wilson said:[Part II]
The problem with the full screen solution I offered in my other message is
that your application form hides everything including the application menu
bar and SIP button (in fact attempting to show the SIP using the InputPanel
control will actually throw an exception).
If you want less of a "sledgehammer" approach, you can use P/Invoke to hide
the start icon (no start icon equals no start menu) using the WinCE SDK
method SHFullScreen. The name is a little misleading as the method performs
several screen-related actions including hiding the start menu.
Of course the challenge of SHFullScreen is that it requires the Form window
handle to do its job; unfortunatly .NET CF 1.0 does not expose the Form
window handle (.NET CF 2.0 adds the Control property which does contain the
handle). To get the handle we use the FindWindow method. Using Remote Spy++
we find that the .NET CF Form class uses the class name "#NETCF_AGL_BASE_".
Armed with this information, we can write the following helper class:
public class SHFullScreenHelper
{
private const Int32 SHFS_SHOWSTARTICON = 0x0010;
private const Int32 SHFS_HIDESTARTICON = 0x0020;
private const string formWindowClassName = "#NETCF_AGL_BASE_" ;
[DllImport("aygshell.dll")]
private static extern Int32 SHFullScreen(IntPtr hWnd, Int32 dwState) ;
[DllImport("coredll.dll")]
private static extern IntPtr FindWindow(string className, string
windowName) ;
private static IntPtr GetWindowHandle(Form f)
{
return FindWindow(formWindowClassName, f.Text);
}
// This is only method we need to call - the other stuff is just helpers
public static bool ShowStartIcon(Form f, bool bShow)
{
Int32 dwFlag = bShow ? SHFS_SHOWSTARTICON : SHFS_HIDESTARTICON ;
return SHFullScreen(GetWindowHandle(f), dwFlag) != 0;
}
}
Using the class, we can get rid of the start menu like this:
class Form1 : Form
{
public Form1()
{
InitliazeComponent();
SHFullScreenHelper.ShowStartIcon(this, false); // hide start icon
}
}
So its kind of a long story, but once the SHFullScreenHelper class is in
place, you can hide or show the start icon (and therefore the start menu)
just by calling the ShowStartIcon method.
Hope this helps.
Jim Wilson, eMVP
http://www.jwhh.com
Jim Wilson said:Just to clarify, when you say "disable the system menu" do you mean the
Pocket PC pull-down "start" menu (shown when a user clicks in the top-left
corner of the screen)? If that's the case there are basically 2 ways to get
rid of it.
[The complete answer is pretty long so I'll split it into two parts]
Part I: The easiest way is to display your application form in fullscreen
mode.
class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Menu = null; // Must get rid of menu for Maximized to take affect
this.WindowState = FormWindowState.Maximized; // Set window to
Mazimized
}
// ...
}
[Continued in next message]
maximilian said:hallo
how can i disable the systemmenu with c#