📄 answer.c
字号:
grex += 2;
}*/
DestroyWindow(hwnd);
return TRUE;
case WM_COMMAND:
switch ((short) WM_COMMAND_ID(wParam)) {
case IDC_RP_PREV:
currentMessage--;
goto playCurrent;
case IDC_RP_NEXT:
currentMessage++;
case IDC_RP_REPLAY:
playCurrent: setMessageCount();
buttonPushed = WM_COMMAND_ID(wParam);
if (obtainOutput(hwndMDIFrame)) {
answerReplay();
answerPlayPos = msgTable[currentMessage];
// Disable controls to prevent mischief while we're playing
EnableWindow(GetDlgItem(hwnd, IDC_RP_PREV), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_NEXT), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REPLAY), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_ERASE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REWIND), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_BROWSE), FALSE);
replaying = TRUE;
firstPacket = TRUE;
hostShown = hostPrelim = FALSE;
SetTimer(hwnd, 5, 1, NULL);
}
break;
case IDC_RP_ERASE:
fclose(answerFile);
answerFile = fopen(answerFileName, "w+b");
msgCount = 0;
answerLen = 0;
// Note fall-through
case IDC_RP_REWIND:
goto setIdle;
case IDC_RP_BROWSE:
{
OPENFILENAME ofn;
char szString[MAX_PATH];
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = rfilter(IDS_T_ANSWER_MESSAGE_FILTER);
ofn.lpstrCustomFilter = NULL;
strcpy(szString, answerFileName);
ofn.lpstrFile = (LPSTR) szString;
ofn.nMaxFile = sizeof(szString);
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = rstring(IDS_T_ANSWER_OPEN_TITLE);
ofn.Flags = OFN_NOREADONLYRETURN | OFN_HIDEREADONLY | OFN_SHOWHELP;
fileHelpKey = rstring(IDS_HELP_ANSWER);
if (GetOpenFileName((LPOPENFILENAME) &ofn)) {
SetDlgItemText(hwnd, IDC_RP_MSGFILE, szString);
_fstrcpy(answerFileName, szString);
answerClose();
answerOpen();
currentMessage = -1;
scanMessageFile(hwnd);
EnableWindow(GetDlgItem(hwnd, IDC_RP_PREV), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REWIND), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REPLAY), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_NEXT), answerFile && msgCount > 0);
EnableWindow(GetDlgItem(hwnd, IDC_RP_ERASE), answerFile && answerLen > 0);
EnableWindow(GetDlgItem(hwnd, IDC_RP_RECORD), answerFile != NULL);
SetDlgItemText(hwnd, IDC_RP_SITE, "");
SetDlgItemText(hwnd, IDC_RP_TIME, "");
setMessageCount();
}
}
break;
case IDC_RP_CLEAR_INCOMING:
SetDlgItemText(hwnd, IDC_RP_MSGFILE, "");
strcpy(answerFileName, "");
answerClose();
currentMessage = -1;
scanMessageFile(hwnd);
EnableWindow(GetDlgItem(hwnd, IDC_RP_PREV), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REWIND), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REPLAY), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_NEXT), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_ERASE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_RECORD), FALSE);
SetDlgItemText(hwnd, IDC_RP_SITE, "");
SetDlgItemText(hwnd, IDC_RP_TIME, "");
setMessageCount();
break;
case IDC_RP_BROWSE_OUTGOING:
{
OPENFILENAME ofn;
char szString[MAX_PATH];
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = rfilter(IDS_T_SOUND_FILE_FILTER);
ofn.lpstrCustomFilter = NULL;
strcpy(szString, answerOutFileName);
ofn.lpstrFile = (LPSTR) szString;
ofn.nMaxFile = sizeof(szString);
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = rstring(IDS_T_ANSWER_OUTOPEN_TITLE);
ofn.Flags = OFN_SHOWHELP;
fileHelpKey = rstring(IDS_HELP_ANSWER);
if (GetOpenFileName((LPOPENFILENAME) &ofn)) {
SetDlgItemText(hwnd, IDC_RP_OUTMSGFILE, szString);
_fstrcpy(answerOutFileName, szString);
}
}
break;
case IDC_RP_CLEAR_OUTGOING:
strcpy(answerOutFileName, "");
SetDlgItemText(hwnd, IDC_RP_OUTMSGFILE, "");
break;
case IDC_RP_RECORD:
answerRecord = IsDlgButtonChecked(hwnd, IDC_RP_RECORD);
break;
case IDOK:
answerRecord = IsDlgButtonChecked(hwnd, IDC_RP_RECORD);
PostMessage(hwnd, WM_CLOSE, 0, 0L);
break;
case ID_HELP:
WinHelp(hwndMDIFrame, rstring(IDS_HELPFILE), HELP_KEY,
((DWORD) (Lrstring(IDS_HELP_ANSWER))));
holped = TRUE;
break;
}
return FALSE;
case WM_DESTROY:
if (replaying) {
KillTimer(hwnd, 5);
}
if (msgTable != NULL) {
GlobalFreePtr(msgTable);
msgTable = NULL;
}
hDlgAnswer = NULL;
return 0;
case WM_TIMER:
{
struct in_addr IPaddr;
char hostName[MAX_HOST];
time_t t;
DWORD startTicks = GetTickCount();
long et, sfp;
int ateof = FALSE;
if (replaying) {
sfp = answerPlayPos;
if (answerRead(&IPaddr, &t, hostName, &ebuf)) {
if (firstPacket || !(ebuf.compression & fAnsNewMsg)) {
firstPacket = FALSE;
playSound(hwndMDIFrame, NULL, &ebuf, aboutOutBits, aboutOutSamples);
if (!hostShown) {
char ft[24];
struct tm *lt;
// Update host when definitive name seen
if (hostName[0] != '(') {
hostShown = TRUE;
hostPrelim = FALSE;
}
if (!hostPrelim) {
lt = localtime(&t);
sprintf(ft, Format(49), rstring(IDS_WEEKDAYS + lt->tm_wday),
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min, lt->tm_sec);
SetDlgItemText(hwnd, IDC_RP_TIME, ft);
SetDlgItemText(hwnd, IDC_RP_SITE, hostName);
hostPrelim = TRUE;
}
}
/* The following code is needed because when we're reading
sound from a file, as opposed to receiving it in real
time from the CODEC, we must meter out the samples
at the rate they will actually be played by the destination
machine. For 8000 samples per second, this amounts
to 125 microseconds per sample. */
#define kOverhead 30000L
et = ((ebuf.buffer.buffer_len * 125L) - kOverhead) -
((GetTickCount() - startTicks) * 1000);
if (et <= 0) {
et = 1;
}
SetTimer(hwnd, 5, (UINT) (et / 1000), NULL);
} else {
answerPlayPos = sfp;
replaying = FALSE;
}
} else {
replaying = FALSE;
ateof = TRUE;
}
}
if (!replaying) {
answerReplayDone();
KillTimer(hwnd, 5);
EnableWindow(GetDlgItem(hwnd, IDC_RP_PREV), currentMessage > 0);
EnableWindow(GetDlgItem(hwnd, IDC_RP_NEXT), !ateof);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REPLAY), currentMessage >= 0);
EnableWindow(GetDlgItem(hwnd, IDC_RP_REWIND), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_ERASE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_RP_BROWSE), TRUE);
/* Restore focus to the button we pushed, or the logical
successor if it isn't enabled any more. */
if (buttonPushed != 0 && !IsWindowEnabled(GetDlgItem(hwnd, buttonPushed))) {
if (IsWindowEnabled(GetDlgItem(hwnd, IDC_RP_NEXT))) {
buttonPushed = IDC_RP_NEXT;
} else if (IsWindowEnabled(GetDlgItem(hwnd, IDC_RP_PREV))) {
buttonPushed = IDC_RP_PREV;
} else if (IsWindowEnabled(GetDlgItem(hwnd, IDC_RP_REPLAY))) {
buttonPushed = IDC_RP_REPLAY;
} else {
buttonPushed = IDOK;
}
}
SetFocus(GetDlgItem(hwnd, buttonPushed));
}
}
break;
default:
if (nMessage == fileOpenHelpButton && fileHelpKey != NULL) {
WinHelp(hwndMDIFrame, rstring(IDS_HELPFILE), HELP_KEY,
((DWORD) (LPSTR) fileHelpKey));
holped = TRUE;
}
break;
}
return FALSE;
}
// ANSWERDIALOGUE -- Answering machine dialogue
VOID answerDialogue(HWND hwndParent)
{
CreateDialog(hInst, MAKEINTRESOURCE(IDD_REPONDEUR),
hwndParent, answerDlgProc);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -