www.pudn.com > EMplayer.rar > multimediaView.cpp


// multimediaView.cpp : implementation of the CMultimediaView class 
// 
 
#include "stdafx.h" 
#include "multimedia.h" 
 
#include "multimediaDoc.h" 
#include "multimediaView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView 
 
IMPLEMENT_DYNCREATE(CMultimediaView, CView) 
 
BEGIN_MESSAGE_MAP(CMultimediaView, CView) 
	//{{AFX_MSG_MAP(CMultimediaView) 
		// 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_MESSAGE(MCIWNDM_NOTIFYSIZE,OnNotifySize) 
 
    //******代码编写结束 
	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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView construction/destruction 
 
CMultimediaView::CMultimediaView() 
{ 
	// TODO: add construction code here 
 
} 
 
CMultimediaView::~CMultimediaView() 
{ 
 
	//******代码编写开始 
 
	m_hMCIWnd=NULL; 
 
    //******代码编写结束 
} 
 
BOOL CMultimediaView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView drawing 
 
void CMultimediaView::OnDraw(CDC* pDC) 
{ 
	CMultimediaDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView printing 
 
BOOL CMultimediaView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CMultimediaView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CMultimediaView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView diagnostics 
 
#ifdef _DEBUG 
void CMultimediaView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CMultimediaView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CMultimediaDoc* CMultimediaView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMultimediaDoc))); 
	return (CMultimediaDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMultimediaView message handlers 
 
void CMultimediaView::OnInitialUpdate()  
{ 
	CView::OnInitialUpdate(); 
	 
	// TODO: Add your specialized code here and/or call the base class 
	 
	//******代码编写开始 
 
	m_hMCIWnd=MCIWndCreate(m_hWnd,AfxGetInstanceHandle(),MCIWNDF_NOTIFYSIZE| 
		MCIWNDF_NOERRORDLG|WS_CHILD|WS_VISIBLE,NULL); 
	if(m_hMCIWnd==NULL)return; 
	const CString& m_filename=GetDocument()->GetPathName(); 
	if(m_filename.GetLength()>0) 
		MCIWndOpen(m_hMCIWnd,(LPCSTR)m_filename,0); 
 
    //******代码编写结束 
} 
 
 
	//******代码编写开始 
 
LONG CMultimediaView::OnNotifySize(UINT wParam,LONG lParam) 
{ 
	CRect m_Rect; 
	CFrameWnd* m_pParent=GetParentFrame(); 
	if(m_hMCIWnd) 
	{ 
		::GetWindowRect(m_hMCIWnd,m_Rect); 
		m_pParent->CalcWindowRect(m_Rect,CWnd::adjustBorder); 
		CSize m_Size(m_Rect.Width(),m_Rect.Height()); 
	 
		if(GetExStyle()&&WS_EX_CLIENTEDGE) //if语句可去 
		{ 
			m_Size.cx+=10; 
			m_Size.cy+=20; 
		} 
 
		m_pParent->SetWindowPos(NULL,0,0,m_Size.cx,m_Size.cy,SWP_NOZORDER| 
			SWP_NOACTIVATE|SWP_NOMOVE); 
	} 
	else 
	{ 
		m_pParent->SetWindowPos(NULL,0,0,200,300,SWP_NOZORDER| 
			SWP_NOACTIVATE|SWP_NOMOVE); 
	} 
	return 1; 
} 
 
    //******代码编写结束