In the trial of some apps, found that some of the AP's window can be embedded in the desktop, so win+d can be seen when the key, very convenient. Searching the web, the principle is to set the window's parent window to the desktop.
This parent window is found under XP through FindWindow ("program Manager", "ProgMan"), but the parent window found under Win7 is not good. After watching with Spy + +, write the following section of code Finddesktopiconwnd (), the parent window can be found under XP and Win7. The child window is then called SetParent (child,parent) and can be seen on the desktop.
In QT Practice:
Theory:
0. #include <windows.h>
1. Call the Win32 API to get the desktop handle and get the window handle through Qwidget::winid ()
2. Call Win32 API Settings Two window parent-child relationship
Practice:
Add a function declaration to the private part of the header file:
Static BOOL ENUMUSERWINDOWSCB (Hwndhwnd,lparamlparam); Static global functions
HWND Finddesktopiconwnd ();
Function implementation:
BOOL WIDGET::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 Widget::finddesktopiconwnd ()
{
HWND Resulthwnd = NULL;
EnumWindows ((Wndenumproc) ENUMUSERWINDOWSCB, (LPARAM) &resulthwnd);
return resulthwnd;
}
With the help of the above two functions, the following work is simple and can be achieved by adding the following code where needed:
HWND Desktophwnd = Finddesktopiconwnd ();
if (Desktophwnd) SetParent (This->winid (), Desktophwnd);
From: Leisurely blog http://mypyg.blog.51cto.com/820446/263349
Embed a form in the desktop