// staticView.cpp : implementation of the CStaticView class
//
#include "stdafx.h"
#include "static.h"
#include "staticDoc.h"
#include "staticView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaticView
IMPLEMENT_DYNCREATE(CStaticView, CView)
BEGIN_MESSAGE_MAP(CStaticView, CView)
//{{AFX_MSG_MAP(CStaticView)
ON_COMMAND(IDM_SHOW, OnShow)
ON_COMMAND(IDM_SEND, OnSend)
ON_WM_CREATE()
ON_COMMAND(IDM_DESTROY, OnDestroy)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaticView construction/destruction
CStaticView::CStaticView()
{
// TODO: add construction code here
}
CStaticView::~CStaticView()
{
}
BOOL CStaticView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CStaticView drawing
void CStaticView::OnDraw(CDC* pDC)
{
CStaticDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CStaticView diagnostics
#ifdef _DEBUG
void CStaticView::AssertValid() const
{
CView::AssertValid();
}
void CStaticView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CStaticDoc* CStaticView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStaticDoc)));
return (CStaticDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CStaticView message handlers
void CStaticView::OnShow()
{
// TODO: Add your command handler code here
RECT r;
r.left=10; r.top=10; r.right=300; r.bottom=25;
myStaticCtrl.Create("Hello, I'm a static control",WS_CHILD|WS_VISIBLE|SS_LEFT, r, this, 10);
}
void CStaticView::OnSend()
{
// TODO: Add your command handler code here
wsprintf(cBuf,"Message number %d", m_n);
myStaticCtrl.SendMessage(WM_SETTEXT,0,(LPARAM)cBuf);
m_n++;
}
int CStaticView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
lstrcpy(cBuf," ");
m_n=1;
return 0;
}
void CStaticView::OnDestroy()
{
// TODO: Add your command handler code here
myStaticCtrl.DestroyWindow();
}