 |
|
 |
Hey,
Thanks for this code, it is really useful! Just to be picky, in the clsMinToTray class, you might want to turn the public fields "trayMenu" and "restoreWindowState" into properties. It's not essential, but it looks a bit more professional to those who call it from code :P
Apart from that small nitpick, once again thank you for this awesome code! I'll start using it straight away.
Anthony
|
|
|
|
 |
|
 |
Excellent code!!
Thanks Man!
Lee
|
|
|
|
 |
|
 |
Works Flawlessly!
Thanks!
hoy pinoy ako
|
|
|
|
 |
|
 |
Hi,
First, thanks for the class, I always like when things are made easy....
I wanted to be able to update the text that appears in the tray (percentage complete) so I added the following property to the class:
Public Property TrayText() As String
Get
Return trayIcon.Text
End Get
Set(ByVal Value As String)
trayIcon.Text = Value
End Set
End Property
Works for me, maybe someone els ecan use the modification.
|
|
|
|
 |
|
 |
I love the idea, the simplicity - and I think you've done a great job laying out the functionality for this task... but I cannot seem to get it to run. I'm not sure of the problems, but I've been try for a couple of days off and on to see if I can debug the issues, but to no avail. I have even downloaded the sample programs you posted to an earlier user's questions and remarks, but it fails to run on my setup or a corresponding setup I have nearby. Both use Microsoft Windows XP with Visual Studio .Net 2003. If I resolve the conflict, I'll be happy to post my findings. Otherwise, great job! (And I say that because it is obvious from the postings that it works for some people just fine.)(I'm a BIG advocate for wrapping functionality as tight as you have done so here!)
Steve England
Senior Software Engineer
JAVS, inc.
Louisville, Kentucky
|
|
|
|
 |
|
 |
Hi Chris,
I just found this class and its very nice, easy to apply to my application.
The one question I have is,
1 of my application use axmediaplayer.dll and when it's minimize to the
tray, and restore again the application restore fine, but the player size
change to the maximize size. I look thru the class and try somethings here
and there, but no luck.
I'm very new in programming, so maybe it's something very simple but I can't
picture it.
Thank you,
Jorge
|
|
|
|
 |
|
 |
Hi Jorge,
Although I am not familiar with the axmediaplayer dll, I would assume that the problem is likely with anchoring. Is the media player within your main window? If so, make sure you set the anchoring property correctly. The class changes the size of the main form (Me)...so if objects on that form are not anchored properly, there can be some problems when restored.
If you continue to have problems, let me know and I will try to help. If you like, you can send me your app and I can take a look at it.
Most people think that programming is an exact science...HA!
Later,
Chris
|
|
|
|
 |
|
 |
