• 大小: 166KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: C/C++
  • 标签: Ogre  mfc  嵌入  结合  C++  

资源简介

本例实现了Ogre嵌入MFC框架,也实现了键盘和鼠标的事件响应。适合初学者学习,我的博客中有详解。

资源截图

代码片段和文件信息


// MainFrm.cpp : CMainframe 类的实现
//

#include “stdafx.h“
#include “OgreTest2.h“

#include “MainFrm.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CMainframe

IMPLEMENT_DYNCREATE(CMainframe CframeWndEx)

const int  iMaxUserToolbars = 10;
const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40;
const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1;

BEGIN_MESSAGE_MAP(CMainframe CframeWndEx)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_CUSTOMIZE &CMainframe::OnViewCustomize)
ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR &CMainframe::OnToolbarCreateNew)
ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000 ID_VIEW_APPLOOK_WINDOWS_7 &CMainframe::OnApplicationLook)
ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000 ID_VIEW_APPLOOK_WINDOWS_7 &CMainframe::OnUpdateApplicationLook)
END_MESSAGE_MAP()

static UINT indicators[] =
{
ID_SEPARATOR           // 状态行指示器
ID_INDICATOR_CAPS
ID_INDICATOR_NUM
ID_INDICATOR_SCRL
};

// CMainframe 构造/析构

CMainframe::CMainframe()
{
// TODO: 在此添加成员初始化代码
theApp.m_nAppLook = theApp.GetInt(_T(“ApplicationLook“) ID_VIEW_APPLOOK_VS_2008);
}

CMainframe::~CMainframe()
{
}

int CMainframe::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CframeWndEx::OnCreate(lpCreateStruct) == -1)
return -1;

BOOL bNameValid;
// 基于持久值设置视觉管理器和样式
OnApplicationLook(theApp.m_nAppLook);

if (!m_wndMenuBar.Create(this))
{
TRACE0(“未能创建菜单栏\n“);
return -1;      // 未能创建
}

m_wndMenuBar.SetPanestyle(m_wndMenuBar.GetPanestyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

// 防止菜单栏在激活时获得焦点
CMFCPopupMenu::SetForceMenuFocus(FALSE);

if (!m_wndToolBar.CreateEx(this TBstyle_FLAT WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINframe_256 : IDR_MAINframe))
{
TRACE0(“未能创建工具栏\n“);
return -1;      // 未能创建
}

CString strToolBarName;
bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
ASSERT(bNameValid);
m_wndToolBar.SetWindowText(strToolBarName);

CString strCustomize;
bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
ASSERT(bNameValid);
m_wndToolBar.EnableCustomizeButton(TRUE ID_VIEW_CUSTOMIZE strCustomize);

// 允许用户定义的工具栏操作:
InitUserToolbars(NULL uiFirstUserToolBarId uiLastUserToolBarId);

if (!m_wndStatusBar.Create(this))
{
TRACE0(“未能创建状态栏\n“);
return -1;      // 未能创建
}
m_wndStatusBar.SetIndicators(indicators sizeof(indicators)/sizeof(UINT));

// TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);


// 启用 Visual Studio 2005 样式停靠窗口行为
CDockingManager::SetDockingMode(DT_SMART);
// 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为
EnableAutoHidePanes(CBRS_ALIGN_ANY);

// 启用工具栏和停靠窗口菜单替换
EnablePaneMenu(TRUE

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-05-17 13:26  OgreTest2\
     目录           0  2014-05-17 13:25  OgreTest2\OgreTest2\
     文件         894  2014-05-16 08:35  OgreTest2\OgreTest2.sln
     文件       15360  2014-05-17 13:18  OgreTest2\OgreTest2.suo
     文件        8691  2014-05-16 08:35  OgreTest2\OgreTest2\MainFrm.cpp
     文件        1095  2014-05-16 08:35  OgreTest2\OgreTest2\MainFrm.h
     文件        2732  2014-05-17 11:06  OgreTest2\OgreTest2\MyframeListener.cpp
     文件        1414  2014-05-17 11:06  OgreTest2\OgreTest2\MyframeListener.h
     文件        3525  2014-05-17 13:14  OgreTest2\OgreTest2\MyOgreApp.cpp
     文件        1297  2014-05-16 20:21  OgreTest2\OgreTest2\MyOgreApp.h
     文件      110368  2014-05-16 16:22  OgreTest2\OgreTest2\OgreTest2.aps
     文件        4954  2014-05-16 08:34  OgreTest2\OgreTest2\OgreTest2.cpp
     文件         671  2014-05-16 08:34  OgreTest2\OgreTest2\OgreTest2.h
     文件       24844  2014-05-16 08:35  OgreTest2\OgreTest2\OgreTest2.rc
     文件        7042  2014-05-16 20:28  OgreTest2\OgreTest2\OgreTest2.vcxproj
     文件        3113  2014-05-16 20:28  OgreTest2\OgreTest2\OgreTest2.vcxproj.filters
     文件         568  2014-05-16 15:11  OgreTest2\OgreTest2\OgreTest2.vcxproj.user
     文件        2574  2014-05-16 08:35  OgreTest2\OgreTest2\OgreTest2Doc.cpp
     文件         865  2014-05-16 08:35  OgreTest2\OgreTest2\OgreTest2Doc.h
     文件        3480  2014-05-17 10:56  OgreTest2\OgreTest2\OgreTest2View.cpp
     文件        1325  2014-05-16 16:26  OgreTest2\OgreTest2\OgreTest2View.h
     文件        3530  2014-05-16 08:34  OgreTest2\OgreTest2\ReadMe.txt
     目录           0  2014-05-16 08:35  OgreTest2\OgreTest2\res\
     文件        1319  2014-05-16 08:35  OgreTest2\OgreTest2\Resource.h
     文件       67777  2009-08-31 02:31  OgreTest2\OgreTest2\res\OgreTest2.ico
     文件         674  2014-05-16 08:35  OgreTest2\OgreTest2\res\OgreTest2.rc2
     文件        4710  2009-08-31 02:31  OgreTest2\OgreTest2\res\OgreTest2Doc.ico
     文件        1078  2009-08-31 02:31  OgreTest2\OgreTest2\res\Toolbar.bmp
     文件        5816  2009-08-31 03:59  OgreTest2\OgreTest2\res\Toolbar256.bmp
     文件         142  2014-05-16 08:35  OgreTest2\OgreTest2\stdafx.cpp
     文件        1632  2014-05-16 08:34  OgreTest2\OgreTest2\stdafx.h
............此处省略3个文件信息

评论

共有 条评论