473,508 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tray Icon Problem

Hi,

I have a form with a tray icon. However, when I minimize the form, it
stays visible - not in the task bar (I have showintaskbar property set
to false), but in a form of a rectangle sitting above the task bar.
Can't figure out why that happens - it looks very ugly...

Any ideas ?

Zeljko
Nov 15 '05 #1
10 2542
When you minimize the form you must also set the Visible property to false

this.Visible = false;
HTH
Brian W
"Zeljko" <tr*******@yahoo.com> wrote in message
news:0d********************************@4ax.com...
Hi,

I have a form with a tray icon. However, when I minimize the form, it
stays visible - not in the task bar (I have showintaskbar property set
to false), but in a form of a rectangle sitting above the task bar.
Can't figure out why that happens - it looks very ugly...

Any ideas ?

Zeljko

Nov 15 '05 #2
But If I do that, I don't see tray icon anymore and can't maximize the
form again ?

Zeljko
On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
When you minimize the form you must also set the Visible property to false

this.Visible = false;
HTH
Brian W
"Zeljko" <tr*******@yahoo.com> wrote in message
news:0d********************************@4ax.com.. .
Hi,

I have a form with a tray icon. However, when I minimize the form, it
stays visible - not in the task bar (I have showintaskbar property set
to false), but in a form of a rectangle sitting above the task bar.
Can't figure out why that happens - it looks very ugly...

Any ideas ?

Zeljko


Nov 15 '05 #3
No, it won't, the tray icon remains visible. Have you tried?

You restore the form in response to a click on the icon.

"Zeljko" <tr*******@yahoo.com> wrote in message
news:nh********************************@4ax.com...
But If I do that, I don't see tray icon anymore and can't maximize the
form again ?

Zeljko
On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
When you minimize the form you must also set the Visible property to false
this.Visible = false;
HTH
Brian W
"Zeljko" <tr*******@yahoo.com> wrote in message
news:0d********************************@4ax.com.. .
Hi,

I have a form with a tray icon. However, when I minimize the form, it
stays visible - not in the task bar (I have showintaskbar property set
to false), but in a form of a rectangle sitting above the task bar.
Can't figure out why that happens - it looks very ugly...

Any ideas ?

Zeljko

Nov 15 '05 #4
Yes, I have tried. tray icon becomes invisible, and there is nothing I
can click on to make it visible again.

Zeljko
On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
No, it won't, the tray icon remains visible. Have you tried?

You restore the form in response to a click on the icon.

"Zeljko" <tr*******@yahoo.com> wrote in message
news:nh********************************@4ax.com.. .
But If I do that, I don't see tray icon anymore and can't maximize the
form again ?

Zeljko
On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
>When you minimize the form you must also set the Visible property tofalse >
> this.Visible = false;
>
>
>HTH
>Brian W
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:0d********************************@4ax.com.. .
>> Hi,
>>
>> I have a form with a tray icon. However, when I minimize the form, it
>> stays visible - not in the task bar (I have showintaskbar property set
>> to false), but in a form of a rectangle sitting above the task bar.
>> Can't figure out why that happens - it looks very ugly...
>>
>> Any ideas ?
>>
>> Zeljko
>


Nov 15 '05 #5
This technique has always worked for me, and is working here now. Have you
assigned an Icon to the icon property of your notifyicon object.

Can you post a small, complete example that reproduces this behavior?
Regards
Brian W

"Zeljko" <tr*******@yahoo.com> wrote in message
news:46********************************@4ax.com...
Yes, I have tried. tray icon becomes invisible, and there is nothing I
can click on to make it visible again.

Zeljko
On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
No, it won't, the tray icon remains visible. Have you tried?

You restore the form in response to a click on the icon.

"Zeljko" <tr*******@yahoo.com> wrote in message
news:nh********************************@4ax.com.. .
But If I do that, I don't see tray icon anymore and can't maximize the
form again ?

