字符串输出

// yingView.cpp : implementation of the CYingView class
//

#include "stdafx.h"
#include "ying.h"
#include  "MainFrm.h "
#include "yingDoc.h"
#include "yingView.h"
//#include "afxGetApp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CYingView

IMPLEMENT_DYNCREATE(CYingView, CView)

BEGIN_MESSAGE_MAP(CYingView, CView)
	//{{AFX_MSG_MAP(CYingView)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_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()

/////////////////////////////////////////////////////////////////////////////
// CYingView construction/destruction

CYingView::CYingView()
{
	// TODO: add construction code here

}

CYingView::~CYingView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CYingView drawing

void CYingView::OnDraw(CDC* pDC)
{
	CYingDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here	int x = 10;
	int y = 30;
	int x = 10;
	int num = 1;
	CString str;
    int temp=10;
	for (num=1; num<101; ++num)
	{
			str.Format("%d", num);
			pDC->TextOut(x, y, str);
			x += 30;
	
    	if(num==temp)
		{
	    	y+=30;
		    temp+=10;
		    x=10;
		}
	}
	CWinApp *pG=::AfxGetApp();
	CYingApp *pM=(CYingApp*)pG;
	pDC->TextOut(100,330,pM->str);

	CWnd *pW=AfxGetApp()->m_pMainWnd;
	CMainFrame *pp=(CMainFrame*)pW;
	pDC->TextOut(100,10,pp->str);

}

/////////////////////////////////////////////////////////////////////////////
// CYingView printing

BOOL CYingView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CYingView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CYingView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CYingView diagnostics

#ifdef _DEBUG
void CYingView::AssertValid() const
{
	CView::AssertValid();
}

void CYingView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CYingView message handlers

void CYingView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CYingDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
/*	CDC*pDC=this->GetDC();
	pDC->TextOut(100,360,pDoc->str);
	this->ReleaseDC(pDC);*/
	CClientDC dc(this);
	dc.TextOut(100,360,pDoc->str);
	CView::OnLButtonDown(nFlags, point);
}

你可能感兴趣的:(字符串输出)