Make your Form as Top Most Window in VB.NET

General Description

This code brings a form on top of every application, which is running. This is required sometimes when the user needs to see some information every time. Just like ICQ, which stays on top of every window.

But, this window can be minimized. If anybody doesn't want at all that the window should be never minimized then one can choose the borderstyle property of the form to be none and then run the code. This window will not be minimized by any method. Not even when the user clicks "Minimize all windows".

The program changes the size, position, and z-order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the z-order.Procedure:

  • Run the code. A small window will open with two buttons.
  • Click the button "On top". 
  • Open any windows maximize it or do whatever you wish. 
  • The window will always stay on top. 
  • You can make the window as normal window by click on the "Normal"  button.

Constants

Public Const SWP_NOMOVE As Integer = 2
Public Const SWP_NOSIZE As Integer = 1
Public Const HWND_TOPMOST As Integer = -1
Public Const HWND_NOTOPMOST As Integer = -2
Public Shared Function <DllImport("user32")> _
GetDesktopWindow() As Integer End Function
'GetDesktopWindow
'The GetDesktopWindow function returns a handle to the desktop window.
'The desktop window covers the entire screen.
'The desktop window is the area on top of which all icons and other windows are painted.


Similar Articles