Hi,
"Peter Larsen" <tj******@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
I have asked this question before, but did not get anything useful from
it - so sorry that i am asking again !!
This is the first time I see it in this NG !
How do i prevent an application from appears more than once in the ALT+TAB
menu.
As it is today, my application will show an icon for each window visible
in
the running application. I only want one icon.
This is what I would do:
1- Detect if another instance of my app is running ( posted many times
here )
2- If an instance is running hide the new instance from the ALT+TAB ( code
posted below).
The problem may be in hiding it, the code use Set/GetWindowLong which IIRC
will affect ALL the instances of that particular window , please somebody
correct me if I'm wrong.
Anyway, you could just try it
Now, I do hope you have a strong reason for doing this, I would be very
surprise knowing I have 10 instances open of IE and seeing only one in the
list.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
[DllImport("user32.dll")]
public static extern int SetWindowLong( IntPtr window, int index, int
value);
[DllImport("user32.dll")]
public static extern int GetWindowLong( IntPtr window, int index);
const int GWL_EXSTYLE = -20;
const int WS_EX_TOOLWINDOW = 0x00000080;
const int WS_EX_APPWINDOW = 0x00040000;
private System.Windows.Forms.NotifyIcon notifyIcon1;
// I use two icons depending of the status of the app
normalIcon = new Icon(this.GetType(),"Normal.ico");
alertIcon = new Icon(this.GetType(),"Alert.ico");
notifyIcon1.Icon = normalIcon;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Visible = false;
this.ShowInTaskbar = false;
iconTimer.Start();
//Make it gone frmo the ALT+TAB
int windowStyle = GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);