|
// HiResScrollWheelDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HiResScrollWheel.h"
#include "HiResScrollWheelDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CHiResScrollWheelDlg dialog
CHiResScrollWheelDlg::CHiResScrollWheelDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHiResScrollWheelDlg::IDD, pParent)
, m_nWheelDelta(15)
, m_nTimeDelta(8)
, m_nEventsPerClick(8)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CHiResScrollWheelDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_nWheelDelta);
DDV_MinMaxUInt(pDX, m_nWheelDelta, 1, 240);
DDX_Text(pDX, IDC_EDIT2, m_nTimeDelta);
DDV_MinMaxUInt(pDX, m_nTimeDelta, 2, 1000);
DDX_Text(pDX, IDC_EDIT3, m_nEventsPerClick);
DDV_MinMaxUInt(pDX, m_nEventsPerClick, 1, 240);
}
BEGIN_MESSAGE_MAP(CHiResScrollWheelDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT1, &CHiResScrollWheelDlg::OnEnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, &CHiResScrollWheelDlg::OnEnChangeEdit2)
ON_EN_CHANGE(IDC_EDIT3, &CHiResScrollWheelDlg::OnEnChangeEdit3)
ON_BN_CLICKED(IDC_APPLY, &CHiResScrollWheelDlg::OnBnClickedApply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CHiResScrollWheelDlg message handlers
__declspec( dllimport ) void SetParameters(int x1, int x2, int x3);
BOOL CHiResScrollWheelDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
SetParameters((int)m_nWheelDelta,(int)m_nTimeDelta,(int)m_nEventsPerClick) ;
GetDlgItem(IDC_APPLY)->EnableWindow(0) ;
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CHiResScrollWheelDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CHiResScrollWheelDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CHiResScrollWheelDlg::OnEnChangeEdit1()
{
GetDlgItem(IDC_APPLY)->EnableWindow(1) ;
}
void CHiResScrollWheelDlg::OnEnChangeEdit2()
{
GetDlgItem(IDC_APPLY)->EnableWindow(1) ;
}
void CHiResScrollWheelDlg::OnEnChangeEdit3()
{
GetDlgItem(IDC_APPLY)->EnableWindow(1) ;
}
void CHiResScrollWheelDlg::OnBnClickedApply()
{
if (UpdateData()) {
// data validated
SetParameters((int)m_nWheelDelta,(int)m_nTimeDelta,(int)m_nEventsPerClick) ;
GetDlgItem(IDC_APPLY)->EnableWindow(0) ;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Stephen lives in Fremont, CA with his wife and daughter and has programmed in C and C++ for a very long time.