ContextMenuStrip has an offset when application is running in full screen mode

Hi,

I have an application running in full screen mode. The main form contains a ContextMenuStrip that is shown when the user clicks on the form. There is an offset between the location where the context menu appears and where it should appear.

Here’s the problem. I hope someone can give me a workaround.

In order to compute the location of the context menu, the working area is taken into account, even if the application is running in full screen mode. If the location where the user clicked falls in a region that is outside of the working area, the context menu automatically offset its position so it is displayed in the working area. Of course, this does not make sense when the application is running in full screen mode since the working area equals the screen area.

It is fairly easy to reproduce:

1- Modify the size of your taskbar so it takes half of your screen area

2- Launch your full screen application (see code below)

3- Try to make a context menu appear in the area where the taskbar would normally be displayed. The context menu should have an offset...

Can anyone help me

Thanks

using System;
using System.Drawing;
using System.Windows.Forms;

public class FS : Form
{
[STAThread]
static void Main()
{
Application.Run(new FS());
}

private ContextMenuStrip cms = new ContextMenuStrip();

public FS()
{
cms.Items.Add("Item");
cms.Items[0].Click += new EventHandler(OnItemClick);

this.FormBorderStyle = FormBorderStyle.None;

this.ControlBox = false;
this.MaximizeBox = false;
this.MinimizeBox = false;
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

Rectangle rectBounds = Screen.GetBounds(this);
rectBounds.Location = Point.Empty;

MaximizedBounds = rectBounds;

WindowState = FormWindowState.Maximized;
}

protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
cms.Show(e.X, e.Y);
}

private void OnItemClick(object sender, EventArgs e)
{
this.Close();
}
}




Answer this question

ContextMenuStrip has an offset when application is running in full screen mode

  • Arcadian

    I tried this and I do not find any way to make it display over the taskbar even that the window is maximized over the whole desktop.

    I even tried hiding the taskbar (WM_HIDE) but same result.

    I peeked around in the ContextMenuStrip code using reflector and found a few flags that seemed to be connected but I found no way to manipulate those. There is probably a really obvious way to enable it but at this moment I have no clue.

    If you find a solution please post it as I got quite curious what it might be.



  • ContextMenuStrip has an offset when application is running in full screen mode