Reputation: 1
I am writing a live wallpaper. So, first thing is create a window and set it behind the desktop icons. Now I almost finish it. I don't know why sometimes the icons display above the window, and most of the time the icons display behind the window.
My main codes is as follows.
I find the SHELLDLL_DefView
window, and set my window be a child for it, then I set it HWND_BOTTOM
.
glfwInit();
GLFWwindow* window = glfwCreateWindow(800, 600, "my window", NULL, NULL);
HWND hwnd = glfwGetWin32Window(window);
SetWallpaperWindowPosition(hwnd);
void SetWallpaperWindowPosition(HWND hwnd)
{
auto r = GetSDDV();
HWND SDDV = std::get<0>(r);
HWND SLV32 = std::get<1>(r);
HWND WorkerW = std::get<2>(r);
SetParent(hwnd, SDDV);
SetWindowLongPtr(hwnd, GWL_STYLE, WS_CHILD | WS_VISIBLE);
SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
std::tuple<HWND, HWND, HWND>* result = reinterpret_cast<std::tuple<HWND,HWND,HWND>*>(lParam);
TCHAR szClassName[256];
TCHAR szWindowName[256];
GetClassName(hwnd, szClassName, _countof(szClassName));
GetWindowText(hwnd, szWindowName, _countof(szWindowName));
if (!_tcscmp(szClassName, _T("WorkerW")))
{
HWND SDDV = FindWindowEx(hwnd, NULL, _T("SHELLDLL_DefView"), NULL);
if (SDDV)
{
HWND SLV32 = FindWindowEx(SDDV, NULL, _T("SysListView32"), _T("FolderView"));
std::get<0>(*result) = SDDV;
std::get<1>(*result) = SLV32;
std::get<2>(*result) = hwnd;
return FALSE;
}
}
return TRUE;
}
std::tuple<HWND, HWND, HWND> GetSDDV()
{
std::tuple<HWND, HWND, HWND> P;
EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&P));
return P;
}
Upvotes: 0
Views: 63