东软总结代码01

来源:互联网 发布:js格式化html代码 编辑:程序博客网 时间:2024/05/16 14:29
// aView.cpp : implementation of the CAView class//#include "stdafx.h"#include "a.h"#include "aDoc.h"#include "aView.h"#include "MainFrm.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CAViewIMPLEMENT_DYNCREATE(CAView, CView)BEGIN_MESSAGE_MAP(CAView, CView)//{{AFX_MSG_MAP(CAView)ON_WM_LBUTTONDOWN()//}}AFX_MSG_MAP// Standard printing commandsON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CAView construction/destructionCAView::CAView(){// TODO: add construction code here}CAView::~CAView(){}BOOL CAView::PreCreateWindow(CREATESTRUCT& cs){// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CAView drawingvoid CAView::OnDraw(CDC* pDC){CADoc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data here/*int nCount = 1;CString str;int x = 10; int y = 10;int temp = 10;for (; nCount < 101; ++nCount){str.Format("%d", nCount);pDC->TextOut(x, y, str);x += 30;if (temp == nCount){x = 10; y += 30;temp += 10;}}CWinApp *pW = ::AfxGetApp();CAApp *pM = (CAApp *)pW;str.Format("%d", pM->a);pDC->TextOut(x, y, str);//可以用下面3句代替后面4句//CWnd *pWw = AfxGetApp()->m_pMainWnd;//CMainFrame *pp = (CMainFrame *)pWw;//pDC->TextOut(x+30, y+30, pp->str);CWinApp *pp = ::AfxGetApp();CWnd *ppp = pp->m_pMainWnd;CMainFrame *ppa = (CMainFrame *)ppp;pDC->TextOut(x+30, y+30, ppa->str);*/pDC->TextOut(500,500,str);/*int x = 10;//坐标int y = 10;CString str;int num = 1;int i;int j;for (i = 0; i < 10; ++i){x = 10;for (j = 0; j < 10; ++j){str.Format("%d", num);pDC->TextOut(x, y, str);x += 30;++num;}y += 30;}*/}/////////////////////////////////////////////////////////////////////////////// CAView printingBOOL CAView::OnPreparePrinting(CPrintInfo* pInfo){// default preparationreturn DoPreparePrinting(pInfo);}void CAView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add extra initialization before printing}void CAView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/){// TODO: add cleanup after printing}/////////////////////////////////////////////////////////////////////////////// CAView diagnostics#ifdef _DEBUGvoid CAView::AssertValid() const{CView::AssertValid();}void CAView::Dump(CDumpContext& dc) const{CView::Dump(dc);}CADoc* CAView::GetDocument() // non-debug version is inline{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CADoc)));return (CADoc*)m_pDocument;}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CAView message handlersvoid CAView::OnLButtonDown(UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultCADoc* pDoc = GetDocument();ASSERT_VALID(pDoc);str = pDoc->str;this->Invalidate();/*CDC *pDC = GetDC();pDC->TextOut(500, 500, pDoc->str);this->Invalidate(false);this->ReleaseDC(pDC);*/CView::OnLButtonDown(nFlags, point);}


 

// a.cpp : Defines the class behaviors for the application.//#include "stdafx.h"#include "a.h"#include "MainFrm.h"#include "aDoc.h"#include "aView.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CAAppBEGIN_MESSAGE_MAP(CAApp, CWinApp)//{{AFX_MSG_MAP(CAApp)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 commandsON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)// Standard print setup commandON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CAApp constructionCAApp::CAApp(){// TODO: add construction code here,// Place all significant initialization in InitInstancea = 101;}/////////////////////////////////////////////////////////////////////////////// The one and only CAApp objectCAApp theApp;/////////////////////////////////////////////////////////////////////////////// CAApp initializationBOOL CAApp::InitInstance(){AfxEnableControlContainer();// 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 _AFXDLLEnable3dControls();// Call this when using MFC in a shared DLL#elseEnable3dControlsStatic();// 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(CADoc),RUNTIME_CLASS(CMainFrame),       // main SDI frame windowRUNTIME_CLASS(CAView));AddDocTemplate(pDocTemplate);// Parse command line for standard shell commands, DDE, file openCCommandLineInfo cmdInfo;ParseCommandLine(cmdInfo);// Dispatch commands specified on the command lineif (!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 Aboutclass 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// Implementationprotected://{{AFX_MSG(CAboutDlg)// No message handlers//}}AFX_MSGDECLARE_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_MAPEND_MESSAGE_MAP()// App command to run the dialogvoid CAApp::OnAppAbout(){CAboutDlg aboutDlg;aboutDlg.DoModal();}/////////////////////////////////////////////////////////////////////////////// CAApp message handlers


 

