www.pudn.com > 毕业留念册.rar > BYDView.cpp


// BYDView.cpp : implementation of the CBYDView class 
// 
 
#include "stdafx.h" 
#include "BYD.h" 
#include "ButtonST.h" 
#include "BYDDoc.h" 
#include "BYDView.h" 
#include "SclassDlg.h" 
#include "TeacherDlg.h" 
#include "ClassmateDlg.h" 
#include "PhotoDlg.h" 
#include "MusicDlg.h" 
#include "PreviewDlg.h" 
//#include "NonRect.h" 
//#include "MainFrm.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CBYDView 
 
IMPLEMENT_DYNCREATE(CBYDView, CFormView) 
 
BEGIN_MESSAGE_MAP(CBYDView, CFormView) 
	//{{AFX_MSG_MAP(CBYDView) 
	ON_BN_CLICKED(IDC_SCLASSBTN, OnSclassBtn) 
	ON_BN_CLICKED(IDC_TEACHEREDITBTN, OnTeacherEditBtn) 
	ON_BN_CLICKED(IDC_CLASSMATEEDITBTN, OnClassmateEditBtn) 
	ON_BN_CLICKED(IDC_PREVIEWBTN, OnPreviewBtn) 
	ON_WM_LBUTTONDOWN() 
	ON_BN_CLICKED(IDC_CLOSE, OnClose) 
	ON_WM_SIZE() 
	ON_BN_CLICKED(IDC_MIN, OnMin) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CBYDView construction/destruction 
 
CBYDView::CBYDView() 
	: CFormView(CBYDView::IDD) 
{ 
	//{{AFX_DATA_INIT(CBYDView) 
	//}}AFX_DATA_INIT 
	// TODO: add construction code here 
    CBitmap bmp; 
	bmp.LoadBitmap(IDB_MAIN); ///加载位图 
    m_bkBrush.CreatePatternBrush(&bmp);	///创建位图画刷 
} 
 
CBYDView::~CBYDView() 
{ 
} 
 
void CBYDView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CBYDView) 
	//}}AFX_DATA_MAP 
} 
 
BOOL CBYDView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CFormView::PreCreateWindow(cs); 
} 
 
void CBYDView::OnInitialUpdate() 
{ 
//	CWnd *pWnd; 
//	pWnd=GetDlgItem(IDC_MUSICEDITBTN); 
//	pWnd->EnableWindow(FALSE); 
//	pWnd=GetDlgItem(IDC_PHOTOEDITBTN); 
//	pWnd->EnableWindow(FALSE); 
	DEVMODE lpDevMode; 
	long m_p,m_x,m_y; 
	BOOL bResult=EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&lpDevMode); 
	if(bResult) 
	{ 
	 
		m_p=lpDevMode.dmBitsPerPel; 
		m_x=lpDevMode.dmPelsWidth; 
		m_y=lpDevMode.dmPelsHeight; 
	} 
	if(m_x!=1024) 
	{ 
		DEVMODE lpDevMode; 
		lpDevMode.dmBitsPerPel=32; 
		lpDevMode.dmPelsWidth=1024; 
		lpDevMode.dmPelsHeight=768; 
		lpDevMode.dmSize=sizeof(lpDevMode); 
		lpDevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL; 
		ChangeDisplaySettings(&lpDevMode,0); 
	} 
 
		//UpdateData(FALSE); 
	 
	 
	SetWindowPos(NULL,50,50,600,450,SWP_NOZORDER); 
	m_Classbnt.SubclassDlgItem(IDC_SCLASSBTN,this); 
	m_Classbnt.DrawTransparent(TRUE); 
	m_Teacherbnt.SubclassDlgItem(IDC_TEACHEREDITBTN,this); 
	m_Teacherbnt.DrawTransparent(TRUE); 
	m_Studentbnt.SubclassDlgItem(IDC_CLASSMATEEDITBTN,this); 
	m_Studentbnt.DrawTransparent(TRUE); 
	m_Ptrviewbnt.SubclassDlgItem(IDC_PREVIEWBTN,this); 
	 
	m_Ptrviewbnt.DrawTransparent(TRUE); 
	m_Closebnt.SubclassDlgItem(IDC_CLOSE,this); 
	m_Closebnt.DrawTransparent(TRUE); 
	m_Savebnt.SubclassDlgItem(ID_FILE_SAVE,this); 
	m_Savebnt.DrawTransparent(TRUE); 
	m_Openbnt.SubclassDlgItem(ID_FILE_OPEN,this); 
	m_Openbnt.DrawTransparent(TRUE); 
	m_Min.SubclassDlgItem(IDC_MIN,this); 
	m_Min.DrawTransparent(TRUE); 
	 
	//CButtonST    m_btn; 
	//m_btn.SubclassDlgItem(IDC_B,this); 
  	//m_btn.DrawTransparent(TRUE); 
	CFormView::OnInitialUpdate(); 
	GetParentFrame()->RecalcLayout(); 
	ResizeParentToFit(); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CBYDView printing 
 
