📄 cedialer.c
字号:
}
else
{
ErrorBox (TEXT("Failed in making the call, ")
TEXT("\nfunction lineMakeCall failed."));
CurrentLineClose ();
}
exit :
if (lpCallParams)
LocalFree (lpCallParams);
if (lpTransOutput)
LocalFree (lpTransOutput);
// If the make call did not succeed but the line was opened,
// then close it.
if ((g_MakeCallRequestID <= 0) && (g_CurrentLineInfo.hLine))
CurrentLineClose ();
return;
}
/***********************************************************************
FUNCTION:
ConnectUsingProc
PURPOSE:
Processes messages sent to IDD_CONNECTUSING dialog box.
***********************************************************************/
BOOL CALLBACK ConnectUsingProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
SHINITDLGINFO shidi;
SHMENUBARINFO mbi;
switch (uMsg)
{
case WM_INITDIALOG:
{
// Create OK button in navigation bar and size dialog.
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLG;
shidi.hDlg = hwnd;
SHInitDialog(&shidi);
if (IsSmartphone())
{
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_OKMENU;
mbi.hInstRes = g_hInst;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
if (SHCreateMenuBar(&mbi) == 0)
return FALSE;
}
// Get the list of lines into the line list box.
InitLineCB (GetDlgItem (hwnd, IDC_LISTLINES),
g_dwCurrentLineID,
g_dwNumDevs);
// Get the list of addresses into the address list box.
InitAddrCB (GetDlgItem (hwnd, IDC_LISTLINES),
GetDlgItem (hwnd, IDC_LISTADDRESSES),
g_dwCurrentLineID,
g_dwCurrentLineAddr);
return TRUE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_LISTLINES:
if (HIWORD(wParam) == CBN_SELENDOK)
{
// Update the address box.
InitAddrCB (GetDlgItem (hwnd, IDC_LISTLINES),
GetDlgItem (hwnd, IDC_LISTADDRESSES),
g_dwCurrentLineID,
g_dwCurrentLineAddr);
}
break;
case IDM_OK:
case IDOK:
{
long lIndex;
lIndex = SendDlgItemMessage (hwnd,
IDC_LISTLINES,
CB_GETCURSEL, 0, 0);
// Update the current line identifier.
g_dwCurrentLineID = SendDlgItemMessage (
hwnd,
IDC_LISTLINES,
CB_GETITEMDATA,
(WPARAM) lIndex, 0);
lIndex = SendDlgItemMessage (hwnd,
IDC_LISTADDRESSES,
CB_GETCURSEL, 0, 0);
// Update the current address for the current line.
g_dwCurrentLineAddr = SendDlgItemMessage (
hwnd,
IDC_LISTADDRESSES,
CB_GETITEMDATA,
(WPARAM) lIndex, 0);
// Assign the g_CurrentLineInfo.
g_CurrentLineInfo = g_lpLineInfo [g_dwCurrentLineID];
}
EndDialog (hwnd, FALSE);
return TRUE;
}
}
}
return FALSE;
}
/***********************************************************************
FUNCTION:
InitLineCB
PURPOSE:
Fills line list box on the IDD_CONNECTUSING dialog box.
***********************************************************************/
BOOL InitLineCB(
HWND hwndLineCB,
DWORD dwCurrentLine,
DWORD dwNumOfDev
)
{
DWORD dwItem,
dwLineID,
dwCurrentItem = (DWORD)-1;
// Empty the line combo box.
SendMessage (hwndLineCB, CB_RESETCONTENT, 0, 0);
// Add the device name strings.
for (dwLineID = 0; dwLineID < dwNumOfDev; ++dwLineID)
{
// Add the line name string to the list box of the line combo box.
dwItem = SendMessage (hwndLineCB,
CB_ADDSTRING,
0,
(LPARAM)(g_lpLineInfo[dwLineID].szLineName));
if (dwItem == CB_ERR || dwItem == CB_ERRSPACE)
return FALSE;
// Set the dwLineID associated with the dwItem item.
SendMessage (hwndLineCB,
CB_SETITEMDATA,
(WPARAM)dwItem,
(LPARAM)dwLineID);
if (dwLineID == dwCurrentLine)
dwCurrentItem = dwItem;
else
{
// If the item we are putting is before the current item, we
// must increment dwCurrentItem to reflect that an item is
// being placed before it, due to sorting.
if (dwCurrentItem != -1 && dwItem <= dwCurrentItem)
++dwCurrentItem;
}
}
if (dwCurrentItem == (DWORD)-1)
dwCurrentItem = 0;
// Select the dwCurrentItem item in the list box of the line
// combo box.
if (SendMessage (hwndLineCB, CB_GETCOUNT, 0, 0) != 0)
{
SendMessage (hwndLineCB, CB_SETCURSEL, (WPARAM)dwCurrentItem, 0);
return TRUE;
}
return FALSE;
}
/***********************************************************************
FUNCTION:
InitAddrCB
PURPOSE:
Fills address list box on the IDD_CONNECTUSING dialog box.
***********************************************************************/
BOOL InitAddrCB(
HWND hwndLineCB,
HWND hwndAddrCB,
DWORD dwCurrentLine,
DWORD dwCurrentAddr
)
{
DWORD dwAddr,
dwItem,
dwCurrentItem = (DWORD)-1,
dwLineCBCurrent;
TCHAR szAddrName[512];
if (SendMessage (hwndLineCB, CB_GETCOUNT, 0, 0) == 0)
return FALSE;
// Empty the address list box.
SendMessage (hwndAddrCB, CB_RESETCONTENT, 0, 0);
// Select the current entry in the line box.
dwLineCBCurrent = SendMessage (
hwndLineCB,
CB_GETITEMDATA,
SendMessage (hwndLineCB, CB_GETCURSEL, 0, 0),
0);
// Get all the addresses for this line.
for (dwAddr = 0;
dwAddr < g_lpLineInfo [dwLineCBCurrent].dwNumOfAddress; ++dwAddr)
{
wsprintf (szAddrName, TEXT("Address %d"), dwAddr);
// Add the address name string to the list box of the address
// combo box.
dwItem = SendMessage (hwndAddrCB, CB_ADDSTRING, 0,
(LPARAM)szAddrName);
if (dwItem == CB_ERR || dwItem == CB_ERRSPACE)
return FALSE;
// Set the dwAddr associated with the dwItem item.
SendMessage (hwndAddrCB, CB_SETITEMDATA, (WPARAM)dwItem,
(LPARAM)dwAddr);
if (dwLineCBCurrent == dwCurrentLine)
{
if (dwAddr == dwCurrentAddr)
dwCurrentItem = dwItem;
else
{
// If the item we are putting is before the current item, we
// must increment dwItemCur to reflect that an item is being
// placed before it, due to sorting.
if (dwCurrentItem != -1 && dwItem <= dwCurrentItem)
++dwCurrentItem;
}
}
}
if (dwLineCBCurrent != dwCurrentLine || dwCurrentItem == (DWORD)-1)
dwCurrentItem = 0;
// Select the dwCurrentItem item in the list box of the line
// combo box.
if (SendMessage (hwndAddrCB, CB_GETCOUNT, 0, 0) != 0)
{
SendMessage (hwndAddrCB, CB_SETCURSEL, (WPARAM)dwCurrentItem, 0);
return TRUE;
}
return FALSE;
}
/***********************************************************************
FUNCTION:
MakeCanonicalNum
PURPOSE:
Convert phone number to canonical address format.
***********************************************************************/
BOOL MakeCanonicalNum (LPTSTR lpszPhoneNum)
{
int index,
iLength = 0,
iStartPos = 0;
TCHAR szCanPhoneNum[TAPIMAXDESTADDRESSSIZE + 1];
for (index = 0; index < (int) wcslen (lpszPhoneNum); ++index)
{
if (iswdigit (lpszPhoneNum[index]))
{
lpszPhoneNum[iLength] = lpszPhoneNum[index];
iLength += 1;
}
}
// Terminate the string with NULL.
lpszPhoneNum[iLength] = '\0';
// If the phone number length is less than 10, return FALSE.
if (iLength < 10)
{
if (lpszPhoneNum[0] == '1')
{
ErrorBox (TEXT("The first digit can not be")
TEXT("\n1 for a local phone number."));
return FALSE;
}
ErrorBox (TEXT("Invalid phone number.")
TEXT("\nEnter area code for ")
TEXT("\na local phone number."));
return FALSE;
}
else
{
if (iLength == 10)
{
//Make the phone number in the format "+1 (xxx) xxx-xxxx"
wcscpy (szCanPhoneNum, TEXT("+1 "));
szCanPhoneNum[3] = '(';
szCanPhoneNum[4] = lpszPhoneNum[iStartPos];
szCanPhoneNum[5] = lpszPhoneNum[iStartPos + 1];
szCanPhoneNum[6] = lpszPhoneNum[iStartPos + 2];
szCanPhoneNum[7] = ')';
szCanPhoneNum[8] = ' ';
szCanPhoneNum[9] = lpszPhoneNum[iStartPos + 3];
szCanPhoneNum[10] = lpszPhoneNum[iStartPos + 4];
szCanPhoneNum[11] = lpszPhoneNum[iStartPos + 5];
szCanPhoneNum[12] = '-';
szCanPhoneNum[13] = lpszPhoneNum[iStartPos + 6];
szCanPhoneNum[14] = lpszPhoneNum[iStartPos + 7];
szCanPhoneNum[15] = lpszPhoneNum[iStartPos + 8];
szCanPhoneNum[16] = lpszPhoneNum[iStartPos + 9];
szCanPhoneNum[17] = '\0';
// Copy the newly created phone number back to lpszPhoneNum.
wcscpy (lpszPhoneNum, szCanPhoneNum);
return TRUE;
}
}
if (iLength == 11)
if (lpszPhoneNum[0] != '1')
{
ErrorBox (TEXT("The first digit must be a")
TEXT("\n1 for a long distance number."));
return FALSE;
}
else
{
//Make the phone number in the format "+1 (xxx) xxx-xxxx"
szCanPhoneNum[0] = '+';
szCanPhoneNum[1] = lpszPhoneNum[iStartPos];
szCanPhoneNum[2] = ' ';
szCanPhoneNum[3] = '(';
szCanPhoneNum[4] = lpszPhoneNum[iStartPos + 1];
szCanPhoneNum[5] = lpszPhoneNum[iStartPos + 2];
szCanPhoneNum[6] = lpszPhoneNum[iStartPos + 3];
szCanPhoneNum[7] = ')';
szCanPhoneNum[8] = ' ';
szCanPhoneNum[9] = lpszPhoneNum[iStartPos + 4];
szCanPhoneNum[10] = lpszPhoneNum[iStartPos + 5];
szCanPhoneNum[11] = lpszPhoneNum[iStartPos + 6];
szCanPhoneNum[12] = '-';
szCanPhoneNum[13] = lpszPhoneNum[iStartPos + 7];
szCanPhoneNum[14] = lpszPhoneNum[iStartPos + 8];
szCanPhoneNum[15] = lpszPhoneNum[iStartPos + 9];
szCanPhoneNum[16] = lpszPhoneNum[iStartPos + 10];
szCanPhoneNum[17] = '\0';
// Copy the newly created phone number back to lpszPhoneNum.
wcscpy (lpszPhoneNum, szCanPhoneNum);
return TRUE;
}
ErrorBox (TEXT("Invalid phone number, please check")
TEXT("\nthe number and enter again."));
return FALSE;
}
// END CEDIALER.C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -