TAPITELDlg.cpp
上传用户:c12836
上传日期:2020-02-05
资源大小:26k
文件大小:6k
源码类别:

TAPI编程

开发平台:

Visual C++

  1. // TAPITELDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TAPITEL.h"
  5. #include "TAPITELDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAboutDlg dialog used for App About
  13. class CAboutDlg : public CDialog
  14. {
  15. public:
  16. CAboutDlg();
  17. // Dialog Data
  18. //{{AFX_DATA(CAboutDlg)
  19. enum { IDD = IDD_ABOUTBOX };
  20. //}}AFX_DATA
  21. // ClassWizard generated virtual function overrides
  22. //{{AFX_VIRTUAL(CAboutDlg)
  23. protected:
  24. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  25. //}}AFX_VIRTUAL
  26. // Implementation
  27. protected:
  28. //{{AFX_MSG(CAboutDlg)
  29. //}}AFX_MSG
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CAboutDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAboutDlg)
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  44. //{{AFX_MSG_MAP(CAboutDlg)
  45. // No message handlers
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CTAPITELDlg dialog
  50. CTAPITELDlg::CTAPITELDlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CTAPITELDlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CTAPITELDlg)
  54. // NOTE: the ClassWizard will add member initialization here
  55. //}}AFX_DATA_INIT
  56. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CTAPITELDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CTAPITELDlg)
  63. DDX_Control(pDX, IDC_LINELIST, m_linelist);
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CTAPITELDlg, CDialog)
  67. //{{AFX_MSG_MAP(CTAPITELDlg)
  68. ON_WM_SYSCOMMAND()
  69. ON_WM_PAINT()
  70. ON_WM_QUERYDRAGICON()
  71. ON_LBN_DBLCLK(IDC_LINELIST, OnDblclkLinelist)
  72. ON_BN_CLICKED(IDC_BTDIAL, OnDial)
  73. ON_BN_CLICKED(IDC_BTDROP, OnDrop)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CTAPITELDlg message handlers
  78. BOOL CTAPITELDlg::OnInitDialog()
  79. {
  80. CDialog::OnInitDialog();
  81. // Add "About..." menu item to system menu.
  82. // IDM_ABOUTBOX must be in the system command range.
  83. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  84. ASSERT(IDM_ABOUTBOX < 0xF000);
  85. CMenu* pSysMenu = GetSystemMenu(FALSE);
  86. if (pSysMenu != NULL)
  87. {
  88. CString strAboutMenu;
  89. strAboutMenu.LoadString(IDS_ABOUTBOX);
  90. if (!strAboutMenu.IsEmpty())
  91. {
  92. pSysMenu->AppendMenu(MF_SEPARATOR);
  93. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  94. }
  95. }
  96. // Set the icon for this dialog.  The framework does this automatically
  97. //  when the application's main window is not a dialog
  98. SetIcon(m_hIcon, TRUE); // Set big icon
  99. SetIcon(m_hIcon, FALSE); // Set small icon
  100. LONG lResult;
  101. LINEINITIALIZEEXPARAMS exparams;
  102. LPLINEAGENTCAPS pLAC;
  103. //LPLINEDEVCAPS pLDC;
  104. DWORD dwDeviceID,dwNumDevs,dwAPIVersion, dwThreadID;
  105. exparams.dwTotalSize=sizeof(LINEINITIALIZEEXPARAMS);
  106. exparams.dwOptions=LINEINITIALIZEEXOPTION_USECOMPLETIONPORT;
  107. exparams.Handles.hCompletionPort=ghCompletionPort;
  108. lResult=lineInitializeEx(&ghLineApp,::AfxGetApp()->m_hInstance,NULL,"mrtapi",
  109. &dwNumDevs,&dwAPIVersion,&exparams);
  110. if (dwNumDevs==0)     
  111. {lineShutdown(ghLineApp);
  112. return FALSE;}
  113. for(DWORD i=0;i<dwNumDevs;i++)
  114. {
  115. //pLAC=LineGetAgentCaps(ghLineApp,i,0);
  116. //pLDC=LineGetDevCaps(ghLineApp,i);
  117. LINEDEVCAPS *pLineDevCaps;
  118. static DWORD dwMaxNeededSize=sizeof(LINEDEVCAPS);
  119. pLineDevCaps=(LINEDEVCAPS*)GlobalAlloc(GPTR,dwMaxNeededSize);
  120. pLineDevCaps->dwTotalSize=dwMaxNeededSize;
  121. lineGetDevCaps(ghLineApp,i,TAPI_CURRENT_VERSION,0,pLineDevCaps);
  122. dwMaxNeededSize=pLineDevCaps->dwNeededSize;
  123. pLineDevCaps=(LINEDEVCAPS*)GlobalReAlloc((HLOCAL)pLineDevCaps,dwMaxNeededSize,GMEM_MOVEABLE);
  124. //if(pLineDevCaps->dwBearerModes==LINEBEARERMODE_VOICE)
  125. //if(pLineDevCaps->dwMediaModes==LINEMEDIAMODE_INTERACTIVEVOICE)
  126. m_linelist.AddString(((LPTSTR)((LPBYTE)pLineDevCaps+pLineDevCaps->dwLineNameOffset)));
  127. }
  128. return TRUE;  // return TRUE  unless you set the focus to a control
  129. }
  130. void CTAPITELDlg::OnSysCommand(UINT nID, LPARAM lParam)
  131. {
  132. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  133. {
  134. CAboutDlg dlgAbout;
  135. dlgAbout.DoModal();
  136. }
  137. else
  138. {
  139. CDialog::OnSysCommand(nID, lParam);
  140. }
  141. }
  142. // If you add a minimize button to your dialog, you will need the code below
  143. //  to draw the icon.  For MFC applications using the document/view model,
  144. //  this is automatically done for you by the framework.
  145. void CTAPITELDlg::OnPaint() 
  146. {
  147. if (IsIconic())
  148. {
  149. CPaintDC dc(this); // device context for painting
  150. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  151. // Center icon in client rectangle
  152. int cxIcon = GetSystemMetrics(SM_CXICON);
  153. int cyIcon = GetSystemMetrics(SM_CYICON);
  154. CRect rect;
  155. GetClientRect(&rect);
  156. int x = (rect.Width() - cxIcon + 1) / 2;
  157. int y = (rect.Height() - cyIcon + 1) / 2;
  158. // Draw the icon
  159. dc.DrawIcon(x, y, m_hIcon);
  160. }
  161. else
  162. {
  163. CDialog::OnPaint();
  164. }
  165. }
  166. // The system calls this to obtain the cursor to display while the user drags
  167. //  the minimized window.
  168. HCURSOR CTAPITELDlg::OnQueryDragIcon()
  169. {
  170. return (HCURSOR) m_hIcon;
  171. }
  172. void CTAPITELDlg::OnDblclkLinelist() 
  173. {
  174. int i=m_linelist.GetCurSel();
  175. lineOpen(ghLineApp,i,&ghLine,TAPI_CURRENT_VERSION,
  176. 0,0,LINECALLPRIVILEGE_OWNER,LINEMEDIAMODE_INTERACTIVEVOICE,NULL);
  177. ::lineConfigDialog(i,this->GetSafeHwnd(),NULL);
  178. lineShutdown(ghLineApp);
  179. }
  180. void CTAPITELDlg::OnDial() 
  181. {
  182. CString number;
  183. GetDlgItem(IDC_EDTELNUM)->GetWindowText(number);
  184. int i=m_linelist.GetCurSel();
  185. lineOpen(ghLineApp,i,&ghLine,TAPI_CURRENT_VERSION,
  186. 0,0,LINECALLPRIVILEGE_OWNER,LINEMEDIAMODE_INTERACTIVEVOICE,NULL);
  187. ::lineMakeCall(ghLine,&call,number,0,0);
  188. }
  189. void CTAPITELDlg::OnDrop() 
  190. {
  191. lineDrop(call,NULL,0);
  192. }