如何全屏显示? 如何不让一个窗口移动?

flying_fox0 2002-08-28 09:48:06
我在作一个视频程序,

请问如何才能做到全屏显示?

如何才能禁止一个窗口的移动?
...全文
209 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
o_racle 2003-04-27
  • 打赏
  • 举报
回复
全屏显示:
我想在一个SDI应用程序中实现正常的窗口和全屏窗口的切换(没有框架,状态栏,工具条)


class CMainFrame : public CSDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

BOOL GetFullScreenSize(CWnd* pWnd, POINT& pt) const;

protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;

CWnd* m_pWndFullScreen;
WINDOWPLACEMENT m_PreviousPlace;
WINDOWPLACEMENT m_MainPreviousPlace;
CRect m_FullScreenPlace;
CRect m_MainFullScreenPlace;
BOOL m_bHadToolBar;
BOOL m_bHadStatusBar;

public:
void EscapeFullScreen();

// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnViewFullScreen();
afx_msg void OnUpdateViewFullScreen(CCmdUI* pCmdUI);
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

void CMainFrame::EscapeFullScreen()
{
if (m_pWndFullScreen != NULL)
OnViewFullScreen();
}


void CMainFrame::OnViewFullScreen()
{
TRACE("m_wndStatusBar == %d\n", m_wndStatusBar.IsWindowVisible());
TRACE("m_wndToolBar == %d\n", m_wndToolBar.IsWindowVisible());

if (m_pWndFullScreen != NULL)
{
// If we are returning the app to the Maximized state, SetWindowPlacement()
// draws the entire app twice - once to its "Normal" state, then once to
// the maximized state. The LockWindowUpdate() calls suppress the extra
// redraw.

ShowControlBar(&m_wndToolBar, m_bHadToolBar, FALSE);
ShowControlBar(&m_wndStatusBar, m_bHadStatusBar, FALSE);

m_pWndFullScreen->LockWindowUpdate();
m_pWndFullScreen->SetWindowPlacement(&m_PreviousPlace);
m_pWndFullScreen->UnlockWindowUpdate();

LockWindowUpdate();
SetWindowPlacement(&m_MainPreviousPlace);
UnlockWindowUpdate();
m_pWndFullScreen = NULL;
}
else
{
m_pWndFullScreen = MDIGetActive();
ASSERT(m_pWndFullScreen != NULL);

m_bHadToolBar = m_wndToolBar.IsWindowVisible();
m_bHadStatusBar = m_wndStatusBar.IsWindowVisible();
ShowControlBar(&m_wndToolBar, FALSE, FALSE);
ShowControlBar(&m_wndStatusBar,FALSE, FALSE);

m_pWndFullScreen->GetWindowPlacement(&m_PreviousPlace);
GetWindowPlacement(&m_MainPreviousPlace);

CRect rectDesktop;
if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, &rectDesktop, 0))
::GetWindowRect(::GetDesktopWindow(), &rectDesktop);
else
{
rectDesktop.right = ::GetSystemMetrics(SM_CXSCREEN);
rectDesktop.bottom = ::GetSystemMetrics(SM_CYSCREEN);
rectDesktop.right -= rectDesktop.left;
rectDesktop.bottom -= rectDesktop.top;
rectDesktop.left = -rectDesktop.left;
rectDesktop.top = -rectDesktop.top;
}

TRACE("Going to (%d,%d) - (%d,%d)\n", rectDesktop.left, rectDesktop.top,
rectDesktop.right, rectDesktop.bottom);

CRect rectDesired = rectDesktop;
::AdjustWindowRect(&rectDesktop, GetStyle(), TRUE);

TRACE("Adjusted to (%d,%d) - (%d,%d)\n", rectDesktop.left, rectDesktop.top,
rectDesktop.right, rectDesktop.bottom);

rectDesktop.bottom += ::GetSystemMetrics(SM_CYBORDER); // See "Ask Dr. GUI #10"
m_FullScreenPlace = rectDesktop;
m_MainFullScreenPlace = rectDesktop;

WINDOWPLACEMENT wpNew = m_PreviousPlace;
wpNew.showCmd = SW_SHOWNORMAL;
wpNew.rcNormalPosition = rectDesktop;

LockWindowUpdate();
SetWindowPlacement(&wpNew);
UnlockWindowUpdate();

TRACE("Before MDI Child to (%d,%d) - (%d,%d)\n", wpNew.rcNormalPosition.left, wpNew.rcNormalPosition.top,
wpNew.rcNormalPosition.right, wpNew.rcNormalPosition.bottom);

wpNew.rcNormalPosition = rectDesired;
::AdjustWindowRect(&(wpNew.rcNormalPosition), m_pWndFullScreen->GetStyle(), FALSE);

TRACE("MDI Child to (%d,%d) - (%d,%d)\n", wpNew.rcNormalPosition.left, wpNew.rcNormalPosition.top,
wpNew.rcNormalPosition.right, wpNew.rcNormalPosition.bottom);

m_pWndFullScreen->LockWindowUpdate();
m_pWndFullScreen->SetWindowPlacement(&wpNew);
m_pWndFullScreen->UnlockWindowUpdate();
}
}
}

16,473

社区成员

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

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

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