主要是一些Qt代码记录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
BOOL enumUserWindowsCB(HWND hwnd, LPARAM lParam) { long wflags = GetWindowLong(hwnd, GWL_STYLE); if(!(wflags & WS_VISIBLE)) return TRUE; HWND sndWnd; if(!(sndWnd = FindWindowEx(hwnd, NULL, L"SHELLDLL_DefView", NULL))) { return TRUE; } HWND targetWnd; if(!(targetWnd = FindWindowEx(sndWnd, NULL, L"SysListView32", L"FolderView"))) { return TRUE; } HWND* resultHwnd = (HWND*)lParam; *resultHwnd = targetWnd; return FALSE; }; HWND findDesktopIconWnd() { HWND resultHwnd = NULL; EnumWindows((WNDENUMPROC)enumUserWindowsCB, (LPARAM)&resultHwnd); return resultHwnd; }; |
调用嵌入:
1 2 3 4 5 6 |
HWND curHwnd = (HWND)this->winId(); HWND desktopHwnd = findDesktopIconWnd(); if(desktopHwnd) { ::SetParent(curHwnd, desktopHwnd); } |
调用取消嵌入:
1 2 3 4 5 |
//DWORD dws = ::GetWindowLong((HWND)this->winId(), GWL_STYLE); //dws = dws & ~WS_POPUP; //dws = dws | WS_CHILD; //SetWindowLong((HWND)this->winId(), GWL_STYLE, dws); SetParent((HWND)this->winId(), NULL); |
瞎记录下…
【Win32】嵌入到桌面,取消嵌入