469,282 Members | 2,000 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Making the program invisible

I made a program like i showed below and i used

this.Visible = false;
line to make it invisible but it doesnt work
where did i make mistake ?
here is my code
[code:1:c303f80ced]
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

public class sylagent : Form
{
private Process[] myproc;
private Timer t1;
private FileVersionInfo myinfo;
private int count;
private String program;
private String prog;

public sylagent()
{
myproc = Process.GetProcesses();
count = 0;
this.Size = new Size(300, 300);
this.Location = new Point(100, 100);
this.Visible = false;

kontrolevent();


}
public void kontrolevent()
{

this.t1 = new Timer();
this.t1.Interval = 1000;
this.t1.Start();
this.t1.Tick += new EventHandler(t1_tick);

}

protected override void Dispose(bool Disposing)
{
Process[] procuo = Process.GetProcesses();
for (int i = 0; i < procuo.Length-3; i++)
{
if
(procuo[i].ProcessName.Equals("client"))
{
procuo[i].Kill();
}
}

base.Dispose(true);

}

public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length-4; i++)
{
if (! this.myproc[i].HasExited)
{
if (this.myproc[i].MainModule.FileName !=
null)
{
this.program =
this.myproc[i].MainModule.FileName.ToString();

if (this.program[0] == 'C' ||
this.program[0] == 'D' || this.program[0] == 'E' ||
this.program[0] == 'F' || this.program[0] ==
'G')
{
prog =
myproc[i].MainModule.FileName.ToString();
this.myinfo =
FileVersionInfo.GetVersionInfo(prog);
if (this.myinfo.OriginalFilename !=
null)
{
if
(this.myinfo.OriginalFilename.Equals("connector.ex e"))
{
this.count++;
}
}
}
}
}
}

if (this.count != 1)
{
this.Close();
}
this.count = 0;

}

public static void Main()
{
Application.Run(new sylagent());

}
}
[/code:1:c303f80ced]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #1
3 3684
If I remember correctly, it actually sets Visible to true after the
constructor is called.

If your form will ALWAYS be invisible, override OnVisibleChanged and set
Visible to false there.

--
Adam Clauss
ca*****@tamu.edu
"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
I made a program like i showed below and i used

this.Visible = false;
line to make it invisible but it doesnt work
where did i make mistake ?
here is my code
[code:1:c303f80ced]
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

public class sylagent : Form
{
private Process[] myproc;
private Timer t1;
private FileVersionInfo myinfo;
private int count;
private String program;
private String prog;

public sylagent()
{
myproc = Process.GetProcesses();
count = 0;
this.Size = new Size(300, 300);
this.Location = new Point(100, 100);
this.Visible = false;

kontrolevent();


}
public void kontrolevent()
{

this.t1 = new Timer();
this.t1.Interval = 1000;
this.t1.Start();
this.t1.Tick += new EventHandler(t1_tick);

}

protected override void Dispose(bool Disposing)
{
Process[] procuo = Process.GetProcesses();
for (int i = 0; i < procuo.Length-3; i++)
{
if
(procuo[i].ProcessName.Equals("client"))
{
procuo[i].Kill();
}
}

base.Dispose(true);

}

public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length-4; i++)
{
if (! this.myproc[i].HasExited)
{
if (this.myproc[i].MainModule.FileName !=
null)
{
this.program =
this.myproc[i].MainModule.FileName.ToString();

if (this.program[0] == 'C' ||
this.program[0] == 'D' || this.program[0] == 'E' ||
this.program[0] == 'F' || this.program[0] ==
'G')
{
prog =
myproc[i].MainModule.FileName.ToString();
this.myinfo =
FileVersionInfo.GetVersionInfo(prog);
if (this.myinfo.OriginalFilename !=
null)
{
if
(this.myinfo.OriginalFilename.Equals("connector.ex e"))
{
this.count++;
}
}
}
}
}
}

if (this.count != 1)
{
this.Close();
}
this.count = 0;

}

public static void Main()
{
Application.Run(new sylagent());

}
}
[/code:1:c303f80ced]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #2
Sorry - meant handle the VisibleChanged event (OnVisibleChanged doesn't
exist).

--
Adam Clauss
ca*****@tamu.edu

"Adam Clauss" <ca*****@nospam.tamu.edu> wrote in message
news:eT*************@TK2MSFTNGP14.phx.gbl...
If I remember correctly, it actually sets Visible to true after the
constructor is called.

If your form will ALWAYS be invisible, override OnVisibleChanged and set
Visible to false there.

--
Adam Clauss
ca*****@tamu.edu
"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
I made a program like i showed below and i used

this.Visible = false;
line to make it invisible but it doesnt work
where did i make mistake ?
here is my code
[code:1:c303f80ced]
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

public class sylagent : Form
{
private Process[] myproc;
private Timer t1;
private FileVersionInfo myinfo;
private int count;
private String program;
private String prog;

public sylagent()
{
myproc = Process.GetProcesses();
count = 0;
this.Size = new Size(300, 300);
this.Location = new Point(100, 100);
this.Visible = false;

kontrolevent();


}
public void kontrolevent()
{

this.t1 = new Timer();
this.t1.Interval = 1000;
this.t1.Start();
this.t1.Tick += new EventHandler(t1_tick);

}

protected override void Dispose(bool Disposing)
{
Process[] procuo = Process.GetProcesses();
for (int i = 0; i < procuo.Length-3; i++)
{
if
(procuo[i].ProcessName.Equals("client"))
{
procuo[i].Kill();
}
}

base.Dispose(true);

}

public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length-4; i++)
{
if (! this.myproc[i].HasExited)
{
if (this.myproc[i].MainModule.FileName !=
null)
{
this.program =
this.myproc[i].MainModule.FileName.ToString();

if (this.program[0] == 'C' ||
this.program[0] == 'D' || this.program[0] == 'E' ||
this.program[0] == 'F' || this.program[0] ==
'G')
{
prog =
myproc[i].MainModule.FileName.ToString();
this.myinfo =
FileVersionInfo.GetVersionInfo(prog);
if (this.myinfo.OriginalFilename !=
null)
{
if
(this.myinfo.OriginalFilename.Equals("connector.ex e"))
{
this.count++;
}
}
}
}
}
}

if (this.count != 1)
{
this.Close();
}
this.count = 0;

}

public static void Main()
{
Application.Run(new sylagent());

}
}
[/code:1:c303f80ced]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


Nov 16 '05 #3
yes it is onvisiblechanged and it works
thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Johanna Albee via AccessMonster.com | last post: by
reply views Thread by Joel Ryan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.