Kevin
Kevin

Reputation: 3509

C# Programmatically disabling Taskbar functionality

When you open internet explorer or mozilla, a new task in the task bar pops out.

When you right click this taskbar item it saids

Restore, move, size, minimize, maximize, close.

Now i have an application that does not use size, minimize,maximize or close.

Can someone give me a quick lead or heads up in order to disable them?

Thanks in advance -Kevin

Upvotes: 1

Views: 2704

Answers (1)

Quentamia
Quentamia

Reputation: 3274

You can use the SetWindowLong function (http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx).

[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

int GwlStyle = -16;       // GWL_STYLE 
int WsSysMenu = 0x80000;  // WS_POPUP

var hwnd = new WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GwlStyle, GetWindowLong(hwnd, GwlStyle) & ~WsSysMenu);

Check the above link for more information about what the values of GwlStyle and WsSysMenu indicate. This will style the window to be a popup window. However, this also removes the close, maximize, and minimize buttons from the top-right.

Upvotes: 2

Related Questions