cpp : implementation file
//
#include "stdafx.h"
#include "mdlsprop.h"
#include "MouseSheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMouseSheet
IMPLEMENT_DYNAMIC(CMouseSheet, CPropertySheet)
CMouseSheet::CMouseSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CMouseSheet::CMouseSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
leftct=rightct=midct=0;
AddPage(&m_clickpage);
AddPage(&m_pospage);
}
CMouseSheet::~CMouseSheet()
{
}
BEGIN_MESSAGE_MAP(CMouseSheet, CPropertySheet)
//{{AFX_MSG_MAP(CMouseSheet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMouseSheet message handlers
BOOL CMouseSheet::OnInitDialog()
{
return CPropertySheet::OnInitDialog();
}
void CMouseSheet::SetXY(int x, int y)
{
m_pospage.m_x=x;
m_pospage.m_y=y;
if (::IsWindow(m_pospage.m_hWnd)) m_pospage.UpdateData(FALSE);
}
void CMouseSheet::MouseDown(int cmd)
{
switch (cmd)
{
case WM_LBUTTONDOWN:
leftct++;
break;
case WM_RBUTTONDOWN:
rightct++;
break;
case WM_MBUTTONDOWN:
midct++;
break;
}
m_clickpage.m_left=leftct;
m_clickpage.m_right=rightct;
m_clickpage.m_middle=midct;
if (::IsWindow(m_clickpage.m_hWnd)) m_clickpage.UpdateData(FALSE);
}
Listing 6.6. Strona pozycji myszy.
// PosPage.cpp : implementation file
//
#include "stdafx.h"
#include "mdlsprop.h"
#include "PosPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPosPage property page
IMPLEMENT_DYNCREATE(CPosPage, CPropertyPage)
CPosPage::CPosPage() : CPropertyPage(CPosPage::IDD)
{
//{{AFX_DATA_INIT(CPosPage)
m_x = 0;
m_y = 0;
//}}AFX_DATA_INIT
}
CPosPage::~CPosPage()
{
}
void CPosPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPosPage)
DDX_Text(pDX, IDC_X, m_x);
DDX_Text(pDX, IDC_Y, m_y);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPosPage, CPropertyPage)
//{{AFX_MSG_MAP(CPosPage)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosPage message handlers
Listing 6.7. Strona kliknięć.
// ClickPage.cpp : implementation file
//
#include "stdafx.h"
#include "mdlsprop.h"
#include "ClickPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClickPage property page
IMPLEMENT_DYNCREATE(CClickPage, CPropertyPage)
CClickPage::CClickPage() : CPropertyPage(CClickPage::IDD)
{
//{{AFX_DATA_INIT(CClickPage)
m_left = 0;
m_middle = 0;
m_right = 0;
//}}AFX_DATA_INIT
}
CClickPage::~CClickPage()
{
}
void CClickPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClickPage)
DDX_Text(pDX, IDC_LEFT, m_left);
DDX_Text(pDX, IDC_MIDDLE, m_middle);
DDX_Text(pDX, IDC_RIGHT, m_right);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClickPage, CPropertyPage)
//{{AFX_MSG_MAP(CClickPage)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClickPage message handlers
Listing 6.8. Wykorzystanie niemodalnego arkusza właściwości.
// mdlspropView.cpp : implementation of the CMdlspropView class
//
#include "stdafx.h"
#include "mdlsprop.h"
#include "mdlspropDoc.h"
#include "mdlspropView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMdlspropView
IMPLEMENT_DYNCREATE(CMdlspropView, CView)
BEGIN_MESSAGE_MAP(CMdlspropView, CView)
//{{AFX_MSG_MAP(CMdlspropView)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_RBUTTONDOWN()
ON_WM_MBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMdlspropView construction/destruction
CMdlspropView::CMdlspropView() : psheet("Właściwości myszy")
{
// TODO: add construction code here
}
CMdlspropView::~CMdlspropView()
{
}
BOOL CMdlspropView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMdlspropView drawing
void CMdlspropView::OnDraw(CDC* pDC)
{
CMdlspropDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMdlspropView diagnostics
#ifdef _DEBUG
void CMdlspropView::AssertValid() const
{
CView::AssertValid();
}
void CMdlspropView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMdlspropDoc* CMdlspropView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMdlspropDoc)));
return (CMdlspropDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMdlspropView message handlers
void CMdlspropView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (::IsWindow(psheet.m_hWnd)) psheet.MouseDown(WM_LBUTTONDOWN);
CView::OnLButtonDown(nFlags, point);
}
void CMdlspropView::OnMouseMove(UINT nFlags, CPoint point)
{
if (::IsWindow(psheet.m_hWnd)) psheet.SetXY(point.x,point.y);
CView::OnMouseMove(nFlags, point);
}
void CMdlspropView::OnRButtonDown(UINT nFlags, CPoint point)
{
if (::IsWindow(psheet.m_hWnd)) psheet.MouseDown(WM_RBUTTONDOWN);
CView::OnRButtonDown(nFlags, point);
}
void CMdlspropView::OnMButtonDown(UINT nFlags, CPoint point)
{
if (::IsWindow(psheet.m_hWnd)) psheet.MouseDown(WM_MBUTTONDOWN);
CView::OnMButtonDown(nFlags, point);
}
void CMdlspropView::OnInitialUpdate()
{
CView::OnInitialUpdate();