Windows全屏代码--摘自Chrome
变量定义:
typedef struct SCREEN_INFO
{
DWORD dwStyle;
DWORD dwExStyle;
CRect rect;
bool bMaximized;
}SreenInfo; SreenInfo m_screenInfo;
bool m_bFullScreen = false;
实现代码:
if (!m_bFullScreen)
{
// Save current window information. We force the window into restored mode
// before going fullscreen because Windows doesn't seem to hide the
// taskbar if the window is in the maximized state.
m_screenInfo.bMaximized = !!::IsZoomed(this->m_hWnd);
// if (m_screenInfo.bMaximized)
// ::SendMessage(this->m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
m_screenInfo.dwStyle = GetWindowLongPtr(this->m_hWnd, GWL_STYLE);
m_screenInfo.dwExStyle = GetWindowLongPtr(this->m_hWnd, GWL_EXSTYLE);
GetWindowRect(m_screenInfo.rect);
} m_bFullScreen = !m_bFullScreen; if (m_bFullScreen)
{
// Set new window style and size.
SetWindowLongPtr(this->m_hWnd, GWL_STYLE,
m_screenInfo.dwStyle & ~(WS_CAPTION | WS_THICKFRAME));
SetWindowLongPtr(this->m_hWnd, GWL_EXSTYLE,
m_screenInfo.dwExStyle & ~(WS_EX_DLGMODALFRAME |
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
// On expand, if we're given a window_rect, grow to it, otherwise do
// not resize.
bool for_metro = false;
if (!for_metro)
{
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(MonitorFromWindow(this->m_hWnd, MONITOR_DEFAULTTONEAREST), & monitor_info);
CRect window_rect(monitor_info.rcMonitor);
SetWindowPos(NULL, window_rect.left, window_rect.top,
window_rect.Width(), window_rect.Height(),
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
}
}
else
{
// Reset original window style and size. The multiple window size/moves
// here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
// repainted. Better-looking methods welcome.
SetWindowLongPtr(this->m_hWnd, GWL_STYLE, m_screenInfo.dwStyle);
SetWindowLongPtr(this->m_hWnd, GWL_EXSTYLE, m_screenInfo.dwExStyle); // On restore, resize to the previous saved rect size.
CRect new_rect(m_screenInfo.rect);
SetWindowPos(NULL, new_rect.left, new_rect.top,
new_rect.Width(), new_rect.Height(),
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
}
参考:
1. https://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar,第一个高赞回答。
2.https://github.com/chromium/chromium/blob/master/ui/views/win/fullscreen_handler.cc, chromium 浏览器源代码。
Windows全屏代码--摘自Chrome的更多相关文章
- 天猫装修-全屏代码,和去掉10px
淘宝装修,不支持float,和position属性 全屏代码 <div style="height:685px;"> <div style="paddi ...
- 兼容IE浏览器的js浏览器全屏代码
众所周知,IE是个奇葩的浏览器,但是由于用户量很大,开发者还是不得不为IE考虑一下,于是,各种浏览器相关的操作,都要多一个特别的判断——专门针对IE浏览器的判断,这里的全屏也不例外.看代码: func ...
- windows蓝屏代码大全及常见蓝屏解决方案
对于以下的代码查询建议使用ctrl+F查询,而且很多蓝屏与黑屏的问题多是最近操作引起的,例如更新驱动,安装新的硬件.软件--把相关的配置调到最近的正常状况大多可以解决,确实不行时方可考虑重装系统,解决 ...
- android 实现全屏代码
设置全屏包括两个部分: 窗口全屏和Activity全屏. 窗口全屏 是指隐藏系统顶部用来显示时间.电量.信号等信息的标题栏 . Activity全屏 是指隐藏程序的标题栏.我们可以通过修改Androi ...
- 【极品代码】一般人我不告诉他,手机端h5播放时不自动全屏代码
已测适用于ios,某些安卓手机微信下播放视频会出现播放器控件(这个实在是无力吐槽噢,因为之前还遇到过微信播放完视频后竟然无法退出全屏出现广告的情况,只有播放完后刷新页面并且要放到框架页里才能屏蔽微信视 ...
- [HTML]JS全屏代码
video全屏参考:https://www.thecssninja.com/javascript/fullscreen <!doctype html> <html> <h ...
- JS 全屏代码
// 推断各种浏览器,找到正确的方法 function launchFullscreen(element) { if(element.requestFullscreen) { element.requ ...
- windows蓝屏代码
原始链接 引用自 https://docs.microsoft.com/zh-cn/windows-hardware/drivers/debugger/bug-check-code-referenc ...
- 谷歌全屏脚本 start chrome.exe --kiosk http://www.baidu.com
start chrome.exe --kiosk http://www.baidu.com
随机推荐
- Codeforces Round #590 (Div. 3)补题
要想上2000分,先刷几百道2000+的题再说 ---某神 题目 E F 赛时是否尝试 × × tag math bitmask 难度 2000 2400 状态 ∅ √ 解 E 待定 F 传送门 第一 ...
- 散列查找的C实现
概念 散列查找,类似与查英文字典的过程.如果我们要查找"zoo"(key)对应的释义(value),我们不会从第一页开始逐页查找(顺序查找),而是直接根据大致的推算(Hash函数) ...
- Angular 表单验证类库 ngx-validator 1.0 正式发布
背景介绍 之前写了一篇 <如何优雅的使用 Angular 表单验证>,结尾处介绍了统一验证反馈的类库 ngx-validator ,由于这段时间一直在新模块做微前端以及相关业务组件库, ...
- Css解决表格超出部分用省略号显示
小伙伴们有没有的遇到页面显示时,因为数据太长导致显示的表格某一列过长,从而导致页面的不美观,下面我们来看一看如何用Css样式解决表格超出部分用省略号显示的问题. 主要设置两个样式: table{ ta ...
- 1、windows安装npm教程 --参考自https://www.cnblogs.com/jianguo221/p/11487532.html
windows安装npm教程 1.在使用之前,先类掌握3个东西,明白它们是用来干什么的: npm: nodejs 下的包管理器. webpack: 它主要用途是通过CommonJS 的语法把所有 ...
- VS多行注释快捷键
VS多行注释快捷键 注释:Ctrl+K,Ctrl+C 取消注释:Ctrl+K,Ctrl+U
- c++11 常量表达式
c++11 常量表达式 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #inclu ...
- [转载]SSD原理与实现
[转载]SSD原理与实现 这里只mark一下,对原论文讲解的很好的博文 https://zhuanlan.zhihu.com/p/33544892 这里有一个关于SSD的很好的程序实现,readme里 ...
- Shiro——入门Demo
Shiro——入门Demo 环境- 引入相关maven依赖, shiro-core,commons-logging 配置shiro配置文件:ini后缀 主方法测试: import org.apach ...
- c#如何使用MemoryStream和BinaryFormatter进行对象的序列化和返序列化
1 下面是我写的一个序列化的类 public static class ObjSerialize { /// <summary> /// 将对象数组obj序列化,内存中的缓冲区的数据序列化 ...