C # Open the taskbar program window

Source: Internet
Author: User

C # Open the taskbar program window

In this example, use C # To open a window displayed on the Windows taskbar.


Lab environment:

Windows XP + VS2005 +. Net 2.0 + Winform test program.

Note: You need to establish a Winform program for testing.


Code: (reprinted please indicate the source of http://blog.csdn.net/studentsky)

Public partial class Form1: Form {private const int SW_HIDE = 0; private const int SW_NORMAL = 1; private const int SW_MAXIMIZE = 3; private const int SW_SHOWNOACTIVATE = 4; private const int SW_SHOW = 5; private const int SW_MINIMIZE = 6; private const int SW_RESTORE = 9; private const int SW_SHOWDEFAULT = 10; [System. runtime. interopServices. dllImport ("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)] static extern bool ShowWindow (IntPtr hWnd, uint nCmdShow );////// Search for a form based on the window title ////////////
 [System. runtime. interopServices. dllImport ("user32.dll", EntryPoint = "FindWindow")] private static extern IntPtr FindWindow (string lpClassName, string lpWindowName); public Form1 () {InitializeComponent ();} private void button#click (object sender, EventArgs e) {IntPtr hWnd = FindWindow (null, "untitled-Notepad"); ShowWindow (hWnd, SW_MAXIMIZE );}}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.