Hi Frank,
Thanks for your post!!
I think Eric has provided you half of the solution
Actually, whether a Window(In .Net, this is called Form) will appear in
Alt+Tab list can be determined by its extended window style. For a detailed
description of "Extended Window Styles", please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/htm
l/_mfc_extended_window_styles.asp
In the above reference, you will see that:
WS_EX_APPWINDOW: Forces a top-level window onto the taskbar when the window
is visible.
WS_EX_TOOLWINDOW: Creates a tool window, which is a window intended to be
used as a floating toolbar. A tool window has a title bar that is shorter
than a normal title bar, and the window title is drawn using a smaller
font. A tool window does not appear in the task bar or in the window that
appears when the user presses ALT+TAB.
So if we get rid of a window(Form)'s WS_EX_APPWINDOW style and then apply
WS_EX_TOOLWINDOW to it, we can get what we want. In .Net a Form's style and
extended style can be changed through overriding CreateParams property,
like below:
//Suppose Form2 is the splash window
private const int WS_EX_TOOLWINDOW= 0x00000080;
private const int WS_EX_APPWINDOW=0x00040000;
protected override CreateParams CreateParams
{
get
{
CreateParams cp=base.CreateParams;
cp.ExStyle=cp.ExStyle&(~WS_EX_APPWINDOW);
cp.ExStyle=cp.ExStyle|WS_EX_TOOLWINDOW;
return cp;
}
}
//In Main app(Form1)
public Form1()
{
Thread t=new Thread(new ThreadStart(ThreadProc));
t.Start();
System.Threading.Thread.Sleep(5000);
InitializeComponent();
}
private void ThreadProc()
{
Form2 f=new Form2();
f.FormBorderStyle=FormBorderStyle.None;
Application.Run(f);
}
Why I say Eric gives you the half solution? Because .Net encapsulate
WS_EX_APPWINDOW style as ShowInTaskbar property, so if we set
ShowInTaskbar=false, we can get rid of this line:
cp.ExStyle=cp.ExStyle&(~WS_EX_APPWINDOW). They are the same effect.
At last, if you want to hide an already existed window from Alt+Tab list,
you can p/invoke SetWindowLong/GetWindowLong Win32 Api to change it
extended window style.
The above code works well on my side. Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.