Making the program invisible

D

Dakkar

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.ProcessName.Equals("client"))
{
procuo.Kill();
}
}

base.Dispose(true);

}

public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length-4; i++)
{
if (! this.myproc.HasExited)
{
if (this.myproc.MainModule.FileName !=
null)
{
this.program =
this.myproc.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.MainModule.FileName.ToString();
this.myinfo =
FileVersionInfo.GetVersionInfo(prog);
if (this.myinfo.OriginalFilename !=
null)
{
if
(this.myinfo.OriginalFilename.Equals("connector.exe"))
{
this.count++;
}
}
}
}
}
}

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

}

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

}
}
[/code:1:c303f80ced]
 
A

Adam Clauss

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.
 
A

Adam Clauss

Sorry - meant handle the VisibleChanged event (OnVisibleChanged doesn't
exist).

--
Adam Clauss
(e-mail address removed)

Adam Clauss said:
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
(e-mail address removed)
Dakkar said:
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.ProcessName.Equals("client"))
{
procuo.Kill();
}
}

base.Dispose(true);

}

public void t1_tick(object sender, EventArgs e)
{
for (int i = 0; i < myproc.Length-4; i++)
{
if (! this.myproc.HasExited)
{
if (this.myproc.MainModule.FileName !=
null)
{
this.program =
this.myproc.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.MainModule.FileName.ToString();
this.myinfo =
FileVersionInfo.GetVersionInfo(prog);
if (this.myinfo.OriginalFilename !=
null)
{
if
(this.myinfo.OriginalFilename.Equals("connector.exe"))
{
this.count++;
}
}
}
}
}
}

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

}

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

}
}
[/code:1:c303f80ced]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top