views:

174

answers:

2

Code:

    [DllImport("AYGShell.dll")]
    static extern Int32 SHFullScreen(IntPtr hwndRequester, UInt32 dwState);

    public const UInt32 SHFS_SHOWSIPBUTTON = 0x0004;
    public const UInt32 SHFS_HIDESIPBUTTON = 0x0008;

    public Form1()
    {
        InitializeComponent();
    }

    private void OnPaint(object sender, PaintEventArgs e)
    {
        HideSipButton();
    }

    private void HideSipButton()
    {
        UInt32 dwState = SHFS_HIDESIPBUTTON;//: SHFS_SHOWSIPBUTTON;
        SHFullScreen(this.Handle, dwState);
    }

HI, above code works fine in the first launch of a form in windowsmobile, it hides the sip button of a form in windows mobile, but if i click on the menu bar sip-button reappears.. i dont no how to eliminate the sip button completely.. please help me how to fix this..

i ment i dont want sip button at all for a form in windowsmobile.. i am using .net CF

Thanks

+1  A: 

When you say you click on the "menu bar" are you talking about a custom bar you've written or the standard bar (the one with the start menu, clock, etc.) at the top of all programs (except full screen ones)?

If you're talking about the normal start menu bar, when you click on it your program is no longer the active one, which is why the SIP button is redrawn. If that's the case you may be able to use the Activated event to try to hide the SIP button again.

Extra note: This code will only re-hide the SIP button when the user clicks in your form again, it will not run until that happens.

Here's an idea on what I'm describing:

public Form1()
{
  InitializeComponent();
  this.Activated += new EventHandler(Form1_Activated);
}

private void Form1_Activated(object sender, EventArgs e)
{
  HideSipButton();
}

private void OnPaint(object sender, PaintEventArgs e)
{
  HideSipButton();
}
Joshua
Hey it works.. only in first instance.. and if i click first SIP button appears, then if i click over SIP button it will call paint event, then again it will be hidden.. when i click on the Menubar neither form activate nor paint event will not come.
Shadow
A: 

Override the Form.OnActivated method and call HideSipButton. E.x.:

protected override void OnActivated(EventArgs e)
{
  HideSipButton();
  return base.Equals(e);
}
hjb417
Why override it when you can just attach to the event?
Joshua
From the 'Remarks' section. "The OnActivated method also allows derived classes to handle the event without attaching a delegate. Overriding this method is the preferred technique for handling the event in a derived class." - http://msdn.microsoft.com/en-us/library/system.windows.forms.form.onactivated.aspx
hjb417
Interesting, I did not know that.
Joshua