BOOL CBYDView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CBYDView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CBYDView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
void CBYDView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add customized printing code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CBYDView diagnostics 
 
#ifdef _DEBUG 
void CBYDView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CBYDView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
 
CBYDDoc* CBYDView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBYDDoc))); 
	return (CBYDDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CBYDView message handlers 
 
void CBYDView::OnSclassBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CSclassDlg m_SclassDlg; 
	CBYDDoc*pDoc=GetDocument(); 
	if(!pDoc->m_Classe.m_ClassIfo.IsEmpty()) 
	{ 
		m_SclassDlg.m_Introdaction=pDoc->m_Classe.m_ClassIfo; 
		 
	} 
	if(pDoc->m_Classe.m_MusicIfo.GetSize()!=0) 
	{ 
		for(int i=0;im_Classe.m_MusicIfo.GetSize();i++) 
		{ 
			m_SclassDlg.m_BgMusics.Add(pDoc->m_Classe.m_MusicIfo[i]); 
			m_SclassDlg.m_MusicName.Add(pDoc->m_Classe.m_MusicName[i]); 
 
		} 
		 
	} 
	if(pDoc->m_Classe.m_SchoolPhoto.GetSize()!=0) 
	{ 
		for(int i=0;im_Classe.m_SchoolPhoto.GetSize();i++) 
			m_SclassDlg.m_Picture.Add(pDoc->m_Classe.m_SchoolPhoto[i]); 
	} 
	if(m_SclassDlg.DoModal()==IDOK) 
	{ 
		pDoc->m_Classe.m_ClassIfo=m_SclassDlg.m_Introdaction; 
		if(pDoc->m_Classe.m_SchoolPhoto.GetSize()!=0) 
		{ 
			pDoc->m_Classe.m_SchoolPhoto.RemoveAll(); 
		} 
		for(int i=0;im_Classe.m_SchoolPhoto.Add(m_SclassDlg.m_Picture[i]); 
		} 
		if(pDoc->m_Classe.m_MusicIfo.GetSize()!=0) 
		{ 
			pDoc->m_Classe.m_MusicIfo.RemoveAll(); 
			pDoc->m_Classe.m_MusicName.RemoveAll(); 
		} 
		 
		for(i=0;im_Classe.m_MusicIfo.Add(m_SclassDlg.m_BgMusics[i]); 
			pDoc->m_Classe.m_MusicName.Add(m_SclassDlg.m_MusicName[i]); 
 
		} 
 
	} 
} 
 
