📄 dialogs.c
字号:
ShowLevelProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_INITDIALOG:
if (!OpenStream(hDlg, (PCMWAVEFORMAT FAR *) lParam)) {
MessageBoxID(IDS_ERR_ACCESS_SOUNDDRIVER, MB_OK|MB_ICONSTOP);
EndDialog(hDlg, FALSE);
}
return(TRUE);
case WM_COMMAND:
switch(GET_WM_COMMAND_ID(wParam, lParam)) {
case IDOK:
case IDCANCEL:
CloseStream(hDlg);
EndDialog(hDlg, TRUE);
return(TRUE);
}
break;
case MM_WIM_DATA:
if (!StreamData(hDlg, (HWAVEIN)wParam, (LPWAVEHDR)lParam)) {
MessageBoxID(IDS_ERR_ACCESS_SOUNDDRIVER, MB_OK|MB_ICONSTOP);
CloseStream(hDlg);
EndDialog(hDlg, FALSE);
}
return(TRUE);
}
return FALSE;
}
//
// AudioFormatProc: Audio Format Setting Dialog Box Procedure
//
int FAR PASCAL AudioFormatProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
{
static int nChannels ;
static WORD wSample ;
static DWORD dwFrequency ;
switch (Message) {
case WM_INITDIALOG :
nChannels = IDD_ChannelIDs + glpwfex->nChannels ;
CheckRadioButton(hDlg, IDD_ChannelMono, IDD_ChannelStereo, nChannels) ;
wSample = IDD_SampleIDs + glpwfex->wBitsPerSample / 8 ;
CheckRadioButton(hDlg, IDD_Sample8Bit, IDD_Sample16Bit, wSample) ;
dwFrequency = IDD_FreqIDs + glpwfex->nSamplesPerSec / 11025 ;
CheckRadioButton(hDlg, IDD_Freq11kHz, IDD_Freq44kHz, (WORD)dwFrequency) ;
return TRUE ;
case WM_COMMAND :
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDD_SetLevel:
{
// get the current data into a PCMWAVEFORMAT struct,
// and run the ShowLevel dialog
PCMWAVEFORMAT wf;
UINT dlgid;
if (IsDlgButtonChecked(hDlg, IDD_ChannelMono)) {
wf.wf.nChannels = 1;
dlgid = IDD_RECLVLMONO;
} else {
wf.wf.nChannels = 2;
dlgid = IDD_RECLVLSTEREO;
}
if (IsDlgButtonChecked(hDlg, IDD_Sample8Bit)) {
wf.wBitsPerSample = 8;
} else {
wf.wBitsPerSample = 16;
}
if (IsDlgButtonChecked(hDlg, IDD_Freq11kHz)) {
wf.wf.nSamplesPerSec = 11025 ;
} else if (IsDlgButtonChecked(hDlg, IDD_Freq22kHz)) {
wf.wf.nSamplesPerSec = 22050 ;
} else {
wf.wf.nSamplesPerSec = 44100 ;
}
DoDialog(
hDlg,
dlgid,
ShowLevelProc,
(LPARAM) &wf);
break;
}
case IDOK :
if (IsDlgButtonChecked(hDlg, IDD_ChannelMono))
nChannels = 1 ;
else
if (IsDlgButtonChecked(hDlg, IDD_ChannelStereo))
nChannels = 2 ;
else {
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
if (IsDlgButtonChecked(hDlg, IDD_Sample8Bit))
wSample = 8 ;
else
if (IsDlgButtonChecked(hDlg, IDD_Sample16Bit))
wSample = 16 ;
else {
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
if (IsDlgButtonChecked(hDlg, IDD_Freq11kHz))
dwFrequency = 11025 ;
else
if (IsDlgButtonChecked(hDlg, IDD_Freq22kHz))
dwFrequency = 22050 ;
else
if (IsDlgButtonChecked(hDlg, IDD_Freq44kHz))
dwFrequency = 44100 ;
else {
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
// All the entries verfied OK -- save them now
glpwfex->nChannels = nChannels ;
glpwfex->wBitsPerSample = wSample ;
glpwfex->nSamplesPerSec = dwFrequency ;
glpwfex->nBlockAlign = glpwfex->nChannels * (glpwfex->wBitsPerSample / 8) ;
glpwfex->nAvgBytesPerSec = (long) glpwfex->nSamplesPerSec *
glpwfex->nBlockAlign ;
glpwfex->cbSize = 0 ;
glpwfex->wFormatTag = WAVE_FORMAT_PCM ;
EndDialog(hDlg, TRUE) ;
return TRUE ;
case IDCANCEL :
EndDialog(hDlg, FALSE) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
#endif // ! USE_ACM
//
// AllocCapFileProc: Capture file Space Allocation Dialog Box Procedure
//
int FAR PASCAL AllocCapFileProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
{
static int nFreeMBs = 0 ;
switch (Message) {
case WM_INITDIALOG :
{
int fh ;
long lFileSize = 0 ;
long lFreeSpaceInKB ;
TCHAR achCapFile[_MAX_PATH] ;
// Get current capture file name and measure its size
capFileGetCaptureFile(ghWndCap, achCapFile, sizeof(achCapFile) / sizeof(TCHAR)) ;
if ((fh = _open(achCapFile, _O_RDONLY)) != -1) {
if ((lFileSize = _lseek(fh, 0L, SEEK_END)) == -1L) {
MessageBoxID(IDS_ERR_SIZECAPFILE,
MB_OK | MB_ICONEXCLAMATION) ;
lFileSize = 0 ;
}
_close(fh) ;
}
// Get free disk space and add current capture file size to that.
// Convert the available space to MBs.
if ((lFreeSpaceInKB = GetFreeDiskSpaceInKB(achCapFile)) != -1L) {
lFreeSpaceInKB += lFileSize / 1024 ;
nFreeMBs = lFreeSpaceInKB / 1024 ;
SetDlgItemInt(hDlg, IDD_SetCapFileFree, nFreeMBs, TRUE) ;
} else {
EnableWindow(GetDlgItem(hDlg, IDD_SetCapFileFree), FALSE);
}
gwCapFileSize = (WORD) (lFileSize / ONEMEG);
SetDlgItemInt(hDlg, IDD_SetCapFileSize, gwCapFileSize, TRUE) ;
return TRUE ;
}
case WM_COMMAND :
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDOK :
{
int iCapFileSize ;
iCapFileSize = (int) GetDlgItemInt(hDlg, IDD_SetCapFileSize, NULL, TRUE) ;
if (iCapFileSize <= 0 || iCapFileSize > nFreeMBs) {
// You are asking for more than we have !! Sorry, ...
SetDlgItemInt(hDlg, IDD_SetCapFileSize, iCapFileSize, TRUE) ;
SetFocus(GetDlgItem(hDlg, IDD_SetCapFileSize)) ;
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
gwCapFileSize = iCapFileSize ;
EndDialog(hDlg, TRUE) ;
return TRUE ;
}
case IDCANCEL :
EndDialog(hDlg, FALSE) ;
return TRUE ;
case IDD_SetCapFileSize:
{
long l;
BOOL bchanged;
char achBuffer[21];
// check that entered size is a valid number
GetDlgItemText(hDlg, IDD_SetCapFileSize, achBuffer, sizeof(achBuffer));
l = atol(achBuffer);
bchanged = FALSE;
if (l < 1) {
l = 1;
bchanged = TRUE;
} else if (l > nFreeMBs) {
l = nFreeMBs;
bchanged = TRUE;
} else {
// make sure there are no non-digit chars
// atol() will ignore trailing non-digit characters
int c = 0;
while (achBuffer[c]) {
if (IsCharAlpha(achBuffer[c]) ||
!IsCharAlphaNumeric(achBuffer[c])) {
// string contains non-digit chars - reset
l = 1;
bchanged = TRUE;
break;
}
c++;
}
}
if (bchanged) {
wsprintf(achBuffer, "%ld", l);
SetDlgItemText(hDlg, IDD_SetCapFileSize, achBuffer);
}
break;
}
}
break ;
}
return FALSE ;
}
#if 0
//
// MakePaletteProc: Palette Details Dialog Box Procedure
//
BOOL CALLBACK MakePaletteProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
{
switch (Message) {
case WM_INITDIALOG :
SetDlgItemInt(hDlg, IDD_MakePalColors, gwPalColors, FALSE) ;
SetDlgItemInt(hDlg, IDD_MakePalFrames, gwPalFrames, FALSE) ;
return TRUE ;
case WM_COMMAND :
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDOK :
{
int iColors ;
int iFrames ;
iColors = (int) GetDlgItemInt(hDlg, IDD_MakePalColors, NULL, TRUE) ;
if (! (iColors > 0 && iColors <= 236 || iColors == 256)) {
// invalid number of palette colors
SetDlgItemInt(hDlg, IDD_MakePalColors, iColors, TRUE) ;
SetFocus(GetDlgItem(hDlg, IDD_MakePalColors)) ;
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
iFrames = (int) GetDlgItemInt(hDlg, IDD_MakePalFrames, NULL, TRUE) ;
if (iFrames <= 0 || iFrames > 10000) {
// no frame or way t-o-o many frames !!!
SetDlgItemInt(hDlg, IDD_MakePalFrames, iFrames, TRUE) ;
SetFocus(GetDlgItem(hDlg, IDD_MakePalFrames)) ;
MessageBeep(MB_ICONEXCLAMATION) ;
return FALSE ;
}
gwPalColors = iColors ;
gwPalFrames = iFrames ;
EndDialog(hDlg, TRUE) ;
return TRUE ;
}
case IDCANCEL :
EndDialog(hDlg, FALSE) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
#endif
#define CAPPAL_TIMER 902
#define CAPTIMER_DELAY 100 // get timers as fast as possible
//
// MakePaletteProc: Palette Details Dialog Box Procedure
//
static int siNumColors = 256;
BOOL CALLBACK MakePaletteProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
static UINT shTimer;
static int siNumFrames;
UINT w;
char ach[40];
char achFormat[40];
int i, k;
switch(msg) {
case WM_INITDIALOG:
siNumFrames = 0;
SetDlgItemInt(hwnd, IDD_MakePalColors, siNumColors, FALSE);
SmartWindowPosition (hwnd, ghWndCap);
return TRUE;
break;
case WM_VSCROLL:
/* now handle the scroll */
i = GetDlgItemInt(hwnd, IDD_MakePalColors, NULL, FALSE);
ArrowEditChange(GetDlgItem(hwnd, IDD_MakePalColors),
GET_WM_VSCROLL_CODE(wParam, lParam), 2, 256);
k = GetDlgItemInt(hwnd, IDD_MakePalColors, NULL, FALSE);
// Jump over the range 237 to 255
if (k > 236 && k < 256) {
if (k > i)
w = 256;
else
w = 236;
SetDlgItemInt (hwnd, IDD_MakePalColors, w, TRUE);
}
break;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDCANCEL:
if (siNumFrames) {
// The following finishes building the new palette
capPaletteManual (ghWndCap, FALSE, siNumColors);
}
if (shTimer){
KillTimer(hwnd, CAPPAL_TIMER);
shTimer = 0;
}
siNumColors = GetDlgItemInt(hwnd, IDD_MakePalColors, (BOOL FAR *)ach, FALSE);
siNumColors = max (2, min (256, siNumColors));
EndDialog(hwnd, siNumFrames);
break;
case IDD_MakePalStart:
/* see if we are in START or STOP mode at */
/* this time and handle each one. */
SetFocus (GetDlgItem (hwnd, IDD_MakePalStart));
if (!siNumFrames){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -