471,325 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Program icons in the ALT+TAB menu

Hi,
I have asked this question before, but did not get anything useful from it -
so sorry that i am asking again !!

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.

And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

Thank you in advance.
Peter

Jan 13 '06 #1
9 6544
Peter,

Are you saying you want more than one application instance to run, but
just one icon in the alt-tab list?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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 !!

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.

And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

Thank you in advance.
Peter

Jan 13 '06 #2
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);
Jan 13 '06 #3
I think he's saying that he has one application running only once with
numerous windows open (that are visible in the taskbar) --- so when the user
hits alt-tab, the application shows up a bunch of times - once for each
window open that is visible in the task bar. This is the default behavior
of other windows apps, so I think he wants to know if there is a way to
override that default behavior.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2******************@TK2MSFTNGP11.phx.gbl...
Peter,

Are you saying you want more than one application instance to run, but
just one icon in the alt-tab list?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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 !!

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.

And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

Thank you in advance.
Peter


Jan 13 '06 #4
No - one application with multiple visible forms - but only apearing once in
the ALT+TAB menu !

Did i really say so ??

/Peter :-)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2******************@TK2MSFTNGP11.phx.gbl...
Peter,

Are you saying you want more than one application instance to run, but
just one icon in the alt-tab list?
--

Jan 13 '06 #5
You are talking about one application started more than once - this is not
my question.
I'm talking about ONE application with more than one window visible.

/Peter :-)

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:Op**************@TK2MSFTNGP11.phx.gbl...
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);

Jan 13 '06 #6
Thats right !!

"Brett Wickard" <br**********@nospam.nospam> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
I think he's saying that he has one application running only once with
numerous windows open (that are visible in the taskbar) --- so when the
user hits alt-tab, the application shows up a bunch of times - once for
each window open that is visible in the task bar. This is the default
behavior of other windows apps, so I think he wants to know if there is a
way to override that default behavior.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Peter,

Are you saying you want more than one application instance to run, but
just one icon in the alt-tab list?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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 !!

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.

And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

Thank you in advance.
Peter



Jan 13 '06 #7
"Peter Larsen" <tj******@gmail.com> wrote in
news:#Y**************@tk2msftngp13.phx.gbl:
How do i prevent an application from appears more than once in the
ALT+TAB menu.


I presume you are opening the windows with Show(). When you call Show,
pass the owning form as a parameter:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
// Form2 defined elsewhere
Form2 f = new Form2();
f.Show(this);
}
}

This works, but I don't know what other side effects it might have.

-mdb
Jan 13 '06 #8
Peter,
And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

I don't know what other suggestion can be made. The ALT+TAB list shows
windows that appear in the task bar. I don't know how you can solve the
problem if you don't want to hide your windows from the task bar.

--

Stoitcho Goutsev (100)


"Peter Larsen" <tj******@gmail.com> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl... Thats right !!

"Brett Wickard" <br**********@nospam.nospam> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
I think he's saying that he has one application running only once with
numerous windows open (that are visible in the taskbar) --- so when the
user hits alt-tab, the application shows up a bunch of times - once for
each window open that is visible in the task bar. This is the default
behavior of other windows apps, so I think he wants to know if there is a
way to override that default behavior.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Peter,

Are you saying you want more than one application instance to run,
but just one icon in the alt-tab list?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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 !!

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.

And please - i'm not talking about the taskbar and/or property
ShowInTaskbar. I already know this and it does not solve my
problem/question.

Thank you in advance.
Peter




Jan 13 '06 #9
Great this works :-)
Thanks for your time, Michael, and thanks to you all for participating.

/Peter :-)

"Michael Bray" <mbray@makeDIntoDot_ctiusaDcom> wrote in message
news:Xn****************************@207.46.248.16. ..
"Peter Larsen" <tj******@gmail.com> wrote in
news:#Y**************@tk2msftngp13.phx.gbl:
How do i prevent an application from appears more than once in the
ALT+TAB menu.


I presume you are opening the windows with Show(). When you call Show,
pass the owning form as a parameter:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
// Form2 defined elsewhere
Form2 f = new Form2();
f.Show(this);
}
}

This works, but I don't know what other side effects it might have.

-mdb

Jan 13 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Adam J. Schaff | last post: by
5 posts views Thread by kh | last post: by
reply views Thread by Gary Brown | last post: by
reply views Thread by claudioillanes | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.