Call User32.dll to show other windows

Source: Internet
Author: User
1 ///This function sets the display state of a window generated by a different thread2         /// </summary>3         /// <param name= "HWnd" >window Handle</param>4         /// <param name= "Cmdshow" >specifies how the window is displayed. To view a list of allowed values, consult the description section of the Showwlndow function</param>5         /// <returns>If the function is originally visible, the return value is not 0; if the function is originally hidden, the return value is zero</returns>6[DllImport ("User32.dll")]7         Private Static extern BOOLShowwindowasync (IntPtr hWnd,intcmdshow);8         /// <summary>9         ///The function creates a thread setting for the specified window to the foreground and activates the window. The keyboard input turns to the window and changes the various visual marks for the user. Ten         ///the system assigns a slightly higher permission to the thread that creates the foreground window than the other threads.  One         /// </summary> A         /// <param name= "HWnd" >window handle that will be activated and transferred to the foreground</param> -         /// <returns>If the window is set to the foreground, the return value is not 0 and the return value is zero if the window is not set in the foreground</returns> -[DllImport ("User32.dll")] the         Private Static extern BOOLSetForegroundWindow (IntPtr hWnd); -  - Private voidBringToFront (IntPtr hWnd) -         { +             //Process currentprocess = process.getcurrentprocess (); -             //Process process = Process.get (ID); +             //if (process! = NULL) A             //{ at             //Showwindowasync (process. Mainwindowhandle, 1);//Show -             //SetForegroundWindow (process. Mainwindowhandle);//when you go to the front -             //} -process[] Processes = process.getprocesses ();//GetProcessesByName (currentprocess.processname); -             foreach(Process processinchProcesses) -             { in                 //process. Start (); -                 //if (process. Id! = currentprocess.id) to                 //{ +                 //if (assembly.getexecutingassembly (). Location.replace ("/", "\ \") -                 //<span style= "White-space:pre" > </span> = = currentProcess.MainModule.FileName) the                 //                    { *                 //return process; $                 //                    }Panax Notoginseng                 if(Process. mainwindowhandle.tostring () = ="0") -                 { the                     Continue; +                 } A                 if(Process. Mainwindowhandle = =hWnd) the                 { +Showwindowasync (process. Mainwindowhandle,1);//Show -SetForegroundWindow (process. Mainwindowhandle);//when you go to the front $                 } $                 //} -             } -}

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.