.netwindowsvb.netdockingalways-on-top

Snap an always-on-top form to the corner of the screen


I have a tiny VB.net application that is a single FixedToolWindow form that I've made TopMost = True and partially transparent. Is it possible to make this "dock" to the corner of the screen? I like it sat in the bottom corner, but currently have to manually align it.

I'm using this on windows 7 machines.


Solution

  • You can move it in code to a corner. The following code will move it to the bottom right corner of the screen it is currently occupying:

    Dim scr As Screen = Screen.FromControl(Me)
    Me.Top = scr.WorkingArea.Top + scr.WorkingArea.Height - Me.Height
    Me.Left = scr.WorkingArea.Left + scr.WorkingArea.Width - Me.Width
    

    WorkingArea will place it above the taskbar, use Bounds instead if you want to place it over the taskbar (if it is visible)