(1)创建一个基于对话框的应用;
(2)在对话框上放置一个图片框设置 ID:IDC_STATIC_AUDIO
(3)在应用中添加以下代码:
BOOL CAudioBarDlg::OnInitDialog()
{
。。。。。。。。。。。。。。。。。。。。
// TODO: Add extra initialization here
CRect rect;
GetDlgItem(IDC_STATIC_AUDIO)->GetWindowRect(rect);
ScreenToClient(rect);
m_AudioShowCtrl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,rect,this,IDC_STATIC_AUDIO,NULL);
m_AudioShowCtrl.SetRange(0,100);
。。。。。。。。。。。。。。。。。。。。。。。。。。。
return TRUE; // return TRUE unless you set the focus to a control
void CAudioBarDlg::OnMyTest()
{
// TODO: Add your control notification handler code here
m_bStartStop=TRUE;
if (m_bStartStop)
SetTimer(1,500,NULL);
else
KillTimer(1);
}
void CAudioBarDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime t = CTime::GetCurrentTime();
int nRandom;
srand(t.GetSecond());
do
{
nRandom = rand();
} while (nRandom < 0 || nRandom > 100);
m_AudioShowCtrl.SetPos(nRandom);
CDialog::OnTimer(nIDEvent);
}
本文地址:http://com.8s8s.com/it/it3894.htm