Zeljko
On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:

>When you minimize the form you must also set the Visible property to

false
>
> this.Visible = false;
>
>
>HTH
>Brian W
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:0d********************************@4ax.com.. .
>> Hi,
>>
>> I have a form with a tray icon. However, when I minimize the form, it >> stays visible - not in the task bar (I have showintaskbar property set >> to false), but in a form of a rectangle sitting above the task bar.
>> Can't figure out why that happens - it looks very ugly...
>>
>> Any ideas ?
>>
>> Zeljko
>

Nov 15 '05 #6
Sure - here it is:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//PENDING_ICON etc are string constants - I added 3 icons to
the app, changing current notify icon based on the status of a windows
service
micoPending = new Icon(typeof(Form1), PENDING_ICON);
micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

}

protected override void OnLayout(LayoutEventArgs levent)
{

switch (WindowState){
case FormWindowState.Minimized:
this.WindowState = FormWindowState.Minimized;
this.Hide();
break;
case FormWindowState.Maximized:
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
break;
}
base.OnLayout (levent);
}


On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
This technique has always worked for me, and is working here now. Have you
assigned an Icon to the icon property of your notifyicon object.

Can you post a small, complete example that reproduces this behavior?
Regards
Brian W

"Zeljko" <tr*******@yahoo.com> wrote in message
news:46********************************@4ax.com.. .
Yes, I have tried. tray icon becomes invisible, and there is nothing I
can click on to make it visible again.

Zeljko
On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
>No, it won't, the tray icon remains visible. Have you tried?
>
>You restore the form in response to a click on the icon.
>
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:nh********************************@4ax.com.. .
>> But If I do that, I don't see tray icon anymore and can't maximize the
>> form again ?
>>
>> Zeljko
>> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
>> <brianw@gold_death_2_spam_rush.com> wrote:
>>
>> >When you minimize the form you must also set the Visible property to
>false
>> >
>> > this.Visible = false;
>> >
>> >
>> >HTH
>> >Brian W
>> >
>> >
>> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >news:0d********************************@4ax.com.. .
>> >> Hi,
>> >>
>> >> I have a form with a tray icon. However, when I minimize the form,it >> >> stays visible - not in the task bar (I have showintaskbar propertyset >> >> to false), but in a form of a rectangle sitting above the task bar.
>> >> Can't figure out why that happens - it looks very ugly...
>> >>
>> >> Any ideas ?
>> >>
>> >> Zeljko
>> >
>>
>


Nov 15 '05 #7
Sorry, this is not complete, for example it does not show me what is going
on in InitializeComponent(), and does not show me what you are doing with
micoPending, micoRunning & micoStopped. The example also does not show me
how you are responding to either the Click or DoubleClick events of the
NotifyIcon object. For that matter it doesn't show that you even have a
TrayIcon object.

With all that said, if I add your code to mine the window minimizes and
hides with the tray icon still visible. So I'm sorry to say it still works
for me here.

Paste the following code as your form make sure you assign an icon to the
NotifyIcon object, then tell me if this works for you.
Regards
Brian W

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.NotifyIcon notifyIcon1;

private System.ComponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

//

// notifyIcon1

//

this.notifyIcon1.Icon =
((System.Drawing.Icon)(resources.GetObject("notify Icon1.Icon")));

this.notifyIcon1.Text = "notifyIcon1";

this.notifyIcon1.Visible = true;

this.notifyIcon1.DoubleClick += new
System.EventHandler(this.notifyIcon1_DoubleClick);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Name = "Form1";

this.Text = "Form1";

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_SizeChanged(object sender, System.EventArgs e)

{

if ( this.WindowState == FormWindowState.Minimized )

this.Hide();

else

this.Show();

}

private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)

{

this.Show();

}

}

