///////////////////////////////////////////////////////////////////// // ChildView.cpp - Implements window where drawing will occur // // // // Jim Fawcett, Spring 2004 // ///////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MFCFrameWin.h" #include "ChildView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CChildView CChildView::CChildView() { } CChildView::~CChildView() { } BEGIN_MESSAGE_MAP(CChildView, CWnd) ON_WM_PAINT() END_MESSAGE_MAP() // CChildView message handlers BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) { if (!CWnd::PreCreateWindow(cs)) return FALSE; cs.dwExStyle |= WS_EX_CLIENTEDGE; cs.style &= ~WS_BORDER; cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), NULL); return TRUE; } // ///////////////////////////////////////////////////////////////////// // OnPaint is where all user defined drawing is implemented // void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); CPen pen; pen.CreatePen(PS_SOLID,4,RGB(100,0,0)); dc.SelectObject(&pen); long width = rect.right - rect.left; long lftPoint = 0.2*width + rect.left; long rgtPoint = rect.right - 0.2*width; long height = rect.bottom - rect.top; long topPoint = rect.top + 0.4*height; long btmPoint = rect.bottom - 0.4*height; dc.MoveTo(lftPoint,topPoint); dc.LineTo(rgtPoint,topPoint); dc.MoveTo(lftPoint,btmPoint); dc.LineTo(rgtPoint,btmPoint); CFont font; font.CreatePointFont(0.25*(height + width), _T("tahoma")); dc.SelectObject(&font); dc.SetTextColor(RGB(100,0,0)); CString str = "CSE775 - Distributed Objects"; UINT pos = DT_SINGLELINE | DT_CENTER | DT_VCENTER; dc.DrawText(str.GetString(),-1,&rect,pos); }