⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 本例程主要介绍了利用OpenGL来实现了如何建立一个落叶纷飞的场景
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Cmy.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_GETMINMAXINFO()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
		fullscreenkey=FALSE;
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	
	if (!m_wndStatusBar.Create(this,WS_CHILD|CBRS_BOTTOM) ||
		!m_wndStatusBar.SetIndicators(indicators,
		sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	
	if (m_wndStatusBar)
	{
		m_wndStatusBar.SetPaneInfo(0,0,SBPS_STRETCH,50);
		m_wndStatusBar.SetPaneInfo(1,0,0,50);
		m_wndStatusBar.SetPaneInfo(2,0,SBPS_STRETCH,50);
		m_wndStatusBar.SetPaneInfo(3,0,SBPS_STRETCH,50);
	}
	
    fullscreenkey=TRUE;
	CRect winme,clientme;
	GetWindowRect(&winme);
	RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&clientme);
    ClientToScreen(&clientme);
	int fullwide=GetSystemMetrics(SM_CXSCREEN);
	int fullhide=GetSystemMetrics(SM_CYSCREEN);
	
	
	mefullscreen.left=winme.left-clientme.left;
	mefullscreen.top=winme.top-clientme.top;
	mefullscreen.right=winme.right-clientme.right+fullwide;
	mefullscreen.bottom=winme.bottom-clientme.bottom+fullhide;
	
	WINDOWPLACEMENT winfull;
	winfull.length=sizeof(WINDOWPLACEMENT);
	winfull.flags=0;
	winfull.showCmd=SW_SHOWNORMAL;
	winfull.rcNormalPosition=mefullscreen;
	SetWindowPlacement(&winfull);
	
	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	
	return 0;
}

void CMainFrame::xyshow(int x,int y)
{
	CString  strsa;
	if (m_wndStatusBar)
	{
		m_wndStatusBar.SetPaneText(1," ");
		strsa.Format("x=%d",x);
		m_wndStatusBar.SetPaneText(2,strsa);
		strsa.Format("y=%d",y);
		m_wndStatusBar.SetPaneText(3,strsa);
	}

}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	// TODO: Add your message handler code here and/or call default
	if (fullscreenkey)
	{
		lpMMI->ptMaxSize.x=mefullscreen.Width();
		lpMMI->ptMaxSize.y=mefullscreen.Height();
		lpMMI->ptMaxPosition.x=mefullscreen.left;
		lpMMI->ptMaxPosition.y=mefullscreen.top;
		lpMMI->ptMaxTrackSize.x=mefullscreen.Width();
		lpMMI->ptMaxTrackSize.y=mefullscreen.Height();
	}
	CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

BOOL CMainFrame::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	return TRUE;
	//return CFrameWnd::OnEraseBkgnd(pDC);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -