// buttonView.cpp : implementation of the CButtonView class
//
#include "stdafx.h"
#include "button.h"
#include "button1.h"
#include "buttonDoc.h"
#include "buttonView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CButtonView
IMPLEMENT_DYNCREATE(CButtonView, CView)
BEGIN_MESSAGE_MAP(CButtonView, CView)
//{{AFX_MSG_MAP(CButtonView)
ON_BN_CLICKED(RADIO1, OnRadio1)
ON_BN_CLICKED(RADIO2, OnRadio2)
ON_BN_CLICKED(STATUS_BUTTON, OnStatus)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CButtonView construction/destruction
CButtonView::CButtonView()
{
// TODO: add construction code here
}
CButtonView::~CButtonView()
{
}
BOOL CButtonView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CButtonView drawing
void CButtonView::OnDraw(CDC* pDC)
{
CButtonDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CButtonView diagnostics
#ifdef _DEBUG
void CButtonView::AssertValid() const
{
CView::AssertValid();
}
void CButtonView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CButtonDoc* CButtonView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CButtonDoc)));
return (CButtonDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CButtonView message handlers
int CButtonView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
RECT r1;
r1.top=10; r1.left=10; r1.bottom=30; r1.right=80;
m_radio1.Create("Radio 1",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,r1,this,RADIO1);
r1.top=50; r1.bottom=70;
m_radio2.Create("Radio 2",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,r1,this,RADIO2);
r1.top=10; r1.left=100; r1.bottom=30; r1.right=180;
m_show.Create("Show Status",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,r1,this,STATUS_BUTTON);
return 0;
}
void CButtonView::OnRadio1()
{
m_radio1.SendMessage(BM_SETCHECK,1,0);
m_radio2.SendMessage(BM_SETCHECK,0,0);
}
void CButtonView::OnRadio2()
{
m_radio1.SendMessage(BM_SETCHECK,0,0);
m_radio2.SendMessage(BM_SETCHECK,1,0);
}
void CButtonView::OnStatus()
{
m_bIsChecked = m_radio1.SendMessage(BM_GETCHECK,0,0);
wsprintf(cBuf, "Top Radio Button = %d", m_bIsChecked);
MessageBox(cBuf, "Button Status", MB_OK);
}