"Zeljko" <tr*******@yahoo.com> wrote in message
news:pu********************************@4ax.com...
Sure - here it is:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//PENDING_ICON etc are string constants - I added 3 icons to
the app, changing current notify icon based on the status of a windows
service
micoPending = new Icon(typeof(Form1), PENDING_ICON);
micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

}

protected override void OnLayout(LayoutEventArgs levent)
{

switch (WindowState){
case FormWindowState.Minimized:
this.WindowState = FormWindowState.Minimized;
this.Hide();
break;
case FormWindowState.Maximized:
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
break;
}
base.OnLayout (levent);
}


On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
This technique has always worked for me, and is working here now. Have youassigned an Icon to the icon property of your notifyicon object.

Can you post a small, complete example that reproduces this behavior?
Regards
Brian W

"Zeljko" <tr*******@yahoo.com> wrote in message
news:46********************************@4ax.com.. .
Yes, I have tried. tray icon becomes invisible, and there is nothing I
can click on to make it visible again.

Zeljko
On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:

>No, it won't, the tray icon remains visible. Have you tried?
>
>You restore the form in response to a click on the icon.
>
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:nh********************************@4ax.com.. .
>> But If I do that, I don't see tray icon anymore and can't maximize the >> form again ?
>>
>> Zeljko
>> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
>> <brianw@gold_death_2_spam_rush.com> wrote:
>>
>> >When you minimize the form you must also set the Visible property to >false
>> >
>> > this.Visible = false;
>> >
>> >
>> >HTH
>> >Brian W
>> >
>> >
>> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >news:0d********************************@4ax.com.. .
>> >> Hi,
>> >>
>> >> I have a form with a tray icon. However, when I minimize the form,
it
>> >> stays visible - not in the task bar (I have showintaskbar
propertyset
>> >> to false), but in a form of a rectangle sitting above the task

bar. >> >> Can't figure out why that happens - it looks very ugly...
>> >>
>> >> Any ideas ?
>> >>
>> >> Zeljko
>> >
>>
>

Nov 15 '05 #8
Hi,

Sorry if this code was incomplete - I left out only the obvious things
- setting icon property of notify icon to one of the 3 icons,
generated code in Initializecomponent etc.

Anyhow - in the meantime, I solved the problem by moving my hide /
minimize code from Layout to Resize event. For some reason it works
that way :)

I'm not sure why it didn't work before - if u have any ideas, I'd be
interested in hearing them :)

Zeljko

On Wed, 19 Nov 2003 10:23:41 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
Sorry, this is not complete, for example it does not show me what is going
on in InitializeComponent(), and does not show me what you are doing with
micoPending, micoRunning & micoStopped. The example also does not show me
how you are responding to either the Click or DoubleClick events of the
NotifyIcon object. For that matter it doesn't show that you even have a
TrayIcon object.

With all that said, if I add your code to mine the window minimizes and
hides with the tray icon still visible. So I'm sorry to say it still works
for me here.

Paste the following code as your form make sure you assign an icon to the
NotifyIcon object, then tell me if this works for you.
Regards
Brian W

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.NotifyIcon notifyIcon1;

private System.ComponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1)) ;

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

//

// notifyIcon1

//

this.notifyIcon1.Icon =
((System.Drawing.Icon)(resources.GetObject("notif yIcon1.Icon")));

this.notifyIcon1.Text = "notifyIcon1";

this.notifyIcon1.Visible = true;

this.notifyIcon1.DoubleClick += new
System.EventHandler(this.notifyIcon1_DoubleClick) ;

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Name = "Form1";

this.Text = "Form1";

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_SizeChanged(object sender, System.EventArgs e)

{

if ( this.WindowState == FormWindowState.Minimized )

this.Hide();

else

this.Show();

}

private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)

{

this.Show();

}

}

"Zeljko" <tr*******@yahoo.com> wrote in message
news:pu********************************@4ax.com.. .
Sure - here it is:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//PENDING_ICON etc are string constants - I added 3 icons to
the app, changing current notify icon based on the status of a windows
service
micoPending = new Icon(typeof(Form1), PENDING_ICON);
micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

}

