LPCTSTR());
}
}
}
我们就在OnPaint() 中调用了DrawWave函数绘制波形,DrawWave函数的代码如下:void CWavePlayerDlg::DrawWave(HDC hdc, unsigned int x, unsigned int y, char*path) {
HMMIO h;
MMCKINFO mmParent,mmSub;//MMCKINFO结构中包含了有关部分的信息
GLOBALHANDLE gh;
PCMWAVEFORMAT waveformat;//fmt部分结构
char *p;
unsigned long nextsample;
long afactor;
unsigned int i,n,amp;
int *ip;
HPEN OldPen=(HPEN)SelectObject(hdc,GetStockObject(BLACK_PEN));
HBRUSH OldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(WHITE_BRUSH));
Rectangle(hdc,x,y,x+INFO_WAVEWIDE,y+INFO_WAVEDEEP);
if((h=mmioOpen(path,NULL,MMIO_READ))==NULL)
return;
mmParent.fccType=mmioFOURCC('W','A','V','E');
if(mmioDescend(h,(LPMMCKINFO)&mmParent,NULL,MMIO_FINDRIFF))
{
mmioClose(h,0);
return;
}
mmSub.ckid=mmioFOURCC('f','m','t',' ');
if(mmioDescend(h,(LPMMCKINFO)&mmSub,(LPMMCKINFO)&mmParent,MMIO_FINDCHUNK)) {
mmioClose(h,0);
return;
}
n=min((unsigned int)mmSub.cksize,sizeof(PCMWAVEFORMAT));
if(mmioRead(h,(LPSTR)&waveformat,n)!=( int)n)
{
mmioClose(h,0);
return;
}