?? scrollview.cpp
字號:
// ScrollView.cpp : implementation file
//
#include "stdafx.h"
#include "Ex07b.h"
#include "ScrollView.h"
#include "Ex07bDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx07bScrollView
IMPLEMENT_DYNCREATE(CEx07bScrollView, CScrollView)
CEx07bScrollView::CEx07bScrollView()
{
}
CEx07bScrollView::~CEx07bScrollView()
{
}
BEGIN_MESSAGE_MAP(CEx07bScrollView, CScrollView)
//{{AFX_MSG_MAP(CEx07bScrollView)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) //Attention here!!!!
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) //Attention here!!!!
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) //Attention here!!!!
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx07bScrollView drawing
void CEx07bScrollView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize size;
size.cx =00;
size.cy = 00;//(這個自己定) ;
SetScrollSizes(MM_TEXT,size);
ResizeParentToFit();
//CScrollView::OnInitialUpdate();
//CSize sizePage;
//sizePage.cx=sizePage.cy=400;
//SetScrollSizes(MM_TEXT,sizePage);
}
void CEx07bScrollView::OnDraw(CDC* pDC)
{
CEx07bDoc* pDoc = GetDocument();
// TODO: add draw code here
ASSERT_VALID(pDoc);
char str[64];
int i=1;
//Title Dispaly
pDC->TextOut(20,0,"第幾項");
pDC->TextOut(90,0,"項目");
pDC->TextOut(175,0,"頻數");
pDC->TextOut(240,0,"百分比");
pDC->TextOut(320,0,"累計百分比");
pDC->TextOut(180,20,"(次)");
pDC->TextOut(255,20,"(%)");
pDC->TextOut(355,20,"(%)");
POSITION pos=pDoc->m_dataList.GetHeadPosition();
while(pos!=NULL)
{
CStudent *pStudent=pDoc->m_dataList.GetNext(pos);
if(pos==pDoc->curPos||
(pos==NULL&&pDoc->curPos==pDoc->m_dataList.GetHeadPosition()))
pDC->TextOut(0,20*(i+1),"=>");
sprintf(str,"%d",i );
pDC->TextOut(30,20*(i+1),str);
sprintf(str,"%6.0f",pStudent->m_nCode);
pDC->TextOut(170,20*(i+1),str);
pDC->TextOut(90,20*(i+1),pStudent->m_sName);
sprintf(str,"%6.2f",pStudent->m_lAge);
pDC->TextOut(240,20*(i+1),str);
sprintf(str,"%6.2f",pStudent->m_lScore);
pDC->TextOut(340,20*(i+1),str);
i++;
}
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = 300;
sizeTotal.cy = i*20+40;//500;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CEx07bScrollView diagnostics
#ifdef _DEBUG
void CEx07bScrollView::AssertValid() const
{
CScrollView::AssertValid();
}
void CEx07bScrollView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx07bScrollView message handlers
void CEx07bScrollView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
Invalidate(true);
}
#ifdef _DEBUG
CEx07bDoc * CEx07bScrollView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx07bDoc)));
return (CEx07bDoc*)m_pDocument;
}
#endif
void CEx07bScrollView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
CScrollView::OnBeginPrinting(pDC, pInfo);
}
void CEx07bScrollView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
CScrollView::OnEndPrinting(pDC, pInfo);
}
void CEx07bScrollView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
CScrollView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_ANISOTROPIC);
//轉換坐標映射方式
CSize size = CSize(800, 580);
pDC->SetWindowExt(size);
//確定窗口大小
//得到實際設備每邏輯英寸的像素數量
int xLogPixPerInch=pDC->GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
//得到設備坐標和邏輯坐標的比例
long xExt = (long)size.cx * xLogPixPerInch/96 ;
long yExt = (long)size.cy * yLogPixPerInch/96 ;
pDC->SetViewportExt((int)xExt, (int)yExt);
//確定視口大小
}
BOOL CEx07bScrollView::OnPreparePrinting(CPrintInfo* pInfo)
{
// TODO: call DoPreparePrinting to invoke the Print dialog box
// return CScrollView::OnPreparePrinting(pInfo);
BOOL b=CView::DoPreparePrinting(pInfo);
return b;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -