Bring to forward window when minimized

前端 未结 2 456
北海茫月
北海茫月 2020-12-11 05:00

I want to know how to bring forward a particular window. SetForegroundWindow works when the window is not minimized!! but when a minimize the window, SetForegroundWindow doe

2条回答
  •  星月不相逢
    2020-12-11 05:29

    You can use ShowWindow combined with what you already have, here is your example with a little modification:

        int IdRemoto = int.Parse(textBoxID.Text);
    
        Process[] processlist = Process.GetProcessesByName("AA_v3.3");
    
        foreach (Process process in processlist)
        {
            if (!String.IsNullOrEmpty(process.MainWindowTitle))
            {
                if (IdRemoto.ToString() == process.MainWindowTitle)
                {
                    ShowWindow(process.MainWindowHandle, 9);
                    SetForegroundWindow(process.MainWindowHandle);  
                }
            }
        }
    
    
       [DllImport("user32.dll")]
       private static extern bool SetForegroundWindow(IntPtr hWnd);
       [DllImport("user32.dll")]
       private static extern bool ShowWindow(IntPtr hWind, int nCmdShow);
    

提交回复
热议问题