我的代码在单文档界面比较好用,但是在多文档的情况下,全屏不彻底,下面有一个窄条没有添满。我看到有人回答过这个问题,说和WS_POPUPWINDOW有关,但是我打不开那个网页,只好来这里问高手了。我的代码如下:
首先在MainFrm.h中
BOOL m_FullScreen;
WINDOWPLACEMENT m_WPPrev;
CRect m_FullScreenWindowRect;
CToolBar *m_pWndFullScreenBar;
然后
void CMainFrame::OnFullScreen()
{
RECT DesktopRect;
WINDOWPLACEMENT WPNew;
m_FullScreen = m_FullScreen ? TRUE : FALSE;
if(!m_FullScreen)
{
// need to hide all status bars
m_wndStatusBar.ShowWindow(SW_HIDE);
//隐藏工具条
m_wndToolBar.ShowWindow(SW_HIDE);
m_Layout.ShowWindow(SW_HIDE);
m_LayoutGL.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(), &DesktopRect);
DesktopRect.left -= 1;
DesktopRect.top -= 1;
DesktopRect.bottom += 2;
DesktopRect.right += 2;
::AdjustWindowRectEx(&DesktopRect, GetStyle(), TRUE, GetExStyle());
// Remember this for OnGetMinMaxInfo()
m_FullScreenWindowRect = DesktopRect;
WPNew = m_WPPrev;
WPNew.showCmd = SW_SHOWNORMAL;
WPNew.rcNormalPosition = DesktopRect;
m_pWndFullScreenBar=new CToolBar;
if(!m_pWndFullScreenBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) ||
!m_pWndFullScreenBar->LoadToolBar(IDR_FULLSCREEN_GLTOOL))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
}
//don't allow the toolbar to dock
m_pWndFullScreenBar->EnableDocking(0);
m_pWndFullScreenBar->SetWindowPos(0, 0,0, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
m_pWndFullScreenBar->SetWindowText(_T("Hold Ctrl+F to switch between normal and a full screen"));
FloatControlBar(m_pWndFullScreenBar, CPoint(0,0));
m_pWndFullScreenBar->EnableToolTips(TRUE);
m_FullScreen=TRUE;
m_Workshop.ShowWindow(SW_HIDE);
}
else
{
m_pWndFullScreenBar->DestroyWindow();
delete m_pWndFullScreenBar;
m_FullScreen=FALSE;
m_wndStatusBar.ShowWindow(SW_SHOWNORMAL);
m_wndToolBar.ShowWindow(SW_SHOWNORMAL);
m_Layout.ShowWindow(SW_SHOWNORMAL);
m_LayoutGL.ShowWindow(SW_SHOWNORMAL);
m_Workshop.ShowWindow(SW_SHOWNORMAL);
WPNew = m_WPPrev;
}
SetWindowPlacement(&WPNew);
}void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if(m_FullScreen)
{
lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height();
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width();
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
}
// CCJFrameWnd::OnGetMinMaxInfo(lpMMI);//必须注销,否则不能编译通过
}
首先在MainFrm.h中
BOOL m_FullScreen;
WINDOWPLACEMENT m_WPPrev;
CRect m_FullScreenWindowRect;
CToolBar *m_pWndFullScreenBar;
然后
void CMainFrame::OnFullScreen()
{
RECT DesktopRect;
WINDOWPLACEMENT WPNew;
m_FullScreen = m_FullScreen ? TRUE : FALSE;
if(!m_FullScreen)
{
// need to hide all status bars
m_wndStatusBar.ShowWindow(SW_HIDE);
//隐藏工具条
m_wndToolBar.ShowWindow(SW_HIDE);
m_Layout.ShowWindow(SW_HIDE);
m_LayoutGL.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(), &DesktopRect);
DesktopRect.left -= 1;
DesktopRect.top -= 1;
DesktopRect.bottom += 2;
DesktopRect.right += 2;
::AdjustWindowRectEx(&DesktopRect, GetStyle(), TRUE, GetExStyle());
// Remember this for OnGetMinMaxInfo()
m_FullScreenWindowRect = DesktopRect;
WPNew = m_WPPrev;
WPNew.showCmd = SW_SHOWNORMAL;
WPNew.rcNormalPosition = DesktopRect;
m_pWndFullScreenBar=new CToolBar;
if(!m_pWndFullScreenBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) ||
!m_pWndFullScreenBar->LoadToolBar(IDR_FULLSCREEN_GLTOOL))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
}
//don't allow the toolbar to dock
m_pWndFullScreenBar->EnableDocking(0);
m_pWndFullScreenBar->SetWindowPos(0, 0,0, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
m_pWndFullScreenBar->SetWindowText(_T("Hold Ctrl+F to switch between normal and a full screen"));
FloatControlBar(m_pWndFullScreenBar, CPoint(0,0));
m_pWndFullScreenBar->EnableToolTips(TRUE);
m_FullScreen=TRUE;
m_Workshop.ShowWindow(SW_HIDE);
}
else
{
m_pWndFullScreenBar->DestroyWindow();
delete m_pWndFullScreenBar;
m_FullScreen=FALSE;
m_wndStatusBar.ShowWindow(SW_SHOWNORMAL);
m_wndToolBar.ShowWindow(SW_SHOWNORMAL);
m_Layout.ShowWindow(SW_SHOWNORMAL);
m_LayoutGL.ShowWindow(SW_SHOWNORMAL);
m_Workshop.ShowWindow(SW_SHOWNORMAL);
WPNew = m_WPPrev;
}
SetWindowPlacement(&WPNew);
}void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if(m_FullScreen)
{
lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height();
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width();
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
}
// CCJFrameWnd::OnGetMinMaxInfo(lpMMI);//必须注销,否则不能编译通过
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货