怎么让主窗口在其他窗口上面?

bo.cui 2010-03-17 10:19:26
我在主窗口初始化之前用一个线程弹出了一个计时窗口。
当这个计时窗口关闭之后,主窗口打开正常。
但是这个窗口却在其他窗口(比如已经打开了文件夹)下面。
怎么让他上来?
...全文
73 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
WizardK 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用楼主 cuibo1123 的回复:]
我在主窗口初始化之前用一个线程弹出了一个计时窗口。
当这个计时窗口关闭之后,主窗口打开正常。
但是这个窗口却在其他窗口(比如已经打开了文件夹)下面。
怎么让他上来?
[/Quote]

关闭计时窗口时,将主窗体SetWindowPos(XXX,HWND_TOPMOST,...,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW)
bo.cui 2010-03-18
  • 打赏
  • 举报
回复
解决。
哈哈哈
SetForegroundWindow();
这样就好了。。 谢谢各位。
bo.cui 2010-03-18
  • 打赏
  • 举报
回复
应该不是这个问题。。

怎么让一个窗口变成活动窗口??
wuhuwy 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 cometnet 的回复:]
设置置顶:
::SetWindowPos(destHwnd,HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
取消置顶:
::SetWindowPos(destHwnd,HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
上面代码中,destHwnd为目标窗口句柄。
[/Quote]正解
邓学彬 2010-03-17
  • 打赏
  • 举报
回复
设置置顶:
::SetWindowPos(destHwnd,HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
取消置顶:
::SetWindowPos(destHwnd,HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);

上面代码中,destHwnd为目标窗口句柄。
bo.cui 2010-03-17
  • 打赏
  • 举报
回复
我用TOPMOST 不行。
WS_EX_TOPMOST 没试验。。。
青稞 2010-03-17
  • 打赏
  • 举报
回复
A topmost window is a window that has the WS_EX_TOPMOST style. Topmost windows are above all non-topmost sibling windows in the Z order. You can create a topmost window directly by specifying the WS_EX_TOPMOST style when you create the window. You can also make a window a topmost window by calling the SetWindowPos function and setting the hWndInsertAfter parameter to HWND_TOPMOST.

//Notice Follow,Maybe Helpful:

A window may lose its topmost style by calling SetWindowPos and setting the hWndInsertAfter parameter to HWND_NOTOPMOST. If a window is positioned directly after a non-topmost window, then that window loses its WS_EX_TOPMOST style.
青稞 2010-03-17
  • 打赏
  • 举报
回复
设置窗口显示风格为TOPMOST
zyyoung 2010-03-17
  • 打赏
  • 举报
回复
SetWindowPos函数,指定窗口的最顶风格,用WS_EX_TOPMOST扩展窗口的 风格

15,979

社区成员

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

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