Click here to Skip to main content
15,917,568 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dynamic Table Alignment Pin
Vasudevan Deepak Kumar13-Nov-07 20:37
Vasudevan Deepak Kumar13-Nov-07 20:37 
QuestionShow two applications Pin
phracek12-Nov-07 21:30
phracek12-Nov-07 21:30 
AnswerRe: Show two applications Pin
Giorgi Dalakishvili12-Nov-07 21:33
mentorGiorgi Dalakishvili12-Nov-07 21:33 
AnswerRe: Show two applications Pin
Martin#12-Nov-07 21:44
Martin#12-Nov-07 21:44 
GeneralRe: Show two applications Pin
phracek12-Nov-07 21:50
phracek12-Nov-07 21:50 
GeneralRe: Show two applications Pin
Martin#12-Nov-07 21:53
Martin#12-Nov-07 21:53 
GeneralRe: Show two applications Pin
phracek12-Nov-07 21:57
phracek12-Nov-07 21:57 
AnswerRe: Show two applications Pin
Martin#12-Nov-07 22:09
Martin#12-Nov-07 22:09 
Hello,

I would do something like this:
private void btnGvim_Click(object sender, EventArgs e)
{
    Process[] allProcesses= Process.GetProcessesByName("gvim");
    if(allProcesses.Length>0)
    {
        if (allProcesses[0].MainWindowHandle != IntPtr.Zero)
        {
            ShowWindow(allProcesses[0].MainWindowHandle, SW_SHOWNORMAL);
        }
    }
    DisposeProcesses(allProcesses);

    allProcesses= Process.GetProcessesByName("notepad");
    if(allProcesses.Length>0)
    {
        if (allProcesses[0].MainWindowHandle != IntPtr.Zero)
        {
            ShowWindow(allProcesses[0].MainWindowHandle, SW_SHOWMINIMIZED);
        }
    }
    DisposeProcesses(allProcesses);
}
 
//Help method which disposes all process instances of the passed process array!
public static void DisposeProcesses(Process[] processes)
{
    if(processes!=null)
    {
        if(processes.Length>0)
        {
            foreach(Process p in processes)
            {
                p.Dispose();
            }
        }
    }
}


If you later want to get the actual status of a process, look at the "IsIconic" method.
/// <summary>
/// Gets a Flag if Window is Iconic or not
/// </summary>
/// <param name="hWnd">windowhandle</param>
/// <returns>true or false</returns>
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool IsIconic(IntPtr hWnd);


All the best,

Martin

GeneralRe: Show two applications Pin
Giorgi Dalakishvili12-Nov-07 22:26
mentorGiorgi Dalakishvili12-Nov-07 22:26 
GeneralRe: Show two applications Pin
Martin#12-Nov-07 22:29
Martin#12-Nov-07 22:29 
GeneralRe: Show two applications Pin
Giorgi Dalakishvili12-Nov-07 22:31
mentorGiorgi Dalakishvili12-Nov-07 22:31 
Questiondelegates Pin
Sonia Gupta12-Nov-07 21:04
Sonia Gupta12-Nov-07 21:04 
AnswerRe: delegates Pin
Christian Graus12-Nov-07 21:06
protectorChristian Graus12-Nov-07 21:06 
AnswerRe: delegates Pin
J4amieC12-Nov-07 22:33
J4amieC12-Nov-07 22:33 
GeneralRe: delegates Pin
Christian Graus12-Nov-07 23:38
protectorChristian Graus12-Nov-07 23:38 
GeneralRe: delegates Pin
mav.northwind13-Nov-07 1:21
mav.northwind13-Nov-07 1:21 
GeneralRe: delegates Pin
Guffa13-Nov-07 1:26
Guffa13-Nov-07 1:26 
JokeRe: delegates Pin
Guffa13-Nov-07 2:59
Guffa13-Nov-07 2:59 
QuestionCan i make arraylist array? Pin
knodark12-Nov-07 21:00
knodark12-Nov-07 21:00 
AnswerRe: Can i make arraylist array? Pin
Christian Graus12-Nov-07 21:05
protectorChristian Graus12-Nov-07 21:05 
GeneralRe: Can i make arraylist array? [modified] Pin
knodark12-Nov-07 21:18
knodark12-Nov-07 21:18 
GeneralRe: Can i make arraylist array? Pin
Martin#12-Nov-07 21:21
Martin#12-Nov-07 21:21 
QuestionIcomparer Pin
AmitG7712-Nov-07 20:51
AmitG7712-Nov-07 20:51 
AnswerRe: Icomparer Pin
Guffa12-Nov-07 21:15
Guffa12-Nov-07 21:15 
GeneralRe: Icomparer Pin
AmitG7712-Nov-07 23:10
AmitG7712-Nov-07 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.