SetForegroundWindow Reference in C#, VB.NET and VB6
Visual Basic 6 definition
Visual Basic 6 example source code
Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Visual Basic .NET definition
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer
public static extern int SetForegroundWindow(int hwnd)
Platforms: Win 95/98, Win NT
SetForegroundWindow makes the specified window the current foreground window and gives it the focus. This function should only be used with windows which your program owns. Of course this function should be used with caution, since the user usually doesn't expect the foreground window to change unexpectedly. The function tells Windows to somehow draw the user's attention to the window, such as by flashing its icon in the taskbar. The function returns 1 if successful, or 0 if an error occured.
Puts the thread that created the specified window into the foreground and activates the window.
For further information on Windows API functions such as these, and how to use these API's in your
C# and VB.NET applications, please refer to the book 'Network programming in .NET' (Buy at Amazon UK)
(Buy at Amazon US)
Visual Basic .NET example source code
C# example source code
Provide a code example
Copyright 2013 Open Merchant Account Ltd.