1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > QT窗口嵌入桌面内部(在桌面图标之上):可以实现自定义桌面

QT窗口嵌入桌面内部(在桌面图标之上):可以实现自定义桌面

时间:2022-02-23 05:46:45

相关推荐

QT窗口嵌入桌面内部(在桌面图标之上):可以实现自定义桌面

代码实现如下:

#include "widget.h"#include "windows.h"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;}void setParentDesktop(QWidget *pWidget){HWND resultHwnd = NULL;EnumWindows((WNDENUMPROC)enumUserWindowsCB, (LPARAM)&resultHwnd);// 设置桌面为父窗口if (resultHwnd) {SetParent((HWND)pWidget->winId(), resultHwnd);}}Widget::Widget(QWidget *parent): QWidget(parent){setParentDesktop(this);}Widget::~Widget(){}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。