Static extern int GetForegroundWindow() //Retrieves a handle to the foreground window Shared ReadOnly HWND_TOP As New IntPtr(0) ' Places the window at the top of the Z order.Ĭonst SWP_NOSIZE As UInt32 = &H1 'Retains current sizeĬonst SWP_NOMOVE As UInt32 = &H2 ' Retains the current positionĬonst TOPMOST_FLAGS As UInt32 = SWP_NOMOVE Or SWP_NOSIZE Shared ReadOnly HWND_TOPMOST As New IntPtr(-1) 'Places the window above all non-topmost windows Public Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr, X As Integer, Y As Integer, cx As Integer, cy As Integer, _ 'This function changes the size, position, and z-order of a child, pop-up, or top-level window. Private Shared Function GetWindowText(hWnd As Integer, text As StringBuilder, count As Integer) As Integer 'Copies the text of the specified window's title bar (if it has one) into a buffer Private Shared Function GetForegroundWindow() As Integer VB.NET 'Retrieves a handle to the foreground window Let’s now add the APIs as well as their associated constants: We use the InteropServices namespace for dealing with APIs and the Text namespace will be used for advanced text manipulation functions, such as the StringBuilder. Design your form to resemble Figure 1.Īs usual, let’s start by adding the necessary Namespaces: Open Visual Studio 2012 and choose either C# or VB.NET as your platform. Yes, that is a good point, but curiosity will always kill the cat. Some experienced programmers might say use Spy++ to get the handles. There is always a need to obtain an outside application’s window handle, to be able to manipulate that window from inside your program. Hello again! Today’s topic is a very popular topic on programming forums like CodeGuru.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |