Call user32.dll to display other windows. Call the user32.dll window.

Source: Internet
Author: User

Call user32.dll to display other windows. Call the user32.dll window.

1 // This function sets the display status of Windows generated by different threads. 2 // </summary> 3 // <param name = "hWnd"> window handle </ param> 4 // <param name = "cmdShow"> specify how the window is displayed. To view the allowed value list, see description of the ShowWlndow function </param> 5 // <returns> if the function is visible, the returned value is non-zero. If the function is hidden, return Value: Zero </returns> 6 [DllImport ("User32.dll")] 7 private static extern bool ShowWindowAsync (IntPtr hWnd, int cmdShow ); 8 /// <summary> 9 // This function sets the thread that creates the specified window to the foreground and activates the window. Enter the keyboard to switch to the window and change various visual marks for the user. 10 // The system assigns a higher permission to the thread that creates the foreground window than other threads. 11 /// </summary> 12 /// <param name = "hWnd"> the window handle is activated and transferred to the foreground </param> 13 /// <returns> If the window is set to the foreground, the return value is non-zero. If the window is not set to the foreground, the return value is zero. </returns> 14 [DllImport ("User32.dll")] 15 private static extern bool SetForegroundWindow (IntPtr hWnd ); 16 17 private void BringToFront (IntPtr hWnd) 18 {19 // Process currentProcess = Process. getCurrentProcess (); 20 // Process process = Process. get (id); 21 // if (process! = Null) 22 // {23 // ShowWindowAsync (process. main1_whandle, 1); // display 24 // SetForegroundWindow (process. main1_whandle); // when it reaches the frontend 25 //} 26 Process [] Processes = Process. getProcesses (); // GetProcessesByName (currentProcess. processName); 27 foreach (Process process in Processes) 28 {29 // process. start (); 30 // if (process. id! = CurrentProcess. id) 31 // {32 // if (Assembly. getExecutingAssembly (). location. replace ("/", "\") 33 // <span> 34 // {35 // return process; 36 //} 37 if (process. main1_whandle. toString () = "0") 38 {39 continue; 40} 41 if (process. main1_whandle = hWnd) 42 {43 ShowWindowAsync (process. mainappswhandle, 1); // display 44 SetForegroundWindow (process. main1_whandle); // when arriving at the frontend 45} 46 //} 47} 48}

 

Related Article

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.