VBForums >
.NET >
C# > I can't find the Interaction.Appactivate [Resolved]
Click to See Complete Forum and Search --> : I can't find the Interaction.Appactivate [Resolved]
mar_zim
Aug 18th, 2005, 08:30 PM
I already use the namespace microsoft.visualbasic and still the interaction class won't display. what reference do i add to show that class?
jmcilhinney
Aug 18th, 2005, 08:48 PM
To use VB.NET Runtime functions in C#, first you must add a reference to "Microsoft Visual Basic .NET Runtime" to your project. Then you need to add "using Microsoft.VisualBasic;" to the top of your class file if you want to avoid having to qualify everything. Then you can use the Runtime modules as though they were classes with static members, e.g. Interaction.MsgBox("VB.NET Runtime functions in C#"). Keep in mind though, that many Runtime functions use optional parameters, which is a concept not supported in C#. This means that in C# you always have to provide a value for every argument.
mar_zim
Aug 18th, 2005, 09:22 PM
Thanks. I want to do that coz I want my application only run once. What i mean there is only one exe of my application running on process.
static void Main()
{
Process[] p=Process.GetProcesses();
int i=0;
foreach(Process pp in p)
{
if(pp.ProcessName=="WindowsApplication4")
{
i++;
if(i==2){Interaction.AppActivate(pp.Id);return;}
}
}
Application.Run(new Form2());
}
I notice the Interaction.AppActivate method only do the application on top by other application(when it's not in minimize mode) but it won't restore the application that's minimize in taskbar. I want to check to the process if that application is running then if so it will pop up/restore and be on top in any other applcation.
jmcilhinney
Aug 18th, 2005, 09:43 PM
You are quite correct. I'd guess that you would have to use an API call to restore the window.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.