protected override void OnLayout(LayoutEventArgs levent)
{

switch (WindowState){
case FormWindowState.Minimized:
this.WindowState = FormWindowState.Minimized;
this.Hide();
break;
case FormWindowState.Maximized:
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
break;
}
base.OnLayout (levent);
}


On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
>This technique has always worked for me, and is working here now. Haveyou >assigned an Icon to the icon property of your notifyicon object.
>
>Can you post a small, complete example that reproduces this behavior?
>
>
>Regards
>Brian W
>
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:46********************************@4ax.com.. .
>> Yes, I have tried. tray icon becomes invisible, and there is nothing I
>> can click on to make it visible again.
>>
>> Zeljko
>> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
>> <brianw@gold_death_2_spam_rush.com> wrote:
>>
>> >No, it won't, the tray icon remains visible. Have you tried?
>> >
>> >You restore the form in response to a click on the icon.
>> >
>> >
>> >
>> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >news:nh********************************@4ax.com.. .
>> >> But If I do that, I don't see tray icon anymore and can't maximizethe >> >> form again ?
>> >>
>> >> Zeljko
>> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
>> >> <brianw@gold_death_2_spam_rush.com> wrote:
>> >>
>> >> >When you minimize the form you must also set the Visible propertyto >> >false
>> >> >
>> >> > this.Visible = false;
>> >> >
>> >> >
>> >> >HTH
>> >> >Brian W
>> >> >
>> >> >
>> >> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >> >news:0d********************************@4ax.com.. .
>> >> >> Hi,
>> >> >>
>> >> >> I have a form with a tray icon. However, when I minimize theform, >it
>> >> >> stays visible - not in the task bar (I have showintaskbarproperty >set
>> >> >> to false), but in a form of a rectangle sitting above the taskbar. >> >> >> Can't figure out why that happens - it looks very ugly...
>> >> >>
>> >> >> Any ideas ?
>> >> >>
>> >> >> Zeljko
>> >> >
>> >>
>> >
>>
>


Nov 15 '05 #9
Lou
How do you assign an icon?
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:Og**************@TK2MSFTNGP10.phx.gbl...
Sorry, this is not complete, for example it does not show me what is going
on in InitializeComponent(), and does not show me what you are doing with
micoPending, micoRunning & micoStopped. The example also does not show me
how you are responding to either the Click or DoubleClick events of the
NotifyIcon object. For that matter it doesn't show that you even have a
TrayIcon object.

With all that said, if I add your code to mine the window minimizes and
hides with the tray icon still visible. So I'm sorry to say it still works
for me here.

Paste the following code as your form make sure you assign an icon to the
NotifyIcon object, then tell me if this works for you.
Regards
Brian W

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.NotifyIcon notifyIcon1;

private System.ComponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

//

// notifyIcon1

//

this.notifyIcon1.Icon =
((System.Drawing.Icon)(resources.GetObject("notify Icon1.Icon")));

this.notifyIcon1.Text = "notifyIcon1";

this.notifyIcon1.Visible = true;

this.notifyIcon1.DoubleClick += new
System.EventHandler(this.notifyIcon1_DoubleClick);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Name = "Form1";

this.Text = "Form1";

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_SizeChanged(object sender, System.EventArgs e)

{

if ( this.WindowState == FormWindowState.Minimized )

this.Hide();

else

this.Show();

}

private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)

{

this.Show();

}

}

"Zeljko" <tr*******@yahoo.com> wrote in message
news:pu********************************@4ax.com...
Sure - here it is:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//PENDING_ICON etc are string constants - I added 3 icons to
the app, changing current notify icon based on the status of a windows
service
micoPending = new Icon(typeof(Form1), PENDING_ICON);
micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

}

