Get location and size of open windows?


Well-known member
Feb 19, 2010
Programming Experience
Lets just say you were trying to make an alternative window manager for the system so you made a borderless template form and designed your own buttons, title bar and so on and had the center of the form completely transparent for other windows behind it to "fit inside it" (really just sit behind it).

That's the easy part but what about detecting the locations of all windows currently open outside your application. For example lets say the user was running firefox, paint and windows media player. How would I simply detect all windows currently open and automatically put and size the template windows around them?

Here is some Pseudocode I've made that I wish existed but I know it's much more complicated than this:
  Public Sub setupoverlaywindows()
        For Each Windows.Forms.Application As syswindow
            Dim overwindow As New template
            overwindow.FormBorderStyle = FormBorderStyle.None
            overwindow.Location = New Point(syswindow.location.x, syswindow.location.y)
            overwindow.Size = New Size(syswindow.width, syswindow.height)
            overwindow.lbtitletext = overwindow.titletext
    End Sub

Then comes problem 2... Making those templates link actions to certain windows such as the close button on the template closing the appropriate window it is wrapping around or the titlebar of the template moving the window it is meant to be linked to.

Is there anyway I do this?
Top Bottom