注册 登录  
 加关注

网易博客网站关停、迁移的公告:

将从2018年11月30日00:00起正式停止网易博客运营
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

jiwenxu的博客

CODE

 
 
 

日志

 
 

向 MFC 应用程序添加“全屏显示”功能  

2009-01-27 21:28:34|  分类: C++ |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
      void CMainFrame::OnViewFullScreen()
      {
          RECT rectDesktop;
          WINDOWPLACEMENT wpNew;

          if (!IsFullScreen())
          {
              // need to hide all status bars
              m_wndStatusBar.ShowWindow(SW_HIDE);
              m_wndToolBar.ShowWindow(SW_HIDE);

              // We'll need these to restore the original state.
              GetWindowPlacement (&m_wpPrev);

              m_wpPrev.length = sizeof m_wpPrev;

              //Adjust RECT to new size of window
              ::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );
          ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE,
              GetExStyle());

              // Remember this for OnGetMinMaxInfo()
              m_FullScreenWindowRect = rectDesktop;

              wpNew = m_wpPrev;
              wpNew.showCmd =  SW_SHOWNORMAL;
              wpNew.rcNormalPosition = rectDesktop;

              m_pwndFullScrnBar=new CToolBar;

          if(!m_pwndFullScrnBar->Create(this,
             CBRS_SIZE_DYNAMIC|CBRS_FLOATING)
                 || !m_pwndFullScrnBar->LoadToolBar(IDR_FULLSCREEN))
            {
            TRACE0("Failed to create toolbar\n");
                 return;      // fail to create
         }

               //don't allow the toolbar to dock
               m_pwndFullScrnBar->EnableDocking(0);
          m_pwndFullScrnBar->SetWindowPos(0,100,100,
      0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
          m_pwndFullScrnBar->SetWindowText(_T("Full Screen"));
            FloatControlBar(m_pwndFullScrnBar, CPoint(100,100));
          m_bFullScreen=TRUE;
          }
          else
          {
               m_pwndFullScrnBar->DestroyWindow();
          delete m_pwndFullScrnBar;

               m_bFullScreen=FALSE;

               m_wndStatusBar.ShowWindow(SW_SHOWNORMAL);
               m_wndToolBar.ShowWindow(SW_SHOWNORMAL);
               wpNew = m_wpPrev;
           }

           SetWindowPlacement ( &wpNew );
      }

      void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
      {
          if (IsFullScreen())
          {
              lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height();
              lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
              lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width();
              lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
          }

      }

      BOOL CMainFrame::IsFullScreen()
      {
           return m_bFullScreen;
      }

      void CMainFrame::OnUpdateViewFullScreen(CCmdUI* pCmdUI)
      {
          pCmdUI->Enable();

          if (IsFullScreen())
            pCmdUI->SetCheck();
          else
            pCmdUI->SetCheck(0);
      }
  评论这张
 
阅读(82)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018