Question App on top of desktop but under anything else

computer guy

Member
Joined
Feb 12, 2008
Messages
18
Programming Experience
Beginner
Hi Everyone,

I need my application to appear on top of the desktop (and vista sidebar if possible) but under every other application that is opened.

It is basically a replacement desktop in a way.


Any suggestions of how I can do it?

Thank you :)
 
All you need to do is update the WINDOWPOS when you receive a WM_WINDOWPOSCHANGING message, setting hWndInsertAfter to HWND_BOTTOM.
VB.NET:
Const WM_WINDOWPOSCHANGING As Int32 = &H46
Const HWND_BOTTOM As Int32 = 1
Structure WINDOWPOS
    Public hwnd As Int32
    Public hWndInsertAfter As Int32
    Public x As Int32
    Public y As Int32
    Public cx As Int32
    Public cy As Int32
    Public flags As Int32
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    If m.Msg = WM_WINDOWPOSCHANGING Then
        Dim pos As WINDOWPOS = CType(Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, GetType(WINDOWPOS)), WINDOWPOS)
        pos.hWndInsertAfter = HWND_BOTTOM
        Runtime.InteropServices.Marshal.StructureToPtr(pos, m.LParam, True)
    End If
    MyBase.WndProc(m)
End Sub
 
Back
Top