views:

42

answers:

1

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

+2  A: 

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.

Quenton Jones
hmmm. this answer is okay, but it's getting it by the window handle.I would like for them to resize the window, but they shouldn't be able to click on the task bar's size, cause the resize i have is used by a grip tool.
Kevin
@Kevin if you are mixing up `Handle` with form's resize grip, please do some reading about winapi and handlers (http://www.codeproject.com/KB/winsdk/InsideWindHandles.aspx). Here `Handle` is a pointer to the Form (or winodw) obect that is used by Windows API to interact with it and the function is removing default menu items that you get on right clicking on taskbar button.
TheVillageIdiot