Hi, I am writing a c# code that opens a file and searches for some condition and according to the condition that occuring tray icon changes.This should be done every 10 minutes.
I have coded this part well but I can not exit my application from a context menu item(exit) which never appears.
If I erase the line where my while loop appear, context menu appears and every thing goes well.
Do you have any suggestion where I might have made a mistake? I am a c# newbie and I cannot find the solution...
thanks for your help very much..
Here is the code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Diagnostics;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
private System.Boolean check;
public Form1()
{
this.check=true;
//this.HideApp();
//this.ShowInTaskbar = false;
this.components = new System.ComponentModel.Container();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
// Initialize contextMenu1
this.contextMenu1.MenuItems.AddRange(
new System.Windows.Forms.MenuItem[] {this.menuItem1});
// Initialize menuItem1
this.menuItem1.Index = 0;
this.menuItem1.Text = "E&xit";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
// Set up how the form should be displayed.
//this.ClientSize = new System.Drawing.Size(292, 266);
this.Text = "Notify Icon Example";
// Create the NotifyIcon.
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
notifyIcon1.ContextMenu = this.contextMenu1;
// The Text property sets the text that will be displayed,
// in a tooltip, when the mouse hovers over the systray icon.
notifyIcon1.Text = "Form1 (Situation controller)";
notifyIcon1.Visible = true;
notifyIcon1.Icon = new Icon("Icon2.ico");
while(this.check==true)
{
FileStream file = new FileStream("path.txt", FileMode.Open, FileAccess.Read,FileShare.Read);
StreamReader sr = new StreamReader(file);
string s;
bool control=false;
while((s = sr.ReadLine())!= null)
{
if(s.IndexOf("down")!=-1)
{
control=true;
}
}
if(control==true)
{
notifyIcon1.Icon = new Icon("Icon2.ico");
}
else
{
notifyIcon1.Icon = new Icon("Icon1.ico");
}
sr.Close();
file.Close();
//bu kısmı degistirdim
Thread.Sleep(1000*10*1);//1000*60*10
//this.Close();
//Application.Exit();
}
this.notifyIcon1.Dispose();
}
protected override void Dispose( bool disposing )
{
// Clean up any components being used.
if( disposing )
if (components != null)
components.Dispose();
base.Dispose( disposing );
}
private void notifyIcon1_DoubleClick(object Sender, EventArgs e)
{
// Show the form when the user double clicks on the notify icon.
// Set the WindowState to normal if the form is minimized.
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
// Activate the form.
this.Activate();
}
private void menuItem1_Click(object Sender, EventArgs e)
{
this.check=false;
notifyIcon1.Visible = false;
Application.Exit();
this.Close();
}
private void InitializeComponent()
{
//
// Form1
//
//this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
//this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.ShowInTaskbar = false;
this.Load += new System.EventHandler(this.Form1_Load);
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
public void HideApp()
{
this.WindowState = FormWindowState.Minimized;
Hide();
}
public void ShowApp()
{
Show();
this.WindowState = FormWindowState.Normal;
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
GÜL
|
|
|
|
 |
|
 |
Hi,
I'm not a C# programmer...
But, are you not disposing the notifiyIcon on every trip through the loop (see below) - I think this will dump your context menu?
You are then assigning an icon to the notifyIcon on the next trip...but no context menu.
By looking at the code, I'm not sure why you are disposing the notifyIcon on every loop (Although, I'm sure you have a reason). Could you not attach the context menu each time you assign an icon in the loop?
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Diagnostics;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
private System.Boolean check;
public Form1()
{
this.check=true;
//this.HideApp();
//this.ShowInTaskbar = false;
this.components = new System.ComponentModel.Container();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
// Initialize contextMenu1
this.contextMenu1.MenuItems.AddRange(
new System.Windows.Forms.MenuItem[] {this.menuItem1});
// Initialize menuItem1
this.menuItem1.Index = 0;
this.menuItem1.Text = "E&xit";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
// Set up how the form should be displayed.
//this.ClientSize = new System.Drawing.Size(292, 266);
this.Text = "Notify Icon Example";
// Create the NotifyIcon.
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
notifyIcon1.ContextMenu = this.contextMenu1;
// The Text property sets the text that will be displayed,
// in a tooltip, when the mouse hovers over the systray icon.
notifyIcon1.Text = "Form1 (Situation controller)";
notifyIcon1.Visible = true;
notifyIcon1.Icon = new Icon("Icon2.ico");
while(this.check==true)
{
FileStream file = new FileStream("path.txt", FileMode.Open, FileAccess.Read,FileShare.Read);
StreamReader sr = new StreamReader(file);
string s;
bool control=false;
while((s = sr.ReadLine())!= null)
{
if(s.IndexOf("down")!=-1)
{
control=true;
}
}
if(control==true)
{
notifyIcon1.Icon = new Icon("Icon2.ico");
}
else
{
notifyIcon1.Icon = new Icon("Icon1.ico");
}
sr.Close();
file.Close();
//bu ksm degistirdim
Thread.Sleep(1000*10*1);//1000*60*10
//this.Close();
//Application.Exit();
}
:omg:this.notifyIcon1.Dispose();:omg:
}
protected override void Dispose( bool disposing )
{
// Clean up any components being used.
if( disposing )
if (components != null)
components.Dispose();
base.Dispose( disposing );
}
private void notifyIcon1_DoubleClick(object Sender, EventArgs e)
{
// Show the form when the user double clicks on the notify icon.
// Set the WindowState to normal if the form is minimized.
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
// Activate the form.
this.Activate();
}
private void menuItem1_Click(object Sender, EventArgs e)
{
this.check=false;
notifyIcon1.Visible = false;
Application.Exit();
this.Close();
}
private void InitializeComponent()
{
//
// Form1
//
//this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
//this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.ShowInTaskbar = false;
this.Load += new System.EventHandler(this.Form1_Load);
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
public void HideApp()
{
this.WindowState = FormWindowState.Minimized;
Hide();
}
public void ShowApp()
{
Show();
this.WindowState = FormWindowState.Normal;
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
Let me know if this is helpful.
Later,
Chris
|
|
|
|
 |
|
 |
can it put an icon to upper taskbar of PPC(CE)?
like shell_notifyicon?
|
|
|
|
 |
|
 |
Hi,
To be honest with you, I don't know. I have done very little in PPC development.
You might give it a try and see if you can get it to work. If you can, let me know. I would be interested in what tweaking needed to be done (As I doubt it would work without it).
Wish I could of been more helpful,
Chris
|
|
|
|
 |
|
 |
Hi,
its nice to see your solution infact i was looking for one like that , but i cma unable to use your class .
Actually i want to add item to the context menu which will be shown in the SYStray and also with the text i want to display icon in the context menu.
Can you send me an example of how to use your class.
Early response will be appreciated.
my mail id is bhanu.prakash@airtightnetworks.net
|
|
|
|
 |
|
 |
Hi,
Glad this is proving useful for you.
I made a very simple sample application with three different contructor setups (just uncomment the one you want and comment out the others).
The example can be downloaded here.
[I will also email you a copy]
If you have any more questions, let me know.
Thanks,
Chris
|
|
|
|
 |
|
 |
Please send me a copy too!!!
Thanks
Marco Sacramento
|
|
|
|
 |
|
 |
Could you send me an email too, tnx!
|
|
|
|
 |
|
 |
Could you send me an email too, tq!
matju84@yahoo.com
|
|
|
|
 |