Hi !
I want to create a ".exe" winform project in order to launch an external application (e.g. the "calc.exe" of windows). When I fire my ".exe", I want to hide the calc and put a NotifyIcon in the tray icon bar. I fire the calc.exe application by calling a Process object in my ".exe"
My problems :
- how can I hide the calc (once launched by the Process) ?
- how can I show (e.g after a click on the NotifyIcon object) the application again ?
-------------------------------------------------
the file which contains the entry point :
-------------------------------------------------
The problem is that I have to attach the process to a Form (to make it visible or not with the .Visible property).Code:public class main { public static void Main(string[] args) { NotifyIcon oNotifyIcon = new NotifyIcon(); Icon oIcon = new Icon(@"c:\app.ico"); oNotifyIcon.Icon = oIcon; notifyIcon1.Visible = true; Process oP = new Process(); oP.StartInfo.FileName = "calc.exe"; oP.Start(); Form oForm = (Form) Form.FromHandle(oP.MainWindowHandle); oForm.Visible = false; } }
The code above is not good because the oForm object contains "null".
It seems that the method FromHandle only works with a object whose type is Control ...
Any idea ???
++
ico



Reply With Quote