Hi, I have been searching online for some sample codes on how to correctly make Windows Application bottom most. After digging and some trials and errors, it can't seem to find the right code for what I want. I wonder if it is possible or not.
I want to put the windows application right on top of the desktop, but under all other applications and taskbar.
Here is what I found so far:
private IntPtr m_DesktopClass;
private IntPtr m_DesktopFileListView;
private IntPtr m_PreviousParent;
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("User32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, String lpClassName, String lpWindowName);
public bool DesktopAttached
{
get { return m_DesktopAttached; }
set
{
m_DesktopAttached = value;
this.MinimizeBox = !value;
if (value)
{
m_DesktopClass = FindWindowEx(FindWindow("Progman", null), new IntPtr(0), "shelldll_defview", null);
m_DesktopFileListView = FindWindowEx(m_DesktopClass, new IntPtr(0), "syslistview32", null);
m_PreviousParent = SetParent(this.Handle, m_DesktopFileListView);
}
else
{
SetParent(this.Handle, m_PreviousParent);
}
}
The above code does put the windows application right on top of the desktop and under all other applications and taskbar; however, all buttons on the application don't work, not what I want.
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
int Y, int cx, int cy, uint uFlags);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_NOACTIVATE = 0x0010;
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
public static void SetBottom()
{
SetWindowPos(this.Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
}
The above code does put the windows application right on top of the desktop and under all other applications and all buttons on the application work; however, the application is on top of the taskbar, not what I want.