📄 remwiz.c
字号:
SendMessage (GetDlgItem (hDlg, IDC_REMNAME), EM_SETSEL, 0, -1);
// Indicate that we didn't find the current device type
CheckRadioButton (hDlg, IDC_DIALUPCONN, IDC_VPNCONN,
IDC_DIRECTCONN);
// Start by disabling all of the windows.
EnableWindow (GetDlgItem (hDlg, IDC_DIALUPCONN), FALSE);
EnableWindow (GetDlgItem (hDlg, IDC_DIRECTCONN), FALSE);
EnableWindow (GetDlgItem (hDlg, IDC_VPNCONN), FALSE);
dwRasDevices = GetRasDevices (&pRasDevInfo);
for (i=0; i < dwRasDevices; i++) {
if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Modem)) {
EnableWindow (GetDlgItem (hDlg, IDC_DIALUPCONN), TRUE);
if (!_tcscmp (EditItem.Entry.szDeviceType, RASDT_Modem)) {
CheckRadioButton (hDlg, IDC_DIALUPCONN, IDC_VPNCONN,
IDC_DIALUPCONN);
}
} else if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Direct)) {
EnableWindow (GetDlgItem (hDlg, IDC_DIRECTCONN), TRUE);
if (!_tcscmp (EditItem.Entry.szDeviceType, RASDT_Direct)) {
CheckRadioButton (hDlg, IDC_DIALUPCONN, IDC_VPNCONN,
IDC_DIRECTCONN);
}
} else if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Vpn)) {
EnableWindow (GetDlgItem (hDlg, IDC_VPNCONN), TRUE);
if (!_tcscmp (EditItem.Entry.szDeviceType, RASDT_Vpn)) {
CheckRadioButton (hDlg, IDC_DIALUPCONN, IDC_VPNCONN,
IDC_VPNCONN);
}
}
}
if (pRasDevInfo) {
LocalFree (pRasDevInfo);
}
// Edit box gets focus by default
nDefFocus = IDC_REMNAME;
} else if (v_WizDialog == v_DialogPages[DLG_PG_2]) {
// Changes buttons if this is a wizard dialog or not
FixButtons(hDlg, v_DialogPages[DLG_PG_2]);
// Set the connection name.
SetWindowText (GetDlgItem (hDlg, IDC_CONNLABEL),
EditItem.EntryName);
dwRasDevices = GetRasDevices (&pRasDevInfo);
for (i=0; i < dwRasDevices; i++) {
if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Modem)) {
SendMessage(GetDlgItem (hDlg, IDC_MODEM),
CB_ADDSTRING,
0, (LPARAM)pRasDevInfo[i].szDeviceName);
}
}
if (pRasDevInfo) {
LocalFree (pRasDevInfo);
}
// Try to find the modem in the list.
lResult = SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_FINDSTRINGEXACT,
0,
(LPARAM)EditItem.Entry.szDeviceName);
if (lResult == CB_ERR) {
SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_SETCURSEL, 0, 0);
GetWindowText (GetDlgItem (hDlg, IDC_MODEM),
EditItem.Entry.szDeviceName,
RAS_MaxDeviceName+1);
} else {
// Set to the correct device.
SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_SETCURSEL, (WPARAM)lResult, 0);
}
// Modem combo box gets focus by default
nDefFocus = IDC_MODEM;
} else if (v_WizDialog == v_DialogPages[DLG_PG_3]) {
if (v_EnteredAsAWizard)
{
if (EditItem.Entry.dwCountryCode == 0) {
EditItem.Entry.dwCountryCode = GetDefaultCountryCode ();
}
if (EditItem.Entry.szAreaCode[0] == TEXT('\0')) {
GetDefaultAreaCode (EditItem.Entry.szAreaCode, RAS_MaxAreaCode);
}
} else {
LoadString(v_hInst, IDS_DIALUPTITLE, szTemp, cTempStrSize);
SetWindowText(hDlg, szTemp);
}
// Set the connection name.
SetWindowText (GetDlgItem (hDlg, IDC_CONNLABEL),
EditItem.EntryName);
// Set Phone Number
SetWindowText (GetDlgItem (hDlg, IDC_AREA_CODE),
EditItem.Entry.szAreaCode);
SetWindowText (GetDlgItem (hDlg, IDC_PHONE_NUM),
EditItem.Entry.szLocalPhoneNumber) ;
// Initialize Country code list box.
CountryCode[0] = TEXT('\0');
if (EditItem.Entry.dwCountryCode)
wsprintf(CountryCode, TEXT("%d"),
EditItem.Entry.dwCountryCode);
SetWindowText (GetDlgItem (hDlg, IDC_COUNTRY),
CountryCode);
// Initialize the use country check box
if (EditItem.Entry.dwfOptions & RASEO_UseCountryAndAreaCodes) {
SendMessage (GetDlgItem(hDlg, IDC_FORCELD), BM_SETCHECK,
1, 0);
}
if (EditItem.Entry.dwfOptions & RASEO_DialAsLocalCall) {
SendMessage (GetDlgItem(hDlg, IDC_FORCELOCAL), BM_SETCHECK,
1, 0);
}
// Phone number gets focus by default
nDefFocus = IDC_PHONE_NUM;
g_pEditProc = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, IDC_AREA_CODE),
GWL_WNDPROC,
(LONG)EditFullWidthConversionSubclassProc);
SetWindowLong(GetDlgItem(hDlg, IDC_PHONE_NUM),
GWL_WNDPROC,
(LONG)EditFullWidthConversionSubclassProc);
SetWindowLong(GetDlgItem(hDlg, IDC_COUNTRY),
GWL_WNDPROC,
(LONG)EditFullWidthConversionSubclassProc);
} else if (v_WizDialog == v_DialogPages[DLG_PG_4]) {
// Changes buttons if this is a wizard dialog or not
FixButtons(hDlg, v_DialogPages[DLG_PG_4]);
// Set the connection name.
SetWindowText (GetDlgItem (hDlg, IDC_CONNLABEL),
EditItem.EntryName);
dwRasDevices = GetRasDevices (&pRasDevInfo);
for (i=0; i < dwRasDevices; i++) {
if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Direct)) {
SendMessage(GetDlgItem (hDlg, IDC_MODEM),
CB_ADDSTRING,
0, (LPARAM)pRasDevInfo[i].szDeviceName);
}
}
if (pRasDevInfo) {
LocalFree (pRasDevInfo);
}
// Try to find the modem in the list.
lResult = SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_FINDSTRINGEXACT, 0,
(LPARAM)EditItem.Entry.szDeviceName);
if (lResult == CB_ERR) {
SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_SETCURSEL, 0, 0);
GetWindowText (GetDlgItem (hDlg, IDC_MODEM),
EditItem.Entry.szDeviceName,
RAS_MaxDeviceName+1);
} else {
// Set to the correct device.
SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_SETCURSEL, (WPARAM)lResult, 0);
}
// gets focus by default
nDefFocus = IDC_MODEM;
} else if (v_WizDialog == v_DialogPages[DLG_PG_5]) {
// The VPN config page
FixButtons(hDlg, v_DialogPages[DLG_PG_5]);
dwRasDevices = GetRasDevices (&pRasDevInfo);
for (i=0; i < dwRasDevices; i++) {
if (!_tcscmp (pRasDevInfo[i].szDeviceType, RASDT_Vpn)) {
// Just copy the first device to the entry.
_tcsncpy (EditItem.Entry.szDeviceType, RASDT_Vpn, RAS_MaxDeviceType);
_tcsncpy (EditItem.Entry.szDeviceName, pRasDevInfo[i].szDeviceName,
RAS_MaxDeviceName);
break;
}
}
if (pRasDevInfo) {
LocalFree (pRasDevInfo);
}
// Set the connection name.
SetWindowText (GetDlgItem (hDlg, IDC_CONNLABEL),
EditItem.EntryName);
SetWindowText (GetDlgItem (hDlg, IDC_HOSTNAME),
EditItem.Entry.szLocalPhoneNumber);
SendMessage (GetDlgItem (hDlg, IDC_HOSTNAME), EM_LIMITTEXT,
RAS_MaxPhoneNumber, 0);
nDefFocus = IDC_HOSTNAME;
} else {
ASSERT (0);
}
// Set focus
SetFocus(GetDlgItem(hDlg, nDefFocus));
return FALSE;
case WM_COMMAND :
if (HIWORD(wParam) == CBN_SELCHANGE) {
DEBUGMSG (ZONE_WARN,
(TEXT("Got CBN_SELCHANGE message\r\n")));
// Make sure that it's the Modem
if (LOWORD(wParam) == IDC_MODEM) {
// Release any Device Config info they had edited.
if (v_pDevConfig) {
LocalFree (v_pDevConfig);
v_pDevConfig = NULL;
v_dwDevConfigSize = 0;
}
}
break;
}
switch (LOWORD(wParam)) {
case IDCANCEL :
NextPage (hDlg, (DWORD)-1);
break;
case IDFINISH:
case IDOK:
if ((v_WizDialog == v_DialogPages[DLG_PG_1]) ||
(v_WizDialog == v_DialogPages[DLG_PG_2])) {
DoNext (hDlg);
} else if (v_WizDialog == v_DialogPages[DLG_PG_3]) {
// Validate the input.
if (GetDialUpSettings(hDlg, CountryCode, TRUE))
{
v_WizDialog = 0;
NextPage (hDlg, v_WizDialog);
}
} else if (v_WizDialog == v_DialogPages[DLG_PG_4]) {
GetWindowText (GetDlgItem (hDlg, IDC_MODEM),
EditItem.Entry.szDeviceName,
RAS_MaxDeviceName+1);
v_WizDialog = 0;
NextPage (hDlg, v_WizDialog);
} else if (v_WizDialog == v_DialogPages[DLG_PG_5]) {
// Should we validate the string???
GetWindowText (GetDlgItem (hDlg, IDC_HOSTNAME),
EditItem.Entry.szLocalPhoneNumber,
RAS_MaxPhoneNumber+1);
v_WizDialog = 0;
NextPage (hDlg, v_WizDialog);
}
break;
case IDNEXT :
DoNext (hDlg);
break;
case IDBACK :
if (v_WizDialog == v_DialogPages[DLG_PG_2]) {
// Save the modem name.
GetWindowText (GetDlgItem (hDlg, IDC_MODEM),
EditItem.Entry.szDeviceName,
RAS_MaxDeviceName+1);
v_WizDialog = v_DialogPages[DLG_PG_1];
} else if (v_WizDialog == v_DialogPages[DLG_PG_3]) {
(void) GetDialUpSettings(hDlg, CountryCode, FALSE);
v_WizDialog = v_DialogPages[DLG_PG_2];
} else if (v_WizDialog == v_DialogPages[DLG_PG_4]) {
v_WizDialog = v_DialogPages[DLG_PG_1];
Device = SendMessage (GetDlgItem (hDlg, IDC_MODEM),
CB_GETCURSEL, 0, 0);
} else if (v_WizDialog == v_DialogPages[DLG_PG_5]) {
v_WizDialog = v_DialogPages[DLG_PG_1];
}
NextPage (hDlg, v_WizDialog);
break;
case IDC_TCPSETTINGS :
TCP_IP_Properties (hDlg, &(EditItem));
break;
case IDC_FORCELOCAL :
if (SendMessage(GetDlgItem(hDlg, IDC_FORCELOCAL),
BM_GETCHECK, 0, 0)) {
// Clear the FORCELD checkbox.
SendMessage (GetDlgItem(hDlg, IDC_FORCELD), BM_SETCHECK,
0, 0);
}
break;
case IDC_FORCELD :
if (SendMessage(GetDlgItem(hDlg, IDC_FORCELD),
BM_GETCHECK, 0, 0)) {
SendMessage (GetDlgItem(hDlg, IDC_FORCELOCAL), BM_SETCHECK,
0, 0);
}
break;
case IDC_CONFIG :
{
static HANDLE hThread = NULL;
DWORD ThreadID;
DWORD RetVal;
MSG NewMsg;
if (hThread != NULL) {
RETAILMSG (1, (TEXT("Recursing, only one config allowed at a time\r\n")));
ASSERT(1);
break;
}
hThread = CreateThread (NULL, 0, DevConfigThread, (LPVOID)hDlg, 0, &ThreadID);
while (1) {
RetVal = MsgWaitForMultipleObjectsEx (1, &hThread, INFINITE, QS_PAINT, 0);
if (WAIT_OBJECT_0 == RetVal) {
// The thread died. Break out of this loop
break;
} else if ((WAIT_OBJECT_0+1) == RetVal) {
if (PeekMessage (&NewMsg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE)) {
if (!IsDialogMessage(hDlg, &NewMsg)) {
TranslateMessage(&NewMsg);
DispatchMessage(&NewMsg);
}
}
}
}
CloseHandle (hThread);
hThread = NULL;
}
break;
default :
// Unused WM_COMMAND?
break;
}
case WM_DESTROY:
return TRUE;
break;
default:
return (FALSE);
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -