www.pudn.com > NoteBookVC++.rar > KEY.cpp
// KEY.cpp : implementation file
//
#include "stdafx.h"
#include "¼Çʱ¾.h"
#include "KEY.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// KEY dialog
KEY::KEY(CWnd* pParent /*=NULL*/)
: CDialog(KEY::IDD, pParent)
{
Sound.x=0;
Sound.y=0;
Temp.x=0;
Temp.y=0;
MaxSound.x=2500;
MaxSound.y=200;
SelectRadio1=TRUE;
//{{AFX_DATA_INIT(KEY)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void KEY::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(KEY)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(KEY, CDialog)
//{{AFX_MSG_MAP(KEY)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER, OnCustomdrawSlider)
ON_BN_CLICKED(IDPLAY, OnPlay)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// KEY message handlers
BOOL KEY::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
KEY::CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
KEY::MyEdit.SubclassDlgItem(IDC_EDIT,this);
char temp[6]="";
sprintf(temp,"%d",Temp.x);
MyEdit.SetWindowText(temp);
KEY::MySlider.SubclassDlgItem(IDC_SLIDER,this);
MySlider.SetRange(0,MaxSound.x);
MySlider.SetPos(Temp.x);
MySlider.SetLineSize(MaxSound.x/20);
PlayButton.SubclassDlgItem(IDPLAY,this);
PlayButton.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void KEY::OnRadio1()
{
// TODO: Add your control notification handler code here
SelectRadio1=TRUE;
MySlider.SetRange(0,MaxSound.x);
MySlider.SetLineSize(MaxSound.x/20);
MySlider.SetPos(Temp.x);
char temp[6]="";
sprintf(temp,"%d",Temp.x);
KEY::MyEdit.SetWindowText(temp);
}
void KEY::OnRadio2()
{
// TODO: Add your control notification handler code here
SelectRadio1=FALSE;
MySlider.SetRange(0,MaxSound.y);
MySlider.SetLineSize(MaxSound.y/20);
MySlider.SetPos(Temp.y);
char temp[6]="";
sprintf(temp,"%d",Temp.y);
KEY::MyEdit.SetWindowText(temp);
}
void KEY::OnOK()
{
// TODO: Add extra validation here
Sound.x=Temp.x;
Sound.y=Temp.y;
CDialog::OnOK();
}
void KEY::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
if(SelectRadio1==TRUE)
{
MySlider.SetRange(0,MaxSound.x);
MySlider.SetLineSize(MaxSound.x/20);
Temp.x=MySlider.GetPos();
char temp[6]="";
sprintf(temp,"%d",Temp.x);
KEY::MyEdit.SetWindowText(temp);
}
else
{
MySlider.SetRange(0,MaxSound.y);
MySlider.SetLineSize(MaxSound.y/20);
Temp.y=MySlider.GetPos();
char temp[6]="";
sprintf(temp,"%d",Temp.y);
KEY::MyEdit.SetWindowText(temp);
}
*pResult = 0;
}
void KEY::OnPlay()
{
// TODO: Add your control notification handler code here
Beep(KEY::Temp.x,KEY::Temp.y);
}