// MainFrm.cpp : implementation of the CMainFrame class//#include "stdafx.h"#include "a.h"#include "MainFrm.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CMainFrameIMPLEMENT_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_MAPEND_MESSAGE_MAP()static UINT indicators[] ={ID_SEPARATOR,           // status line indicatorID_INDICATOR_CAPS,ID_INDICATOR_NUM,ID_INDICATOR_SCRL,};/////////////////////////////////////////////////////////////////////////////// CMainFrame construction/destructionCMainFrame::CMainFrame(){// TODO: add member initialization code herestr = "mainframe";}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 dockablem_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 csreturn TRUE;}/////////////////////////////////////////////////////////////////////////////// CMainFrame diagnostics#ifdef _DEBUGvoid CMainFrame::AssertValid() const{CFrameWnd::AssertValid();}void CMainFrame::Dump(CDumpContext& dc) const{CFrameWnd::Dump(dc);}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CMainFrame message handlers


 

// a.h : main header file for the A application//#if !defined(AFX_A_H__0FCAED3A_1309_4114_89C0_D02D02B3DC8F__INCLUDED_)#define AFX_A_H__0FCAED3A_1309_4114_89C0_D02D02B3DC8F__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/////////////////////////////////////////////////////////////////////////////// CAApp:// See a.cpp for the implementation of this class//class CAApp : public CWinApp{public:CAApp();int a;// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CAApp)public:virtual BOOL InitInstance();//}}AFX_VIRTUAL// Implementation//{{AFX_MSG(CAApp)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_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_A_H__0FCAED3A_1309_4114_89C0_D02D02B3DC8F__INCLUDED_)


 

// MainFrm.h : interface of the CMainFrame class///////////////////////////////////////////////////////////////////////////////#if !defined(AFX_MAINFRM_H__FF971404_5AD5_4C22_967F_ED42A7FC6EA4__INCLUDED_)#define AFX_MAINFRM_H__FF971404_5AD5_4C22_967F_ED42A7FC6EA4__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000class CMainFrame : public CFrameWnd{protected: // create from serialization onlyCMainFrame();DECLARE_DYNCREATE(CMainFrame)// Attributespublic:CString str;// Operationspublic:// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CMainFrame)virtual BOOL PreCreateWindow(CREATESTRUCT& cs);//}}AFX_VIRTUAL// Implementationpublic:virtual ~CMainFrame();#ifdef _DEBUGvirtual void AssertValid() const;virtual void Dump(CDumpContext& dc) const;#endifprotected:  // control bar embedded membersCStatusBar  m_wndStatusBar;CToolBar    m_wndToolBar;// Generated message map functionsprotected://{{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_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MAINFRM_H__FF971404_5AD5_4C22_967F_ED42A7FC6EA4__INCLUDED_)


 

// aView.h : interface of the CAView class///////////////////////////////////////////////////////////////////////////////#if !defined(AFX_AVIEW_H__8A569E1E_7C89_445A_9F2D_BA87CBB90D91__INCLUDED_)#define AFX_AVIEW_H__8A569E1E_7C89_445A_9F2D_BA87CBB90D91__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000class CAView : public CView{protected: // create from serialization onlyCAView();DECLARE_DYNCREATE(CAView)// Attributespublic:CADoc* GetDocument();CString str;// Operationspublic:// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CAView)public:virtual void OnDraw(CDC* pDC);  // overridden to draw this viewvirtual 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// Implementationpublic:virtual ~CAView();#ifdef _DEBUGvirtual void AssertValid() const;virtual void Dump(CDumpContext& dc) const;#endifprotected:// Generated message map functionsprotected://{{AFX_MSG(CAView)afx_msg void OnLButtonDown(UINT nFlags, CPoint point);//}}AFX_MSGDECLARE_MESSAGE_MAP()};#ifndef _DEBUG  // debug version in aView.cppinline CADoc* CAView::GetDocument()   { return (CADoc*)m_pDocument; }#endif///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_AVIEW_H__8A569E1E_7C89_445A_9F2D_BA87CBB90D91__INCLUDED_)