protected override void OnLayout(LayoutEventArgs levent)
{

switch (WindowState){
case FormWindowState.Minimized:
this.WindowState = FormWindowState.Minimized;
this.Hide();
break;
case FormWindowState.Maximized:
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
break;
}
base.OnLayout (levent);
}


On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:
This technique has always worked for me, and is working here now. Have youassigned an Icon to the icon property of your notifyicon object.

Can you post a small, complete example that reproduces this behavior?
Regards
Brian W

"Zeljko" <tr*******@yahoo.com> wrote in message
news:46********************************@4ax.com.. .
> Yes, I have tried. tray icon becomes invisible, and there is nothing I> can click on to make it visible again.
>
> Zeljko
> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
> <brianw@gold_death_2_spam_rush.com> wrote:
>
> >No, it won't, the tray icon remains visible. Have you tried?
> >
> >You restore the form in response to a click on the icon.
> >
> >
> >
> >"Zeljko" <tr*******@yahoo.com> wrote in message
> >news:nh********************************@4ax.com.. .
> >> But If I do that, I don't see tray icon anymore and can't maximize the> >> form again ?
> >>
> >> Zeljko
> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
> >> <brianw@gold_death_2_spam_rush.com> wrote:
> >>
> >> >When you minimize the form you must also set the Visible property to> >false
> >> >
> >> > this.Visible = false;
> >> >
> >> >
> >> >HTH
> >> >Brian W
> >> >
> >> >
> >> >"Zeljko" <tr*******@yahoo.com> wrote in message
> >> >news:0d********************************@4ax.com.. .
> >> >> Hi,
> >> >>
> >> >> I have a form with a tray icon. However, when I minimize the form,it
> >> >> stays visible - not in the task bar (I have showintaskbar propertyset
> >> >> to false), but in a form of a rectangle sitting above the task bar.> >> >> Can't figure out why that happens - it looks very ugly...
> >> >>
> >> >> Any ideas ?
> >> >>
> >> >> Zeljko
> >> >
> >>
> >
>


Nov 15 '05 #10
See the .Icon property of the NotifyIcon class.

Regards
Brian W
"Lou" <lo********@comcast.net> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
How do you assign an icon?
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:Og**************@TK2MSFTNGP10.phx.gbl...
Sorry, this is not complete, for example it does not show me what is going
on in InitializeComponent(), and does not show me what you are doing with micoPending, micoRunning & micoStopped. The example also does not show me how you are responding to either the Click or DoubleClick events of the
NotifyIcon object. For that matter it doesn't show that you even have a
TrayIcon object.

With all that said, if I add your code to mine the window minimizes and
hides with the tray icon still visible. So I'm sorry to say it still works for me here.

Paste the following code as your form make sure you assign an icon to the NotifyIcon object, then tell me if this works for you.
Regards
Brian W

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.NotifyIcon notifyIcon1;

private System.ComponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

//

// notifyIcon1

//

this.notifyIcon1.Icon =
((System.Drawing.Icon)(resources.GetObject("notify Icon1.Icon")));

this.notifyIcon1.Text = "notifyIcon1";

this.notifyIcon1.Visible = true;

this.notifyIcon1.DoubleClick += new
System.EventHandler(this.notifyIcon1_DoubleClick);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Name = "Form1";

this.Text = "Form1";

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_SizeChanged(object sender, System.EventArgs e)

{

if ( this.WindowState == FormWindowState.Minimized )

this.Hide();

else

this.Show();

}

private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)

{

this.Show();

}

}

"Zeljko" <tr*******@yahoo.com> wrote in message
news:pu********************************@4ax.com...
Sure - here it is:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//PENDING_ICON etc are string constants - I added 3 icons to
the app, changing current notify icon based on the status of a windows
service
micoPending = new Icon(typeof(Form1), PENDING_ICON);
micoRunning = new Icon (typeof (Form1) , RUNNING_ICON);
micoStopped = new Icon (typeof (Form1) , STOPPED_ICON);

}

