生成用于选择筛选器的对话框
应用程序允许用户选择任意筛选操作并将其应用于波形音频数据。 在以下示例中,应用程序分配一个缓冲区来保存筛选器,然后使用 acmFilterChoose 函数选择筛选器。 此示例中的函数必须使用相应的筛选器或筛选器标记调用。
MMRESULT mmr;
ACMFILTERCHOOSE afc;
PWAVEFILTER pwfltr;
DWORD cbwfltr;
// Determine the maximum size required for any valid filter
// for which the ACM has a driver installed and enabled.
mmr = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FILTER, &cbwfltr);
if (MMSYSERR_NOERROR != mmr) {
// The ACM probably has no drivers installed and
// enabled for filter operations.
return (mmr);
}
// Dynamically allocate a structure large enough to hold the
// maximum sized filter enabled in the system.
pwfltr = (PWAVEFILTER)LocalAlloc(LPTR, (UINT)cbwfltr);
if (NULL == pwfltr) {
return (MMSYSERR_NOMEM);
}
// Initialize the ACMFILTERCHOOSE members.
memset(&afc, 0, sizeof(afc));
afc.cbStruct = sizeof(afc);
afc.fdwStyle = 0L; // no special style flags
afc.hwndOwner = hwnd; // hwnd of parent window
afc.pwfltr = pwfltr; // wfltr to receive selection
afc.cbwfltr = cbwfltr; // size of wfltr buffer
afc.pszTitle = TEXT("Any Filter Selection");
// Call the ACM to bring up the filter-selection dialog box.
mmr = acmFilterChoose(&afc);
if (MMSYSERR_NOERROR == mmr) {
// The user selected a valid filter. The pwfltr buffer,
// allocated above, contains the complete filter description.
}
// Clean up and exit.
LocalFree((HLOCAL)pwfltr);
return (mmr);