如何在用户按了“显示桌面”按钮,这个窗口不被隐藏

码侬 2010-12-22 11:41:12
我想要的程序是看起来“贴”在桌面上,有点象便条。是不能在最上面的,只能在最底层。
就是那个天气预报秀的效果.
...全文
329 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
dianhui 2010-12-23
  • 打赏
  • 举报
回复
我想其实还是个窗口而已,只是窗口半透明罢了!
superdiablo 2010-12-23
  • 打赏
  • 举报
回复
建议不要用窗口实现,直接朝桌面上画
如果非得用窗口,可以写一个定时器检测是否被最小化或者响应最小化消息,把窗口恢复
码侬 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 j8daxue 的回复:]
引用 7 楼 tigermaydo 的回复:
C/C++ code

HWND hDesktop = ::FindWindow("Progman", NULL);
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
CWnd* pWndDesktop = CWnd::FromHandle(hDesktop);
this->SetParent(pWnd……
[/Quote]

你是大神,用了你的方法之后貌似可以了。但是也引入了问题。

用了你的方法之后,用Spy++可以看到parent窗口是Progman,
但是用
HWND hDesktop = ::FindWindow("Progman", NULL);
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
CWnd* pWndDesktop = CWnd::FromHandle(hDesktop);
this->SetParent(pWndDesktop);

父窗口是NULL,这是为什么呢?



引入的问题是,只要我的程序启动,天气预报窗口就一直置顶了。
码侬 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 tigermaydo 的回复:]
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
这句去掉看看
[/Quote]

可能因为我的是WIN7吧,去掉之后也不行,没有界面了
j8daxue 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 tigermaydo 的回复:]
C/C++ code

HWND hDesktop = ::FindWindow("Progman", NULL);
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
CWnd* pWndDesktop = CWnd::FromHandle(hDesktop);
this->SetParent(pWndDesktop);


这段代码 我试过了……
[/Quote]
原理是对的。如果LZ是用MFC对话框的话,把CxApp::InitInstance初始化改改
CXTestDlg dlg;
HWND hDesktop = ::FindWindow(_T("Progman"), NULL);
m_pMainWnd = &dlg;
CWnd dWnd;
dWnd.Attach(hDesktop);

dlg.Create(MAKEINTRESOURCE(IDD_XTEST_DIALOG),&dWnd);
dlg.ShowWindow(SW_SHOW);
dWnd.Detach();
int nResponse = dlg.RunModalLoop();
码侬 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 zgl7903 的回复:]
启动一个定时器 在定时器中不断重置
::SetWindowPos(GetSafeHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
[/Quote]

看清问题了吗?
Eleven 2010-12-23
  • 打赏
  • 举报
回复

HWND hDesktop = ::FindWindow(_T("Progman"), NULL);
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
::SetParent(GetSafeHwnd(), hDesktop);

这样确实是可以做到
zgl7903 2010-12-23
  • 打赏
  • 举报
回复
启动一个定时器 在定时器中不断重置
::SetWindowPos(GetSafeHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
tigerMayDo 2010-12-23
  • 打赏
  • 举报
回复
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
这句去掉看看
码侬 2010-12-23
  • 打赏
  • 举报
回复
谁有能够功能的方法,第一时间把分数全部给他
dxdxmy 2010-12-23
  • 打赏
  • 举报
回复
拿点积分闪人
码侬 2010-12-23
  • 打赏
  • 举报
回复
to tigerMayDo:

我怎么不可以呢?将上面4句放在OnInitDialog里面,看到:

HWND hDesktop = ::FindWindow(L"Progman", NULL);  // hDesktop == 0x000100ec
hDesktop = ::GetWindow(hDesktop, GW_CHILD);// hDesktop == 0x00000000
tigerMayDo 2010-12-23
  • 打赏
  • 举报
回复

HWND hDesktop = ::FindWindow("Progman", NULL);
hDesktop = ::GetWindow(hDesktop, GW_CHILD);
CWnd* pWndDesktop = CWnd::FromHandle(hDesktop);
this->SetParent(pWndDesktop);

这段代码 我试过了 可以
fall513 2010-12-23
  • 打赏
  • 举报
回复
感觉要hook显示桌面的消息才能做到,QQ有这样的功能
向立天 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 gao_zilai 的回复:]
引用 3 楼 idle_ 的回复:
使用SetParent()将Parent窗口设置成GetDesktopWindow()?

我试过了,对话款都不显示了
[/Quote]
用spy++看看
我记得桌面句柄不是GetDesktopWindow获得的
码侬 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 idle_ 的回复:]
使用SetParent()将Parent窗口设置成GetDesktopWindow()?
[/Quote]
我试过了,对话款都不显示了
阿呆_ 2010-12-23
  • 打赏
  • 举报
回复
使用SetParent()将Parent窗口设置成GetDesktopWindow()?

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