2011年计算机二级C++辅导实例编程(28)

2014-10-19 00:09:09 · 作者: · 浏览: 218

  MFC实现全屏功能的代码


  很多的播放器都有快捷键控制窗口以全屏幕的方式显示。给应用程序加上全屏幕的功能,并不需要很多的代码,比如给一个基于对话框的应用程序加上全屏功能只需要以下少量代码就可以工作了。


  void CFullScreenDlg::FullScreenView(void)


  {


  RECT rectDesktop;


  WINDOWPLACEMENT wpNew;


  if (!IsFullScreen())


  {


  // We'll need these to restore the original state.


  GetWindowPlacement (&m_wpPrev);


  //Adjust RECT to new size of window


  ::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );


  ::AdjustWindowRectEx(&rectDesktop, GetStyle(), FALSE, GetExStyle());


  // Remember this for OnGetMinMaxInfo()


  m_rcFullScreenRect = rectDesktop;


  wpNew = m_wpPrev;