Bring the window to Front and set It Active window using c#

using this Fucntion we can Bring the window to Front and set It Active window. i'm using win API .

public static extern Int32 SetForegroundWindow(int hWnd);

public static extern int FindWindow(string lpClassName, string lpWindowName);

private void BringToFront(string className,string CaptionName)

private void Form1_Load(object sender, EventArgs e)

BringToFront("Notepad", "Untitled - Notepad");



Author: Victor Birin24 Feb 2008 Member Level: Silver   Points : 0

You don't need to use FindWindow call. Just replace in with Handle.ToInt32();



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: