MyFirst程序详解

来源:互联网 发布:怎么下载淘宝软件 编辑:程序博客网 时间:2024/06/05 08:24


1.StdAfx.h


// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__3049EDC7_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)
#define AFX_STDAFX_H__3049EDC7_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_  //做初始化,定义一些必要的宏,包含一些必要的头文件,MFC默认是包含这个          //文件的,所以在这里尽量包含那些公用的文件,比如支持MFC的,或者其他的,凡是afx开头的文件,都是和MFC有关的

#if _MSC_VER > 1000  //如果MFC的版本大于4.2
#pragma once //这个头文件只编译一次,为了类库的兼容性考虑,想以前的C的类库
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers 剔除掉一些极少用到的函数和数据类型

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>   // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__3049EDC7_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)



2.Resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MYFIRST.RC
//
#define IDD_ABOUTBOX    100 //定义全局常量 或宏定义
#define IDR_MAINFRAME    128 //定义全局常量或宏定义
#define IDR_MYFIRSTYPE    129 //定义全局常量或宏定义

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED   //定义全局常量 或宏定义
#ifndef APSTUDIO_READONLY_SYMBOLS   //定义全局常量 或宏定义
#define _APS_3D_CONTROLS   1   //定义全局常量 或宏定义
#define _APS_NEXT_RESOURCE_VALUE 130   //定义全局常量 或宏定义
#define _APS_NEXT_CONTROL_VALUE  1000   //定义全局常量 或宏定义
#define _APS_NEXT_SYMED_VALUE  101   //定义全局常量 或宏定义
#define _APS_NEXT_COMMAND_VALUE  32771 //定义全局常量 或宏定义
#endif
#endif


3.MyFirstView.h

