📄 dialogs.c
字号:
CheckDlgButton(hwnd, IDC_MC_LOOP, multiLoop);
EnableWindow(GetDlgItem(hwnd, IDC_MC_LOOP), !multiBrainDead);
EnableWindow(GetDlgItem(hwnd, IDC_MC_LEAVE), multiMemberships > 0);
EnableWindow(GetDlgItem(hwnd, IDC_MC_JOIN), FALSE);
}
break;
case WM_COMMAND:
switch ((short) WM_COMMAND_ID(wParam)) {
case IDOK:
{
int i, n;
multicastJoin(hwnd, FALSE); // Drop current groups
multiLoop = IsDlgButtonChecked(hwnd, IDC_MC_LOOP);
n = (int) SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_GETCOUNT, 0, 0L);
for (i = 0; i < n; i++) {
char s[MAX_HOST + 24];
char *cp;
SendDlgItemMessage(hwnd, IDC_MC_GROUPS, LB_GETTEXT, i,
(LPARAM) (LPCSTR) s);
if ((cp = strchr(s, '(')) != NULL) {
char *cp1;
cp++;
cp1 = strchr(cp, ')');
if (cp1 != NULL) {
*cp1 = 0;
}
} else {
cp = s;
}
multiAddr[i].s_addr = inet_addr(cp);
multiName[i] = NULL;
if (cp > s) {
LPSTR np;
cp[-2] = 0;
np = GlobalAllocPtr(GPTR, strlen(s) + 1);
if (np != NULL) {
strcpy(np, s);
multiName[i] = np;
}
}
}
multiMemberships = n;
multicastJoin(hwnd, TRUE); // Join newly chosen groups
}
EndDialog(hwnd, TRUE);
break;
case IDCANCEL:
EndDialog(hwnd, FALSE);
break;
case IDC_MC_NEW_GROUP:
if (WM_COMMAND_NOTIFY == EN_CHANGE) {
EnableWindow(GetDlgItem(hwnd, IDC_MC_JOIN),
(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:
displayHelpTopic(IDS_HELP_MULTICAST);
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];
int iRc;
LPHOSTENT lphp;
struct in_addr in_addrIP;
wsprintf(s, Format(75), 8 * sizeof(int));
SetDlgItemText(hwnd, IDC_ABOUT_TITLE, s);
if (aboutInSamples != 0) {
strcpy(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) {
strcpy(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);
strcat(s, " (No Crypto)");
SetDlgItemText(hwnd, IDC_ABOUT_VERSION, s);
#endif
// Display local IP address.
iRc = gethostname(s, 80);
lphp = NULL;
if (iRc != SOCKET_ERROR)
{
lphp = gethostbyname(s);
}
if(lphp != NULL)
{
in_addrIP = *(struct in_addr *)(lphp->h_addr);
wsprintf(s, "%s", (LPSTR)inet_ntoa(in_addrIP));
}
else
{
strcpy(s, "Unknown");
}
SetDlgItemText(hwnd, IDC_ABOUT_IP_ADDRESS, s);
}
break;
case WM_COMMAND:
switch ((short) WM_COMMAND_ID(wParam)) {
case IDOK:
EndDialog(hwnd, TRUE);
break;
case ID_HELP:
displayHelpTopic(IDS_HELP_ABOUT);
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) {
strcpy(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) {
strcpy(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 {
sprintf(s, Format(7), outputPending, microsecondsPending / 1000000.0);
}
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);
/* N.b. Any of the more advanced compression modes may be combined
with "simple" (compression == TRUE) compression, but they are
mutually exclusive. The following statement was coded as if
they were not prior to the advent of CELP, but in fact the
string table items beginning with IDS_COMPRESSION_TYPES were
only populated with the possible combinations. To avoid
colliding with subsequent items in the string table,
new compression modes should be inserted with in pairs of
slots starting with 20, or back-filling prior vacant
slots. */
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) |
(celpcompress ? 18 : 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:
displayHelpTopic(IDS_HELP_PROPELLER);
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;
strcpy(NewHostParams.pszHostName, inet_ntoa(in));
memcpy(NewHostParams.paddr, &NewHostParams.laddr, sizeof(IN_ADDR));
EndDialog(hwnd, TRUE);
return;
}
}
// Found the host
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -