?? cedialer.c
字號:
DialogBox (g_hInst,
MAKEINTRESOURCE(IDD_CEDIALER),
NULL,
(DLGPROC) DialerDlgProc);
}
return TRUE;
}
/***********************************************************************
FUNCTION:
InitApplication
PURPOSE:
Initialize application.
***********************************************************************/
BOOL InitApplication(
HINSTANCE hInstance
)
{
WNDCLASS wc;
BOOL f;
// Register application main window
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_CEDIALER));
wc.hInstance = hInstance;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH) GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szAppName;
f = (RegisterClass(&wc));
return f;
}
/***********************************************************************
FUNCTION:
WinMain
PURPOSE:
Called by the system as the initial entry point for this Windows
CE-based application.
***********************************************************************/
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow
)
{
HWND hwndCeDialer;
// If CeDialer.exe is running, then give the focus to the window.
hwndCeDialer = FindWindow (g_szAppName, g_szTitle);
if (hwndCeDialer)
{
SetForegroundWindow (hwndCeDialer);
return 0;
}
if ( !InitInstance( hInstance, nCmdShow ) )
{
return (FALSE);
}
return 0;
}
/***********************************************************************
FUNCTION:
lineCallbackFunc
PURPOSE:
This is a callback function invoked to determine status and events on
the line device, addresses, or calls.
***********************************************************************/
VOID CALLBACK lineCallbackFunc (
DWORD hDevice,
DWORD dwMsg,
DWORD dwCallbackInstance,
DWORD dwParam1,
DWORD dwParam2,
DWORD dwParam3
)
{
BOOL bCloseLine = FALSE;
LPTSTR lpszStatus;
lpszStatus = TEXT(" ");
switch (dwMsg)
{
case LINE_CALLSTATE: // Sent after change of call state
// dwParam1 is the specific CALLSTATE change that is occurring.
switch (dwParam1)
{
case LINECALLSTATE_DIALTONE:
lpszStatus = TEXT("Dial tone");
break;
case LINECALLSTATE_DIALING:
lpszStatus = TEXT("Dialing...");
break;
case LINECALLSTATE_PROCEEDING:
lpszStatus = TEXT("Dialing completed, call proceeding.");
break;
case LINECALLSTATE_RINGBACK:
lpszStatus = TEXT("Ring back");
break;
case LINECALLSTATE_CONNECTED:
lpszStatus = TEXT("Connected");
break;
case LINECALLSTATE_BUSY:
lpszStatus = TEXT("Line busy, shutting down.");
bCloseLine = TRUE;
break;
case LINECALLSTATE_IDLE:
lpszStatus = TEXT("Line is idle");
break;
case LINECALLSTATE_SPECIALINFO:
lpszStatus =TEXT("Special Information, couldn't dial number");
bCloseLine = TRUE;
break;
case LINECALLSTATE_DISCONNECTED:
{
LPTSTR lpszDisconnected;
lpszDisconnected = TEXT(" ");
switch (dwParam2)
{
case LINEDISCONNECTMODE_NORMAL:
lpszDisconnected = TEXT("Remote party disconnected");
break;
case LINEDISCONNECTMODE_UNKNOWN:
lpszDisconnected = TEXT("Disconnected: Unknown reason");
break;
case LINEDISCONNECTMODE_REJECT:
lpszDisconnected = TEXT("Remote Party rejected call");
break;
case LINEDISCONNECTMODE_PICKUP:
lpszDisconnected =
TEXT("Disconnected: Local phone picked up");
break;
case LINEDISCONNECTMODE_FORWARDED:
lpszDisconnected = TEXT("Disconnected: Forwarded");
break;
case LINEDISCONNECTMODE_BUSY:
lpszDisconnected = TEXT("Disconnected: Busy");
break;
case LINEDISCONNECTMODE_NOANSWER:
lpszDisconnected = TEXT("Disconnected: No Answer");
break;
case LINEDISCONNECTMODE_BADADDRESS:
lpszDisconnected = TEXT("Disconnected: Bad address");
break;
case LINEDISCONNECTMODE_UNREACHABLE:
lpszDisconnected = TEXT("Disconnected: Unreachable");
break;
case LINEDISCONNECTMODE_CONGESTION:
lpszDisconnected = TEXT("Disconnected: Congestion");
break;
case LINEDISCONNECTMODE_INCOMPATIBLE:
lpszDisconnected = TEXT("Disconnected: Incompatible");
break;
case LINEDISCONNECTMODE_UNAVAIL:
lpszDisconnected = TEXT("Disconnected: Unavailable");
break;
case LINEDISCONNECTMODE_NODIALTONE:
lpszDisconnected = TEXT("Disconnected: No dial tone");
break;
default:
lpszDisconnected = TEXT("Disconnected: Unknown reason");
break;
} // end switch (dwParam2)
bCloseLine = TRUE;
lpszStatus = lpszDisconnected;
break;
} // end case LINECALLSTATE_DISCONNECTED:
} // end switch (dwParam1)
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE, WM_SETTEXT,
0,(LPARAM)lpszStatus);
if (bCloseLine)
{
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
}
break;
case LINE_LINEDEVSTATE:
switch (dwParam1)
{
case LINEDEVSTATE_RINGING:
lpszStatus = TEXT("Ringing");
break;
case LINEDEVSTATE_OUTOFSERVICE:
lpszStatus = TEXT("The line selected is out of service.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_DISCONNECTED:
lpszStatus = TEXT("The line selected is disconnected.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_MAINTENANCE:
lpszStatus = TEXT("The line selected is out for maintenance.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT,0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
break;
case LINEDEVSTATE_TRANSLATECHANGE:
break;
case LINEDEVSTATE_REMOVED:
ErrorBox (
TEXT("The Line device has been removed; no action taken."));
break;
case LINEDEVSTATE_REINIT:
{
// This usually means that a service provider has changed in
// such a way that requires TAPI to REINIT. Note that there
// are both soft REINITs and hard REINITs. Soft REINITs do not
// require a full shutdown but an informational change that
// historically required a REINIT to force the application to
// deal with. TAPI API Version 1.3 applications require a
// full REINIT for both hard and soft REINITs.
switch(dwParam2)
{
// This is the hard REINIT. TAPI is waiting for everyone to
// shut down. Our response is to immediately shut down any
// calls, shut down our use of TAPI and notify the user.
case 0:
if (MessageBox (
g_hwndMain,
TEXT("Tapi line configuration has been changed. ")
TEXT("You have to shut down CeDialer to\n")
TEXT("re-initialize the use of tapi.dll. Do ")
TEXT("you want to shut down CeDialer now?"),
TEXT("Warning"),
MB_YESNO) == IDYES)
{
lineShutdown (g_hLineApp);
DestroyWindow (g_hwndMain);
}
break;
case LINE_CREATE:
lineCallbackFunc (hDevice, dwParam2, dwCallbackInstance,
dwParam3, 0, 0);
break;
case LINE_LINEDEVSTATE:
lineCallbackFunc (hDevice, dwParam2, dwCallbackInstance,
dwParam3, 0, 0);
break;
// There might be other reasons to send a soft REINIT.
// No need to shut down for these reasons.
default:
break;
}
}
default:
break;
}
break;
case LINE_REPLY:
// Reply from the lineMakeCall function.
if ((LONG)dwParam1 == g_MakeCallRequestID)
{
// If an error occurred on making the call.
if (dwParam2 != ERR_NONE)
{
lpszStatus = TEXT("Closing line");
if (dwParam2 == LINEERR_CALLUNAVAIL)
lpszStatus = TEXT("The line is not available.");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT, 0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
}
}
break;
case LINE_CREATE:
// dwParam1 is the device identifier of the new line.
if (dwParam1 >= g_dwNumDevs)
{
DWORD dwLineID;
LINEINFO *lpLineInfo;
g_dwNumDevs = dwParam1 + 1;
// Allocate a buffer for storing LINEINFO for all the lines.
if (!(lpLineInfo = (LPLINEINFO) LocalAlloc (
LPTR,
sizeof (LINEINFO) * g_dwNumDevs)))
{
break;
}
// Assume we just add a new line, the lines are sequential and
// the new line is the last one.
for (dwLineID = 0; dwLineID < dwParam1; ++dwLineID)
{
lpLineInfo[dwLineID] = g_lpLineInfo[dwLineID];
}
// Get the new line information.
GetLineInfo (dwParam1, &lpLineInfo[dwParam1]);
LocalFree (g_lpLineInfo);
g_lpLineInfo = lpLineInfo;
}
break;
case LINE_CLOSE:
if (g_CurrentLineInfo.hLine == (HLINE) hDevice)
{
lpszStatus = TEXT("Closing line");
if (g_hwndDial)
SendDlgItemMessage(g_hwndDial, IDC_STATUSMESSAGE,
WM_SETTEXT, 0,(LPARAM)lpszStatus);
CurrentLineClose ();
if (g_hwndDial)
SendMessage (g_hwndDial, WM_COMMAND, MAKEWPARAM(IDOK,0), 0);
}
break;
case LINE_ADDRESSSTATE:
case LINE_CALLINFO:
case LINE_DEVSPECIFIC:
case LINE_DEVSPECIFICFEATURE:
case LINE_GATHERDIGITS:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -