4

Believe me, I have Googled it and expected it to be a fairly easy find - turns out it isn't. I have my window handle, but no form. How do I do it? Thanks!

Lazlo
  • 8,518
  • 14
  • 77
  • 116

2 Answers2

8

Declare these:

 [DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private const int GWL_EX_STYLE = -20;
private const int WS_EX_APPWINDOW = 0x00040000, WS_EX_TOOLWINDOW = 0x00000080;

And then use this before the form is shown:


SetWindowLong(handle, GWL_EX_STYLE, (GetWindowLong(handle, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);

(change handle to whatever your window handle is stored in)

Joel Rein
  • 3,608
  • 1
  • 26
  • 32
3

Set Form's ShowInTaskbar property to false.

kvetinac
  • 41
  • 1