在单文挡中如何实现全屏显示?

leng 2000-08-11 11:49:00
在单文挡中如何实现全屏显示?
...全文
138 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2000-08-13
  • 打赏
  • 举报
回复
search FullScreen in MSDN
celxta 2000-08-12
  • 打赏
  • 举报
回复
Sorry:刚才忘记了放代码,如下
声明:
BOOL m_bFullScreen;
CRect m_FullScreenRect;
WINDOWPLACEMENT m_OldWndpl;
void OnFullScreen();
函数:
void CMainFrame::OnFullScreen()
{
/*
BOOL m_bFullScreen;
CRect m_FullScreenRect;
WINDOWPLACEMENT m_OldWndpl;
void OnFullScreen();
*/
//保存原来的窗口
GetWindowPlacement(&m_OldWndpl);
//保存控制条位置
CRect WindowRect,ClientRect;
GetWindowRect(&WindowRect);
RepositionBars(0,0xffff, AFX_IDW_PANE_FIRST,reposQuery,&ClientRect);
ClientToScreen(&ClientRect);
//显示客户区
m_FullScreenRect.left =WindowRect.left -ClientRect.left ;
m_FullScreenRect.top =WindowRect.top -ClientRect.top ;
m_FullScreenRect.right =WindowRect.right -ClientRect.right +ScreenWidth ;
m_FullScreenRect.bottom =WindowRect.bottom -ClientRect.bottom +ScreenHeight;
//设置全屏显示标志
m_bFullScreen=TRUE;
//全屏显示
WINDOWPLACEMENT wndpl;
wndpl.length =sizeof(WINDOWPLACEMENT);
wndpl.flags =0;
wndpl.showCmd =SW_SHOWNORMAL;
wndpl.rcNormalPosition =m_FullScreenRect;
SetWindowPlacement(&wndpl);
}


void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if(m_bFullScreen){
lpMMI->ptMaxSize.x = m_FullScreenRect.Width();
lpMMI->ptMaxSize.y = m_FullScreenRect.Height ();
lpMMI->ptMaxPosition.x = m_FullScreenRect.left;
lpMMI->ptMaxPosition.y = m_FullScreenRect.top ;
lpMMI->ptMaxTrackSize.x =m_FullScreenRect.Width();
lpMMI->ptMaxTrackSize.y =m_FullScreenRect.Height ();
}
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
celxta 2000-08-12
  • 打赏
  • 举报
回复
这是我实现的方法,很稳定,也可还原非全屏显示

email: celxta@cmmail.com
creative 2000-08-12
  • 打赏
  • 举报
回复
参看MSDN Help的Knowledge Base的Q164162, 会给你一个满意的答案。
leng 2000-08-11
  • 打赏
  • 举报
回复
在基于对话框的程序中:
我利用GetWindowPlacement() and SetWindowPlacement()
可以实现全屏显示,
但在但文挡中,只能使工具条和状态条消失,而不能全屏显示,不只为什么?
谢谢你的回答!
haitian99 2000-08-11
  • 打赏
  • 举报
回复
Thanks.
hyzx2000 2000-08-11
  • 打赏
  • 举报
回复
下面的程序实现了你所需的要求:(多文档的,单文档的原理也是一样的)
http://210.77.145.209/dev/Visual%20C++/source%20code/Bitmap/dibimage.zip
仔细阅读 MainFrm.cpp的OnViewFullScreen()。这个我在单文档下试过,可以。
具体代码:(你要添加变量m_bIsFullScreen,m_Menu等,并修改下面的代码)
// if the view is now full screen, change the view to normal size and state
if (m_bIsFullScreen)
{
// add the WS_CAPTION and WS_THICKFRAME styles to the frame window
ModifyStyle(0,WS_CAPTION);
ModifyStyle(0,WS_THICKFRAME);

// restore the frame window to normal size and state
ShowWindow(SW_SHOWNORMAL); // restore the default menu and show it
SetMenu(&m_Menu);
m_Menu.Detach();


//re show the toolbars
ShowControlBar(&m_HistogramBar, m_bHistogramVisible, FALSE);
ShowControlBar(&m_PaletteBar, m_bPaletteVisible, FALSE);
ShowControlBar(&m_wndToolBar, m_bToolbarVisible, FALSE);
ShowControlBar(&m_wndStatusBar, m_bStatusbarVisible, FALSE);
ShowControlBar(&m_wndToolBar2, m_bToolbar2Visible, FALSE);

// set flag to indicate that frame window is now NOT full screen
m_bIsFullScreen = 0;
}
// if the view is now normal, change the view to full screen
else
{
//remember each of the controlbars visibility before we hide them
m_bHistogramVisible = ((m_HistogramBar.GetStyle() & WS_VISIBLE) != 0);
m_bPaletteVisible = ((m_PaletteBar.GetStyle() & WS_VISIBLE) != 0);
m_bToolbarVisible = ((m_wndToolBar.GetStyle() & WS_VISIBLE) != 0);
m_bStatusbarVisible = ((m_wndStatusBar.GetStyle() & WS_VISIBLE) != 0);
m_bToolbar2Visible = ((m_wndToolBar2.GetStyle() & WS_VISIBLE) != 0);


m_Menu.Attach(GetMenu()->m_hMenu);

// remove the WS_CAPTION and WS_THICKFRAME styles from the frame window
ModifyStyle(WS_CAPTION,0);
ModifyStyle(WS_THICKFRAME,0);
// remove the default menu and erase the menu
SetMenu(NULL);
// show the now menuless and frameless window full screen
ShowWindow(SW_MAXIMIZE);

ShowControlBar(&m_HistogramBar, FALSE, FALSE);
ShowControlBar(&m_PaletteBar, FALSE, FALSE);
ShowControlBar(&m_wndToolBar, FALSE, FALSE);
ShowControlBar(&m_wndStatusBar, FALSE, FALSE);
ShowControlBar(&m_wndToolBar2, FALSE, FALSE);

CFrameWnd* pFrame = GetActiveFrame();
if (pFrame)
pFrame->ShowWindow(SW_MAXIMIZE);

//reset the flag to indicate that the view is now full screen
m_bIsFullScreen = 1;
}

16,470

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