void CBYDView::OnTeacherEditBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CTeacherDlg m_TeacherDlg;	 
	CBYDDoc*pDoc=GetDocument(); 
	CTeacher *te=new CTeacher(); 
	CObject *obj; 
	POSITION pos; 
	pos=pDoc->m_Classe.m_Teaches.GetHeadPosition(); 
	if(pos!=NULL) 
	{ 
		obj=pDoc->m_Classe.m_Teaches.GetAt(pos); 
		te=(CTeacher*)obj; 
		m_TeacherDlg.m_Name=te->m_Name; 
		m_TeacherDlg.m_Liuyan=te->m_Liuyan; 
		m_TeacherDlg.m_Birthday=te->m_Birthday; 
		m_TeacherDlg.m_Email=te->m_Email; 
		m_TeacherDlg.m_MoveTel=te->m_MoveTel; 
		m_TeacherDlg.m_Position=te->m_Position; 
		m_TeacherDlg.m_Subject=te->m_Subject; 
		m_TeacherDlg.m_Tel=te->m_Tel; 
	} 
 
	CObList * pOblist=&(pDoc->m_Classe.m_Teaches); 
	m_TeacherDlg.pObList=pOblist; 
	m_TeacherDlg.DoModal(); 
 
} 
 
void CBYDView::OnClassmateEditBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CClassmateDlg m_ClassmateDlg; 
	CBYDDoc*pDoc=GetDocument(); 
	CStudent *stu=new CStudent(); 
	CObject *obj; 
	POSITION pos; 
	pos=pDoc->m_Classe.m_Students.GetHeadPosition(); 
	if(pos!=NULL) 
	{ 
		obj=pDoc->m_Classe.m_Students.GetAt(pos); 
		stu=(CStudent*)obj; 
		m_ClassmateDlg.m_Birthday=stu->m_Birthday; 
		m_ClassmateDlg.m_Email=stu->m_Email; 
		m_ClassmateDlg.m_Liuyan=stu->m_Liuyan; 
//		m_ClassmateDlg.m_LoveBook=stu->m_LoveBook; 
		m_ClassmateDlg.m_LoveWords=stu->m_LoveWords; 
		m_ClassmateDlg.m_Name=stu->m_Name; 
		m_ClassmateDlg.m_QQ=stu->m_QQ; 
		m_ClassmateDlg.m_Sex=stu->m_Sex; 
		m_ClassmateDlg.m_MoveTel=stu->m_MoveTel; 
		m_ClassmateDlg.m_Tel=stu->m_Tel; 
	} 
	CObList*pObList=&(pDoc->m_Classe.m_Students); 
	m_ClassmateDlg.pObList=pObList; 
	m_ClassmateDlg.DoModal(); 
 
 
} 
 
/*void CBYDView::OnPhotoEditBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CPhotoDlg m_PhotoDlg; 
	m_PhotoDlg.DoModal(); 
} 
 
void CBYDView::OnMusicEditBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CMusicDlg m_MusicDlg; 
	m_MusicDlg.DoModal(); 
} 
*/ 
void CBYDView::OnPreviewBtn()  
{ 
	// TODO: Add your control notification handler code here 
	CPreviewDlg m_PreviewDlg; 
	CBYDDoc*pDoc=GetDocument(); 
	m_PreviewDlg.m_Classe=&(pDoc->m_Classe); 
	if(m_PreviewDlg.m_Classe!=NULL) 
	{ 
		if(m_PreviewDlg.DoModal()==IDOK) 
		{ 
		} 
	} 
	else 
		MessageBox("请输先编辑班级信息^_^……","提示",MB_ICONINFORMATION); 
} 
 
/*void CBYDView::OnExitEditBtn()  
{ 
	 
	// TODO: Add your control notification handler code here 
	 
}*/ 
 
void CBYDView::OnDraw(CDC* pDC)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	CRect rect; 
	GetClientRect(rect);///取得客户区域 
    pDC->FillRect(rect,&m_bkBrush); ///用背景画刷填充区域 
} 
 
void CBYDView::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
  //PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM (point.x, point.y));	 
	CFormView::OnLButtonDown(nFlags, point); 
} 
 
void CBYDView::OnClose()  
{ 
	 
	PostQuitMessage(0); 
 
} 
 
 
 
void CBYDView::OnMin()  
{ 
	// TODO: Add your control notification handler code here 
	AfxGetMainWnd()->ShowWindow(SW_MINIMIZE); 
}