// MyFirstView.h : interface of the CMyFirstView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYFIRSTVIEW_H__3049EDCD_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)
#define AFX_MYFIRSTVIEW_H__3049EDCD_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CMyFirstView : public CEditView
{
protected: // create from serialization only
 CMyFirstView();
 DECLARE_DYNCREATE(CMyFirstView) //内部使用了 DECLARE_DYNAMIC 宏,即声明“运行时类型识别”宏。为了确定运行时对象属于哪一个类而定义的宏。为了确定运行时对象属于哪一个类而定义的宏。

// Attributes
public:
 CMyFirstDoc* GetDocument();//函数GetDocument()用于获取当前文档对象的指针m_pDocument
 CPoint startpt;
// Operations
public:

// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CMyFirstView)
 public:
 virtual void OnDraw(CDC* pDC);  // overridden to draw this view
 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 protected:
 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
 //}}AFX_VIRTUAL

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

protected:

// Generated message map functions
protected:
 //{{AFX_MSG(CMyFirstView)
 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in MyFirstView.cpp
inline CMyFirstDoc* CMyFirstView::GetDocument()
   { return (CMyFirstDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYFIRSTVIEW_H__3049EDCD_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)



4.MyFirstDoc.h

// MyFirstDoc.h : interface of the CMyFirstDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYFIRSTDOC_H__3049EDCB_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)
#define AFX_MYFIRSTDOC_H__3049EDCB_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CMyFirstDoc : public CDocument
{
protected: // create from serialization only
 CMyFirstDoc();
 DECLARE_DYNCREATE(CMyFirstDoc)

// Attributes
public:

// Operations
public:

// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CMyFirstDoc)
 public:
 virtual BOOL OnNewDocument();
 virtual void Serialize(CArchive& ar);
 //}}AFX_VIRTUAL

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

protected:

// Generated message map functions
protected:
 //{{AFX_MSG(CMyFirstDoc)
  // NOTE - the ClassWizard will add and remove member functions here.
  //    DO NOT EDIT what you see in these blocks of generated code !
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYFIRSTDOC_H__3049EDCB_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)




5.MyFirst.h

// MyFirst.h : main header file for the MYFIRST application
//

#if !defined(AFX_MYFIRST_H__3049EDC5_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)
#define AFX_MYFIRST_H__3049EDC5_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
 #error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CMyFirstApp:
// See MyFirst.cpp for the implementation of this class
//

class CMyFirstApp : public CWinApp
{
public:
 CMyFirstApp();

// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CMyFirstApp)
 public:
 virtual BOOL InitInstance();
 //}}AFX_VIRTUAL

// Implementation
 //{{AFX_MSG(CMyFirstApp)
 afx_msg void OnAppAbout();
  // NOTE - the ClassWizard will add and remove member functions here.
  //    DO NOT EDIT what you see in these blocks of generated code !
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYFIRST_H__3049EDC5_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)




6.MainFrm.h

// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__3049EDC9_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)
#define AFX_MAINFRM_H__3049EDC9_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMainFrame : public CFrameWnd
{
 
protected: // create from serialization only
 CMainFrame();
 DECLARE_DYNCREATE(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

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

// Generated message map functions
protected:
 //{{AFX_MSG(CMainFrame)
 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  // NOTE - the ClassWizard will add and remove member functions here.
  //    DO NOT EDIT what you see in these blocks of generated code!
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__3049EDC9_863F_11D4_ADBB_5254AB1AFF2A__INCLUDED_)




7.StdAfx.cpp

// stdafx.cpp : source file that includes just the standard includes
// MyFirst.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"






8.MyFirstView.cpp

// MyFirstView.cpp : implementation of the CMyFirstView class
//

#include "stdafx.h"
#include "MyFirst.h"

#include "MyFirstDoc.h"
#include "MyFirstView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView

IMPLEMENT_DYNCREATE(CMyFirstView, CEditView) //通过DECLARE_DYNCREATE宏来使用IMPLEMENT_DYNCREATE宏,以允许CObject派生类对象在运行时                 //自动建立。主机使用此功能自动建立对象,IMPLEMENT_DYNCREATE(class_name,base_class_name) 

BEGIN_MESSAGE_MAP(CMyFirstView, CEditView)
 //{{AFX_MSG_MAP(CMyFirstView)
 ON_WM_LBUTTONDOWN()
 ON_WM_LBUTTONUP()
 ON_WM_MOUSEMOVE()
 //}}AFX_MSG_MAP
 // Standard printing commands
 ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint) //
 ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView construction/destruction

CMyFirstView::CMyFirstView()
{
 // TODO: add construction code here
    startpt = -1;
    //You may replace the above two lines
 //for the following two lines;
// startpt.x=-1;
// startpt.y=-1;

}

CMyFirstView::~CMyFirstView()
{
}

BOOL CMyFirstView::PreCreateWindow(CREATESTRUCT& cs)
{
 // TODO: Modify the Window class or styles here by modifying
 //  the CREATESTRUCT cs

 BOOL bPreCreated = CEditView::PreCreateWindow(cs);
 cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping

 return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView drawing

void CMyFirstView::OnDraw(CDC* pDC)
{
 CMyFirstDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);                                           //是一个断定宏,就是肯定pDoc不为空,如果pDoc为NULL就不继续运行的意思。
 // TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView printing

BOOL CMyFirstView::OnPreparePrinting(CPrintInfo* pInfo)
{
 // default CEditView preparation
 return CEditView::OnPreparePrinting(pInfo);
}

void CMyFirstView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
 // Default CEditView begin printing.
 CEditView::OnBeginPrinting(pDC, pInfo);
}

void CMyFirstView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
 // Default CEditView end printing
 CEditView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView diagnostics

#ifdef _DEBUG
void CMyFirstView::AssertValid() const
{
 CEditView::AssertValid();
}

void CMyFirstView::Dump(CDumpContext& dc) const
{
 CEditView::Dump(dc);
}

CMyFirstDoc* CMyFirstView::GetDocument() // non-debug version is inline
{
 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyFirstDoc)));
 return (CMyFirstDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyFirstView message handlers

void CMyFirstView::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 startpt=point;
 // CView::OnLButtonDown(nFlags, point);
 
 CEditView::OnLButtonDown(nFlags, point);
}

void CMyFirstView::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 startpt = -1; 
 CEditView::OnLButtonUp(nFlags, point);
}

void CMyFirstView::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 CClientDC dc(this);

 if (startpt.x != -1 )
 {
  dc.MoveTo(startpt);
  dc.LineTo(point);
  startpt = point;
 }
 
 CEditView::OnMouseMove(nFlags, point);
}


9.MyFirstDoc.cpp

// MyFirstDoc.cpp : implementation of the CMyFirstDoc class
//

#include "stdafx.h"
#include "MyFirst.h"

#include "MyFirstDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyFirstDoc

IMPLEMENT_DYNCREATE(CMyFirstDoc, CDocument)

BEGIN_MESSAGE_MAP(CMyFirstDoc, CDocument)
 //{{AFX_MSG_MAP(CMyFirstDoc)
  // NOTE - the ClassWizard will add and remove mapping macros here.
  //    DO NOT EDIT what you see in these blocks of generated code!
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyFirstDoc construction/destruction

CMyFirstDoc::CMyFirstDoc()
{
 // TODO: add one-time construction code here

}

CMyFirstDoc::~CMyFirstDoc()
{
}