protected override void OnLayout(LayoutEventArgs levent)
{

switch (WindowState){
case FormWindowState.Minimized:
this.WindowState = FormWindowState.Minimized;
this.Hide();
break;
case FormWindowState.Maximized:
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
break;
}
base.OnLayout (levent);
}


On Tue, 18 Nov 2003 10:20:32 -0800, "Brian W"
<brianw@gold_death_2_spam_rush.com> wrote:

>This technique has always worked for me, and is working here now.
Have you
>assigned an Icon to the icon property of your notifyicon object.
>
>Can you post a small, complete example that reproduces this behavior?
>
>
>Regards
>Brian W
>
>
>
>"Zeljko" <tr*******@yahoo.com> wrote in message
>news:46********************************@4ax.com.. .
>> Yes, I have tried. tray icon becomes invisible, and there is
nothing
I >> can click on to make it visible again.
>>
>> Zeljko
>> On Tue, 18 Nov 2003 09:10:53 -0800, "Brian W"
>> <brianw@gold_death_2_spam_rush.com> wrote:
>>
>> >No, it won't, the tray icon remains visible. Have you tried?
>> >
>> >You restore the form in response to a click on the icon.
>> >
>> >
>> >
>> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >news:nh********************************@4ax.com.. .
>> >> But If I do that, I don't see tray icon anymore and can't

maximize the
>> >> form again ?
>> >>
>> >> Zeljko
>> >> On Tue, 18 Nov 2003 08:23:23 -0800, "Brian W"
>> >> <brianw@gold_death_2_spam_rush.com> wrote:
>> >>
>> >> >When you minimize the form you must also set the Visible
property to
>> >false
>> >> >
>> >> > this.Visible = false;
>> >> >
>> >> >
>> >> >HTH
>> >> >Brian W
>> >> >
>> >> >
>> >> >"Zeljko" <tr*******@yahoo.com> wrote in message
>> >> >news:0d********************************@4ax.com.. .
>> >> >> Hi,
>> >> >>
>> >> >> I have a form with a tray icon. However, when I minimize the

form,
>it
>> >> >> stays visible - not in the task bar (I have showintaskbar

property
>set
>> >> >> to false), but in a form of a rectangle sitting above the
task bar.
>> >> >> Can't figure out why that happens - it looks very ugly...
>> >> >>
>> >> >> Any ideas ?
>> >> >>
>> >> >> Zeljko
>> >> >
>> >>
>> >
>>
>



Nov 15 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13541
by: Mats-Lennart Hansson | last post by:
Hi, I'm having a hard time getting my service to show a sys tray icon. I've tried to create a separate Windows application where I simply add a notification icon to the form. In the OnStart method...
2
2418
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from...
7
6839
by: Danielb | last post by:
I want my application to run most of the time as just an notify icon visible in the system tray, with some dialogs windows that open if the user selects an option from the context menu on the tray...
2
1747
by: quilkin | last post by:
Hi I have an control app which starts up with a small info message then sits down as a tray icon while it does its work. When started manually (e.g.from a shortcut) this always works fine. However...
4
7942
by: utkarsh | last post by:
Hi, I want to develop a Window Service in C# that should be capable of sisplaying the a icon in the window tray. Based on some logic in service, icon should be changed to some other...
8
3378
by: george d lake | last post by:
Hi, I have an app that runs in the system tray. When I exit the app (from a button on a form) the app ends but the icon stays in the tray. Any ideas? here is the code I use to end the app ...
3
7911
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
6
2214
monirul arfin
by: monirul arfin | last post by:
Hi all, Recently I installed " Windows Media Bonus Pack for Windows XP " to get tray icon for windows media player 10 in system tray . But I couldn't find any tray icon option in this bonus...
1
2151
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, how can i remove/disable the tray icon for the started Express Edition from the system tray. Te icon directs me to the express editons website after clicking on it. I dont want these tray...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.