EDN Admin
Well-known member
Hi All.
How to bring minimized application to front WITHOUT setting focus in C#.Net.
Below code is working but it always setting the focus. Without set focus how to bring minimized application to front.
Any one can help on this request.
using System;<br/>
using System.Collections.Generic;<br/>
using System.ComponentModel;<br/>
using System.Data;<br/>
using System.Drawing;<br/>
using System.Linq;<br/>
using System.Text;<br/>
using System.Windows.Forms;<br/>
using System.Diagnostics;<br/>
using System.Runtime.InteropServices;
namespace WindowsFormsApplication<br/>
{<br/>
public partial class BringToFront : Form<br/>
{<br/>
public BringToFront()<br/>
{<br/>
InitializeComponent();<br/>
}
private void BringToFront_Load(object sender, EventArgs e)<br/>
{<br/>
foreach (Process p in Process.GetProcesses("."))<br/>
{<br/>
try<br/>
{<br/>
if (p.MainWindowTitle.Length > 0)<br/>
{<br/>
listBox1.Items.Add(p.MainWindowTitle.ToString());<br/>
}<br/>
}<br/>
catch { }<br/>
}<br/>
}
[DllImport("user32.dll")]<br/>
static extern bool ShowWindow(IntPtr hwnd, uint windowStyle);
[DllImport("user32.dll")]<br/>
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void BringToFrontbutton_Click(object sender, EventArgs e)<br/>
{<br/>
string SelectItem = listBox1.SelectedItem.ToString();
System.Diagnostics.Process[] ProcessCheck = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process prcTempProc in ProcessCheck)<br/>
{<br/>
if (prcTempProc.MainWindowTitle == SelectItem)<br/>
{<br/>
ShowWindow(prcTempProc.MainWindowHandle, 1);<br/>
SetWindowPos(prcTempProc.MainWindowHandle, new IntPtr(-1), 0, 0, 0, 0, 3);<br/>
break;<br/>
}<br/>
}<br/>
}<br/>
}<br/>
} <hr class="sig Vijay
View the full article
How to bring minimized application to front WITHOUT setting focus in C#.Net.
Below code is working but it always setting the focus. Without set focus how to bring minimized application to front.
Any one can help on this request.
using System;<br/>
using System.Collections.Generic;<br/>
using System.ComponentModel;<br/>
using System.Data;<br/>
using System.Drawing;<br/>
using System.Linq;<br/>
using System.Text;<br/>
using System.Windows.Forms;<br/>
using System.Diagnostics;<br/>
using System.Runtime.InteropServices;
namespace WindowsFormsApplication<br/>
{<br/>
public partial class BringToFront : Form<br/>
{<br/>
public BringToFront()<br/>
{<br/>
InitializeComponent();<br/>
}
private void BringToFront_Load(object sender, EventArgs e)<br/>
{<br/>
foreach (Process p in Process.GetProcesses("."))<br/>
{<br/>
try<br/>
{<br/>
if (p.MainWindowTitle.Length > 0)<br/>
{<br/>
listBox1.Items.Add(p.MainWindowTitle.ToString());<br/>
}<br/>
}<br/>
catch { }<br/>
}<br/>
}
[DllImport("user32.dll")]<br/>
static extern bool ShowWindow(IntPtr hwnd, uint windowStyle);
[DllImport("user32.dll")]<br/>
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void BringToFrontbutton_Click(object sender, EventArgs e)<br/>
{<br/>
string SelectItem = listBox1.SelectedItem.ToString();
System.Diagnostics.Process[] ProcessCheck = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process prcTempProc in ProcessCheck)<br/>
{<br/>
if (prcTempProc.MainWindowTitle == SelectItem)<br/>
{<br/>
ShowWindow(prcTempProc.MainWindowHandle, 1);<br/>
SetWindowPos(prcTempProc.MainWindowHandle, new IntPtr(-1), 0, 0, 0, 0, 3);<br/>
break;<br/>
}<br/>
}<br/>
}<br/>
}<br/>
} <hr class="sig Vijay
View the full article