我的代码在单文档界面比较好用,但是在多文档的情况下,全屏不彻底,下面有一个窄条没有添满。我看到有人回答过这个问题,说和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);//必须注销,否则不能编译通过
}
解决方案 »
- MFC关于按钮的状态
- 100分求助,我想做一个漂亮的界面,请问有没有例子?
- Mutex的问题,HANDLE不能用指针传入
- 我是个小菜鸟,我的问题很简单,但是我总是搞不出来
- 请问 各位高手最基础的问题
- 一个程序如何向外提供接口(API)?
- 请教高手???!!!
- 有没有关于Windows下网络监听的源程序,急用!(小弟保证遵守中华人民共和国有关法律、法规,尊重网上道德)
- 非常着急,在对话框中假如了一个picture控件以后,为什么不能显示位图呢??
- 怎样在DLL中应用对话框等资源2????
- 求助,关于多文档的全屏问题
- CAsyncSocket::SendTo中的那个port是什么概念?????????
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// Create a window without min/max buttons or sizable border
cs.style = WS_OVERLAPPED | /*WS_SYSMENU |*/ WS_BORDER; // Size the window to 1/3 screen size and center it
cs.cy = ::GetSystemMetrics(SM_CYSCREEN) / 3;
cs.cx = ::GetSystemMetrics(SM_CXSCREEN) / 3;
cs.y = ((cs.cy * 3) - cs.cy) / 2;
cs.x = ((cs.cx * 3) - cs.cx) / 2; // Call the base-class version
return CFrameWnd::PreCreateWindow(cs);
}WS_POPUPWINDOW Creates a pop-up window with the WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the Control menu visible
改为
CMainFrame::OnGetMinMaxInfo(lpMMI);//
所以不能更改
看看下面的对你应该又帮助
http://www.vckbase.com/code/listcode.asp?mclsid=5&sclsid=509