dotnetspider.com


 


TutorialsForumResourcesReviewsJobsInterviewVideosCommunitiesProjectsTraining

Subscribe to Subscribers


Online MembersAnu George
NareshGodera
N. KUMAR
Naveen
Mahesh
Shesh Kumar Mishra
Pawan Awasthi
saranya
raju
Anil Kumar Pandey
sudheera
More...




Resources » Code Snippets » Application windows, menus & toolbars


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


Posted Date:     Category: Application windows, menus & toolbars    Rating: 1 out of 5
Author: Member Level: Gold    Points: 5


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


[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);

[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);

private void BringToFront(string className,string CaptionName)
{
SetForegroundWindow(FindWindow(className,CaptionName));
}



private void Form1_Load(object sender, EventArgs e)
{

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

}



Did you like this resource? Share it with your friends and show your love!





Responses to "Bring the window to Front and set It Active window using c#"
Author: Victor Birin    24 Feb 2008Member Level: Silver   Points : 0
You don't need to use FindWindow call. Just replace in with Handle.ToInt32();

result

SetForegroundWindow(Handle.ToInt32());



Author: Bernd Wechner    17 Aug 2010Member Level: Bronze   Points : 1
I find that this works more simply:

TopMost = true;
TopMost = false;

I don't want the form to stay topmost so I turn it off again imemdiately, but I find that setting TopMost actually displays it and works around the annoying habit Windos has of flashing the taskbar button instead.



Feedbacks      

Post Comment:




  • 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:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: hide the TaskBar using FindWindow API
    Previous Resource: Display CurrentLine in RichText Box
    Return to Resources
    Post New Resource
    Category: Application windows, menus & toolbars


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    (No tags found.)

    My Profile

    Active Members
    TodayLast 7 Daysmore...


    Awards & Gifts


    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds



    About Us    Trademark Disclaimer    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.