首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >MFC Windows 程序设计->最顶层窗口

MFC Windows 程序设计->最顶层窗口

作者头像
井九
发布2024-10-12 08:43:47
发布2024-10-12 08:43:47
3030
举报
文章被收录于专栏:四楼没电梯四楼没电梯

The difference between a topmost window and a nontopmost window is an extended window style bit. WS_EX_TOPMOST makes a window a topmost window. You can create a topmost frame window by including a WS_EX_TOPMOST flag in the call to Create, like this:

代码语言:txt
复制
Create (NULL, _T ("MyWindow"), WS_OVERLAPPEDWINDOW, rectDefault,
    NULL, NULL, WS_EX_TOPMOST);

The alternative is to add the style bit after the window is created by calling SetWindowPos with a &wndTopMost parameter, as shown here:

代码语言:txt
复制
SetWindowPos (&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE ¦ SWP_NOSIZE);

You can convert a topmost window into a nontopmost window by calling SetWindowPos with the first parameter equal to &wndNoTopMost rather than &wndTopMost.

Clock uses SetWindowPos to make its window a topmost window when Stay On Top is checked in the system menu and a nontopmost window when Stay On Top is unchecked. The work is done by CMainWindow::SetTopMostState, which is called by OnSysCommand. When Stay On Top is checked, Clock is visible on the screen at all times, even if it's running in the background and it overlaps the application running in the foreground.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-10-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档