窗口模式与全屏模式切换,创建全屏窗口
2008-05-10 18:19
656 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
HWND m_hWnd;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
RECT m_WndRect;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
LONG m_Style;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
enum WINDOW_SHOW
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WINDOW_FULLSCREEN,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WINDOW_800_600,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WINDOW_1024_768
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
WINDOW_SHOW m_eWndShow;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
m_eWndShow = WINDOW_800_600;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//创建主窗口
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
HWND hWnd;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
hWnd = CreateWindowEx( ... );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
if ( !hWnd )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
m_hWnd = hWnd;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
BOOL SetFullScreen()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//获得并储存当前窗口信息,用于以后恢复
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GetWindowRect( m_hWnd, &m_WndRect ); //获得当前窗口RECT
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LONG style = GetWindowLong( m_hWnd, GWL_STYLE ); //获得当前窗口的类型
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m_Style = style; //储存当前的窗口类型
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//设置窗口显示类型
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
style &= ~WS_CAPTION;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetWindowLong( m_hWnd, GWL_STYLE, style );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//获得屏幕大小
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int ScreenX = GetSystemMetrics( SM_CXSCREEN );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int ScreenY = GetSystemMetrics( SM_CYSCREEN );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( !MoveWindow( m_hWnd, 0, 0, ScreenX, ScreenY, TRUE ) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
BOOL ResetWindow()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//设置窗口类型为原来的类型
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetWindowLong( m_hWnd, GWL_STYLE, m_Style );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( !MoveWindow( m_hWnd, m_WndRect.left, m_WndRect.top,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m_WndRect.right-m_WndRect.left, m_WndRect.bottom-m_WndRect.top, TRUE ) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( m_WndRect.right-m_WndRect.left == 800 )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m_eWndShow = WINDOW_800_600;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if( m_WndRect.right-m_WndRect.left == 1024 )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m_eWndShow = WINDOW_1024_768;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//消息处理
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
static int wmId;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
switch (message)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case WM_DESTROY:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PostQuitMessage(0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case WM_KEYDOWN:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
switch (wParam)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case VK_RETURN:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( m_eWndShow != WINDOW_FULLSCREEN )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetFullScreen();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
m_eWndShow = WINDOW_FULLSCREEN;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case VK_ESCAPE:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( m_eWndShow == WINDOW_FULLSCREEN )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ResetWindow();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
break;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
default:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return DefWindowProc(hWnd, message, wParam, lParam);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- D3DPRESENT_PARAMETERS 说明及 DirectX窗口模式和全屏模式的Device创建
- D3DPRESENT_PARAMETERS 说明及 DirectX窗口模式和全屏模式的Device创建
- Win7远程桌面全屏及窗口模式切换
- MASM32编程演示程序在窗口模式和全屏模式间切换
- vitamio窗口layout模式切换-全屏黑边问题
- windows编程 全屏窗口的创建总结 .
- Ubuntu的窗口模式与命令行模式切换
- MFC创建一个全屏窗口(附源码)
- Windows mobile多窗口的模式中窗口之间切换显示的连续性
- Android 动态切换全屏和非全屏模式
- vmware 学习笔记==常见虚拟机创建工具(虚拟机3种联网模式+网络模式切换时+配置静态ip时 的网络(网卡VMnetxxx)的配置###不熟悉!!!很常用)
- UE4中窗口模式切换
- 【C#】创建透明窗口实现夜间模式
- MFC应用程序中处理消息,创建窗口的过程,关闭窗口(非模态窗口),打开模式对话框等的函数调用顺序
- C++创建控件并响应三部曲、设置窗口全屏、OnSize实现控件大小改变、跟踪调试顺序
- Portlet通过标签在不同的模式(PortletMode)窗口状态间切换
- Portlet通过标签在不同的模式(PortletMode)窗口状态间切换
- CentOS5.10 X window 文本与窗口模式的切换
- javascript应用:实现复选框全选/全不选切换,创建无边框的弹出窗口!
- Android三种播放视频的方式(全屏模式的切换)