📄 dialogs.c
字号:
(multiMemberships < IP_MAX_MEMBERSHIPS) &&
(SendDlgItemMessage(hwnd, IDC_MC_NEW_GROUP, EM_LINELENGTH, 0, 0L) > 0));
}
break;
case IDC_MC_JOIN:
{
char group[MAX_HOST];
int l;
struct in_addr newaddr;
*((WORD *) group) = sizeof group;
l = (int) SendDlgItemMessage(hwnd, IDC_MC_NEW_GROUP, EM_GETLINE,
0, (LPARAM) (LPSTR) group);
group[l] = 0;
newaddr.s_addr = inet_addr(group);
if (newaddr.s_addr == INADDR_NONE) {
LPHOSTENT h = gethostbyname(group);
if (h == NULL) {
int serr = WSAGetLastError();
MsgBox(hwnd, MB_ICONSTOP | MB_OK, Format(39),
(LPSTR) group,
serr, SockerrToString(serr));
group[0] = 0;
} else {
newaddr = *((LPIN_ADDR) h->h_addr);
wsprintf(group + strlen(group), Format(34),
(LPSTR) inet_ntoa(newaddr));
}
}
if (group[0] != 0 && !IN_MULTICAST(newaddr.s_addr)) {
MsgBox(hwnd, MB_ICONSTOP | MB_OK, Format(35),
((LPSTR) inet_ntoa(newaddr)));
group[0] = 0;
}
if (group[0] != 0) {
int nitem, ic;
// Clear input field
SetDlgItemText(hwnd, IDC_MC_NEW_GROUP, "");
// Make sure it's not already in the box
nitem = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_FINDSTRINGEXACT,
(WPARAM) -1, (LPARAM) (LPCSTR) group);
if (nitem == LB_ERR) {
nitem = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_ADDSTRING, 0,
(LPARAM) (LPCSTR) group);
ic = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_GETCOUNT, 0, 0L);
EnableWindow(GetDlgItem(hwnd, IDC_MC_LEAVE), ic > 0);
EnableWindow(GetDlgItem(hwnd, IDC_MC_JOIN), FALSE);
}
if (nitem != LB_ERR) {
SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_SETCURSEL, nitem, 0L);
}
}
// Set focus back to the edit field
SetFocus(GetDlgItem(hwnd, IDC_MC_NEW_GROUP));
}
break;
case IDC_MC_LEAVE:
{
int item = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS,
LB_GETCURSEL, 0, 0L);
if (item != LB_ERR) {
int itemc;
SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_DELETESTRING, item, 0L);
itemc = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_GETCOUNT, 0, 0L);
EnableWindow(GetDlgItem(hwnd, IDC_MC_LEAVE), itemc > 0);
EnableWindow(GetDlgItem(hwnd, IDC_MC_JOIN),
(itemc < IP_MAX_MEMBERSHIPS) &&
(SendDlgItemMessage(hwnd, IDC_MC_NEW_GROUP, EM_LINELENGTH, 0, 0L) > 0));
SendDlgItemMessage(hwnd, IDC_MC_GROUPS,
LB_SETCURSEL, item >= itemc ? itemc - 1 : item, 0L);
}
}
break;
case ID_HELP:
WinHelp(hwndMDIFrame, rstring(IDS_HELPFILE), HELP_KEY,
((DWORD) (Lrstring(IDS_HELP_MULTICAST))));
holped = TRUE;
break;
}
}
#endif
return FALSE;
}
// MULTICASTGROUPSDIALOGUE -- Multicast group membership dialogue
VOID multicastGroupsDialogue(HWND hwnd)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_MULTICAST), hwnd, multicastDlgProc);
}
// ABOUT_DLGPROC -- About dialogue procedure
BOOL CALLBACK About_DlgProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam)
{
switch (nMessage) {
case WM_INITDIALOG:
{
char s[80];
wsprintf(s, Format(75), 8 * sizeof(int));
SetDlgItemText(hwnd, IDC_ABOUT_TITLE, s);
if (aboutInSamples != 0) {
_fstrcpy(s, inputActive ? rstring(IDS_T_ACTIVE) : rstring(IDS_T_IDLE));
wsprintf(s + strlen(s), Format(50),
aboutInSamples, aboutInBits);
SetDlgItemText(hwnd, IDC_ABOUT_INPUT, s);
} else {
SetDlgItemText(hwnd, IDC_ABOUT_INPUT, rstring(IDS_T_NEVER_USED));
}
if (aboutOutSamples != 0) {
_fstrcpy(s, outputActive ? rstring(IDS_T_ACTIVE) : rstring(IDS_T_IDLE));
wsprintf(s + strlen(s), Format(50),
aboutOutSamples, aboutOutBits);
SetDlgItemText(hwnd, IDC_ABOUT_OUTPUT, s);
} else {
SetDlgItemText(hwnd, IDC_ABOUT_OUTPUT, rstring(IDS_T_NEVER_USED));
}
ShowWindow(GetDlgItem(hwnd, IDC_ABOUT_DUPLEX),
halfDuplex ? SW_SHOW : SW_HIDE);
#ifdef CRYPTO
ShowWindow(GetDlgItem(hwnd, IDC_ABOUT_CRYPTO_ON), SW_SHOW);
ShowWindow(GetDlgItem(hwnd, IDC_ABOUT_CRYPTO_OFF), SW_HIDE);
#else
ShowWindow(GetDlgItem(hwnd, IDC_ABOUT_CRYPTO_OFF), SW_SHOW);
ShowWindow(GetDlgItem(hwnd, IDC_ABOUT_CRYPTO_ON), SW_HIDE);
GetDlgItemText(hwnd, IDC_ABOUT_VERSION, s, sizeof s);
_fstrcat(s, " (No Crypto)");
SetDlgItemText(hwnd, IDC_ABOUT_VERSION, s);
#endif
}
break;
case WM_COMMAND:
switch ((short) WM_COMMAND_ID(wParam)) {
case IDOK:
EndDialog(hwnd, TRUE);
break;
case ID_HELP:
WinHelp(hwndMDIFrame, rstring(IDS_HELPFILE), HELP_KEY,
((DWORD) (Lrstring(IDS_HELP_ABOUT))));
holped = TRUE;
break;
}
break;
}
return FALSE;
}
// ABOUTDIALOGUE -- About dialogue
VOID aboutDialogue(HWND hwndParent)
{
DialogBox(hInst, IDD_ABOUT, hwndParent, About_DlgProc);
}
/* PROPUPDATEAUDIO -- Update audio configuration information in the
propeller head panel. */
void propUpdateAudio(void)
{
if (hDlgPropeller != NULL) {
char s[80];
if (aboutInSamples != 0) {
_fstrcpy(s, inputActive ? rstring(IDS_T_ACTIVE_COMMA) : rstring(IDS_T_IDLE_COMMA));
wsprintf(s + strlen(s), Format(36),
aboutInBits, aboutInSamples);
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_IN, s);
} else {
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_IN, rstring(IDS_T_NONE));
}
if (aboutOutSamples != 0) {
_fstrcpy(s, outputInShutdown ? rstring(IDS_T_TERMINATING_COMMA) :
(halfDuplexTransition ? rstring(IDS_T_TRANSITION_COMMA) :
(outputActive ? rstring(IDS_T_ACTIVE_COMMA) : rstring(IDS_T_IDLE_COMMA))));
wsprintf(s + strlen(s), Format(36),
aboutOutBits, aboutOutSamples);
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_OUT, s);
if (outputPending == 0) {
wsprintf(s, Format(6));
} else {
wsprintf(s, Format(7), outputPending);
}
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_OUT_QUEUE, s);
} else {
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_OUT, rstring(IDS_T_NONE));
}
SetDlgItemText(hDlgPropeller, IDC_PH_AUDIO_DUPLEX,
halfDuplex ? rstring(IDS_T_HALF_DUPLEX) : rstring(IDS_T_FULL_DUPLEX));
SetDlgItemInt(hDlgPropeller, IDC_PH_CONNECTIONS, openConnections, FALSE);
SetDlgItemInt(hDlgPropeller, IDC_PH_PACKET_SENDSIZE, inputSampleCount(), FALSE);
SetDlgItemText(hDlgPropeller, IDC_PH_COMPRESSION,
rstring(IDS_COMPRESSION_TYPES + ((compression ? 1 : 0) |
((gsmcompress || voxcompress) ? 2 : 0) |
(adpcmcompress ? 4 : 0) |
(lpccompress ? 8 : 0) |
(lpc10compress ? 16 : 0))));
}
}
// PROPELLERHEADDLGPROC -- Propeller head dialogue procedure
BOOL CALLBACK propellerHeadDlgProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam)
{
switch (nMessage) {
case WM_INITDIALOG:
{
char s[80];
if (aboutUDPmax != 0) {
wsprintf(s, Format(37), aboutUDPmax);
SetDlgItemText(hwnd, IDC_PH_PACKET_SIZE, s);
}
#define Prop(item, value) wsprintf(s, Format(0), value); SetDlgItemText(hwnd, item, s)
Prop(IDC_PH_PACKETS_RECEIVED, packetsReceived);
Prop(IDC_PH_PACKETS_SENT, packetsSent);
Prop(IDC_PH_INPUT_LOST, inputPacketsLost);
Prop(IDC_PH_OUTPUT_LOST, outputPacketsLost);
Prop(IDC_PH_MESSAGE_QUEUE, (long) messageQueueSize);
Prop(IDC_PH_MSGCHECK, messageChecks);
SetDlgItemText(hwnd, IDC_PH_SENDTO,
useSendNotSendto ? rstring(IDS_T_SEND) : rstring(IDS_T_SENDTO));
#undef Prop
hDlgPropeller = hwnd;
propUpdateAudio();
}
return TRUE;
case WM_CLOSE:
DestroyWindow(hwnd);
return TRUE;
case WM_COMMAND:
switch ((short) WM_COMMAND_ID(wParam)) {
case IDOK:
PostMessage(hwnd, WM_CLOSE, 0, 0L);
break;
case ID_HELP:
WinHelp(hwndMDIFrame, rstring(IDS_HELPFILE), HELP_KEY,
((DWORD) (Lrstring(IDS_HELP_PROPELLER))));
holped = TRUE;
break;
}
return TRUE;
case WM_DESTROY:
hDlgPropeller = NULL;
return 0;
}
return FALSE;
}
// PROPELLERHEADDIALOGUE -- Expert status dialogue
VOID propellerHeadDialogue(HWND hwndParent)
{
hDlgPropeller = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PROPELLER_HEAD),
hwndParent, propellerHeadDlgProc);
}
/* NEWHOST_ENABLECONTROLS -- Enable/disable controls (other
than the Cancel button) in the New
Host dialogue. */
static VOID NewHost_EnableControls(HWND hwnd, BOOL fEnable)
{
EnableWindow(GetDlgItem(hwnd, IDD_NEW_HOST), fEnable);
EnableWindow(GetDlgItem(hwnd, IDD_NEW_HOST_NAME), fEnable);
EnableWindow(GetDlgItem(hwnd, IDOK), fEnable);
/* If we enabling the dialog controls, it is due to a
failure to retrieve the host data, so set the focus
to the host edit field. If we're disabling the controls,
set the focus to the cancel button since that's the only
thing we haven't disabled. */
SetFocus(GetDlgItem(hwnd, fEnable ? IDD_NEW_HOST : IDCANCEL));
}
/* NEWHOST_ONSOCKETASYNC -- Handles reply from lookup of host
name or IP address. */
static VOID NewHost_OnSocketAsync(HWND hwnd, SOCKERR hAsync,
SOCKERR serr, SOCKEVENT cbBuffer)
{
LPHOSTENT phostent;
phostent = (LPHOSTENT) NewHostParams.bBuffer;
if (serr != 0) {
// Error retrieving host name/address
if (NewHostParams.laddr == INADDR_NONE) {
MsgBox(hwnd, MB_ICONSTOP | MB_OK, Format(41),
NewHostParams.pszHostName, serr, SockerrToString(serr));
// Reenable the dialog controls
NewHost_EnableControls(hwnd, TRUE);
return;
} else {
struct in_addr in;
in.s_addr = NewHostParams.laddr;
_fstrcpy(NewHostParams.pszHostName, inet_ntoa(in));
_fmemcpy(NewHostParams.paddr, &NewHostParams.laddr, sizeof(IN_ADDR));
EndDialog(hwnd, TRUE);
return;
}
}
// Found the host
_fstrcpy(NewHostParams.pszHostName, phostent->h_name);
_fmemcpy(NewHostParams.paddr, phostent->h_addr, sizeof(IN_ADDR));
EndDialog(hwnd, TRUE);
}
/* NEWHOST_ONCOMMAND -- Handle child control messages in the new
host dialogue. */
static VOID NewHost_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
HANDLE hAsyncTask;
SOCKERR serr;
// Interpret the command
switch (id) {
case IDOK:
// handled below
break;
case IDCANCEL:
// Cancel any pending async operation started by this dialog
if (NewHostParams.hAsync != NULL) {
WSACancelAsyncRequest(NewHostParams.hAsync);
NewHostParams.hAsync = NULL;
}
EndDialog(hwnd, FALSE);
return;
#ifdef MODEM
case IDC_NEW_MODEM:
{
if ((WORD) SendMessage(GetDlgItem(hwnd, IDC_NEW_MODEM),
BM_GETCHECK, 0, 0L)) {
ShowWindow(GetDlgItem(hwnd, IDD_NEW_HOST_NAME), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, IDD_NEW_HOST_DIAL_STRING), SW_SHOW);
} else {
ShowWindow(GetDlgItem(hwnd, IDD_NEW_HOST_NAME), SW_SHOW);
ShowWindow(GetDlgItem(hwnd, IDD_NEW_HOST_DIAL_STRING), SW_HIDE);
}
}
return;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -