www.pudn.com > geomm1.zip > SampleCEView.cpp


// SampleCEView.cpp : implementation of the CSampleCEView class 
// 
 
#include "stdafx.h" 
#include "SampleCE.h" 
 
#include "SampleCEDoc.h" 
#include "SampleCEView.h" 
#include "GeometryManager.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleCEView 
 
IMPLEMENT_DYNCREATE(CSampleCEView, CFormView) 
 
BEGIN_MESSAGE_MAP(CSampleCEView, CFormView) 
	//{{AFX_MSG_MAP(CSampleCEView) 
		// 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 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleCEView construction/destruction 
 
CSampleCEView::CSampleCEView() 
	: CFormView(CSampleCEView::IDD) 
{ 
	//{{AFX_DATA_INIT(CSampleCEView) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// TODO: add construction code here 
 
} 
 
CSampleCEView::~CSampleCEView() 
{ 
} 
 
void CSampleCEView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSampleCEView) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
BOOL CSampleCEView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CFormView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleCEView diagnostics 
 
#ifdef _DEBUG 
void CSampleCEView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CSampleCEView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
 
CSampleCEDoc* CSampleCEView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSampleCEDoc))); 
	return (CSampleCEDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CSampleCEView message handlers 
 
void CSampleCEView::OnInitialUpdate()  
{ 
	CFormView::OnInitialUpdate(); 
	 
	// we don't want any scroll bars 
	SetScrollSizes(MM_TEXT, CSize(0, 0)); 
 
	// initialize the geometry management 
	// 
	HGEOM hGeom = GmStartDefinition(0); 
	ASSERT(hGeom); 
	if (!hGeom) 
		return; 
	 
	// add the top-level frame window group 
	// 
	// arrange its direct children horizontally 
	// 
	// Notice that since this window are a CFormView, you need to 
	// pass in the window handle of the parent frame window. 
	// 
	HGMGROUP hTopFrameWnd = GmAddTopFrameWnd(hGeom, GetParentFrame()->m_hWnd, GM_HORIZONTAL); 
	if (hTopFrameWnd) 
	{ 
		// add the generic group for the static text and edit field 
		// 
		// arrange its direct children horizontally 
		// give it a weight of 1 
		// 
		HGMGROUP hGroup1 = GmAddGroup(hGeom, hTopFrameWnd, GM_HORIZONTAL, 1); 
		if (hGroup1) 
		{ 
			// add the static text group 
			// 
			// left-align and vertically center it 
			// give it a weight of 0 
			// 
			GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_NAME_LABEL), GM_LEFT | GM_VCENTER, 0); 
			 
			// add the edit field group 
			// 
			// vertically center it 
			// allow it to grow horizontally 
			// give it a weight of 1 
			// 
			GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_NAME), GM_VCENTER | GM_GROW_X, 1); 
		} 
 
		// add the generic group for the static text and multiline edit field 
		// 
		// arrange its direct children vertically 
		// give it a weight of 1 
		// 
		hGroup1 = GmAddGroup(hGeom, hTopFrameWnd, GM_VERTICAL, 1); 
		if (hGroup1) 
		{ 
			// add the static text group 
			// 
			// left-align and vertically center it 
			// give it a weight of 0 
			// 
			GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_ADDRESS_LABEL), GM_LEFT | GM_VCENTER, 0); 
			 
			// add the multiline edit field group 
			// 
			// allow it to grow in both directions 
			// give it a weight of 1 
			// 
			GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_ADDRESS), GM_GROW, 1); 
		} 
	} 
 
	// end the definition and start the manager 
	// 
	VERIFY(GmEndDefinition(hGeom)); 
}