BOOL CMyFirstDoc::OnNewDocument()//OnNewDocument() 创建新文档时用户对自己文档对象的内容初始化内容。

{
 if (!CDocument::OnNewDocument())
  return FALSE;

 ((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);//每个 Document 可以对应多个 view; m_viewList 是 CDocument 的一个成员变量, 存储它所对应的 views

 // TODO: add reinitialization code here
 // (SDI documents will reuse this document)

 return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CMyFirstDoc serialization

void CMyFirstDoc::Serialize(CArchive& ar)
{
 // CEditView contains an edit control which handles all serialization
 ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
}

/////////////////////////////////////////////////////////////////////////////
// CMyFirstDoc diagnostics

#ifdef _DEBUG
void CMyFirstDoc::AssertValid() const
{
 CDocument::AssertValid();
}

void CMyFirstDoc::Dump(CDumpContext& dc) const
{
 CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyFirstDoc commands



10.MyFirst.cpp

// MyFirst.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "MyFirst.h"

#include "MainFrm.h"
#include "MyFirstDoc.h"
#include "MyFirstView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyFirstApp

BEGIN_MESSAGE_MAP(CMyFirstApp, CWinApp)
 //{{AFX_MSG_MAP(CMyFirstApp)
 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  // NOTE - the ClassWizard will add and remove mapping macros here.
  //    DO NOT EDIT what you see in these blocks of generated code!
 //}}AFX_MSG_MAP
 // Standard file based document commands
 ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
 ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
 // Standard print setup command
 ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyFirstApp construction

CMyFirstApp::CMyFirstApp()
{
 // TODO: add construction code here,
 // Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CMyFirstApp object

CMyFirstApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CMyFirstApp initialization

BOOL CMyFirstApp::InitInstance()
{
 // Standard initialization
 // If you are not using these features and wish to reduce the size
 //  of your final executable, you should remove from the following
 //  the specific initialization routines you do not need.

#ifdef _AFXDLL
 Enable3dControls();   // Call this when using MFC in a shared DLL
#else
 Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

 // Change the registry key under which our settings are stored.
 // TODO: You should modify this string to be something appropriate
 // such as the name of your company or organization.
 SetRegistryKey(_T("Local AppWizard-Generated Applications"));

 LoadStdProfileSettings();  // Load standard INI file options (including MRU)

 // Register the application's document templates.  Document templates
 //  serve as the connection between documents, frame windows and views.

 CSingleDocTemplate* pDocTemplate;
 pDocTemplate = new CSingleDocTemplate(
  IDR_MAINFRAME,
  RUNTIME_CLASS(CMyFirstDoc),
  RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  RUNTIME_CLASS(CMyFirstView));
 AddDocTemplate(pDocTemplate);

 // Parse command line for standard shell commands, DDE, file open
 CCommandLineInfo cmdInfo;
 ParseCommandLine(cmdInfo);

 // Dispatch commands specified on the command line
 if (!ProcessShellCommand(cmdInfo))
  return FALSE;

 // The one and only window has been initialized, so show and update it.
 m_pMainWnd->ShowWindow(SW_SHOW);
 m_pMainWnd->UpdateWindow();

 return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
 CAboutDlg();

// Dialog Data
 //{{AFX_DATA(CAboutDlg)
 enum { IDD = IDD_ABOUTBOX };
 //}}AFX_DATA

 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CAboutDlg)
 protected:
 virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
 //}}AFX_VIRTUAL

// Implementation
protected:
 //{{AFX_MSG(CAboutDlg)
  // No message handlers
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
 //{{AFX_DATA_INIT(CAboutDlg)
 //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CAboutDlg)
 //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
 //{{AFX_MSG_MAP(CAboutDlg)
  // No message handlers
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CMyFirstApp::OnAppAbout()
{
 CAboutDlg aboutDlg;
 aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CMyFirstApp message handlers




11.MainFrm.CPP

// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "MyFirst.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)
  // NOTE - the ClassWizard will add and remove mapping macros here.
  //    DO NOT EDIT what you see in these blocks of generated code !
 ON_WM_CREATE()
 //}}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
 
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  return -1;
 
 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(IDR_MAINFRAME))
 {
  TRACE0("Failed to create toolbar\n");
  return -1;      // fail to create
 }

 if (!m_wndStatusBar.Create(this) ||
  !m_wndStatusBar.SetIndicators(indicators,
    sizeof(indicators)/sizeof(UINT)))
 {
  TRACE0("Failed to create status bar\n");
  return -1;      // fail to create
 }

 // 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;
}

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




12.






0 0
原创粉丝点击