// extractorView.cpp : implementation of the CExtractorView class
//

#include "stdafx.h"
#include "extractor.h"

#include "extractorDoc.h"
#include "extractorView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExtractorView

IMPLEMENT_DYNCREATE(CExtractorView, CView)

BEGIN_MESSAGE_MAP(CExtractorView, CView)
	//{{AFX_MSG_MAP(CExtractorView)
		// 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 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()

/////////////////////////////////////////////////////////////////////////////
// CExtractorView construction/destruction

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

}

CExtractorView::~CExtractorView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExtractorView drawing

void CExtractorView::OnDraw(CDC* pDC)
{
	CExtractorDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

	CWnd* pFrame = AfxGetMainWnd();
	CMyAvi* pAvi = pDoc->Getm_avi();

	if(pAvi->GetWidth()!=0)
	{
		CString avi_info;
		AVIFILEINFO *pAviFileInfo;
		BITMAPINFOHEADER *pBMPInfo;
		pAviFileInfo = pAvi->GetAviFileInfo();
		pBMPInfo = pAvi->GetBMPInfo();

		avi_info.Format("avi file's information:");
		pDC->TextOut(20,20,avi_info);
		
		avi_info.Format("width=%d,   height=%d",pAvi->GetWidth(),pAvi->GetHeight());
		pDC->TextOut(20,40,avi_info);
		
		avi_info.Format("Scale=%d (ms)  Rate=%d (ms)",pAviFileInfo->dwScale/1000,pAviFileInfo->dwRate/1000);
		pDC->TextOut(20,60,avi_info);
		
		avi_info.Format("number of the frames=%d",pAviFileInfo->dwLength);
		pDC->TextOut(20,80,avi_info);

		avi_info.Format("the color bit of the frames=%d",pBMPInfo->biBitCount);
		pDC->TextOut(20,100,avi_info);

		avi_info.Format("USE the \"control\" menu to do some setting.");
		pDC->TextOut(20,130,avi_info);

		avi_info.Format("Press the START button to begin extract.      (cost time: about %d minutes)",pAviFileInfo->dwLength/300+1);
		pDC->TextOut(20,150,avi_info);

		avi_info.Format("the extracted files will be put into the same directory of the original avi file.");
		pDC->TextOut(20,170,avi_info);
	}
	else
		pFrame->SetWindowText("easy extractor");
}

/////////////////////////////////////////////////////////////////////////////
// CExtractorView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExtractorView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExtractorView message handlers
