Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

826 lines
21 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : DlgNewDevice.cpp //
  3. // //
  4. // DESCRIPTION : The CDlgNewFaxOutboundDevice class implements the //
  5. // dialog for additon of new Group. //
  6. // //
  7. // AUTHOR : yossg //
  8. // //
  9. // HISTORY : //
  10. // Jan 3 2000 yossg Create //
  11. // //
  12. // Copyright (C) 2000 Microsoft Corporation All Rights Reserved //
  13. /////////////////////////////////////////////////////////////////////////////
  14. #include "StdAfx.h"
  15. #include "dlgNewDevice.h"
  16. #include "FaxServer.h"
  17. #include "FaxServerNode.h"
  18. #include "dlgutils.h"
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CDlgNewFaxOutboundDevice
  21. CDlgNewFaxOutboundDevice::CDlgNewFaxOutboundDevice(CFaxServer * pFaxServer)
  22. {
  23. m_lpdwAllDeviceID = NULL;
  24. m_dwNumOfAllDevices = 0;
  25. m_lpdwAssignedDeviceID = NULL;
  26. m_dwNumOfAssignedDevices = 0;
  27. ATLASSERT(pFaxServer);
  28. m_pFaxServer = pFaxServer;
  29. }
  30. CDlgNewFaxOutboundDevice::~CDlgNewFaxOutboundDevice()
  31. {
  32. if (NULL != m_lpdwAllDeviceID)
  33. delete[] m_lpdwAllDeviceID;
  34. if (NULL != m_lpdwAssignedDeviceID)
  35. delete[] m_lpdwAssignedDeviceID;
  36. }
  37. /*
  38. - CDlgNewFaxOutboundDevice::initDevices
  39. -
  40. * Purpose:
  41. * Initiates the configuration structure from RPC get Call,
  42. * and current assined devices own parameters
  43. *
  44. * Arguments:
  45. *
  46. * Return:
  47. * OLE error code
  48. */
  49. HRESULT CDlgNewFaxOutboundDevice::InitDevices(DWORD dwNumOfDevices, LPDWORD lpdwDeviceID, BSTR bstrGroupName)
  50. {
  51. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::InitDevices"));
  52. HRESULT hRc = S_OK;
  53. m_bstrGroupName = bstrGroupName;
  54. if (!m_bstrGroupName )
  55. {
  56. DebugPrintEx(DEBUG_ERR,
  57. _T("Out of memory - Failed to Init m_bstrGroupName. (ec: %0X8)"), hRc);
  58. //MsgBox by Caller Function
  59. hRc = E_OUTOFMEMORY;
  60. goto Exit;
  61. }
  62. hRc = InitAssignedDevices(dwNumOfDevices, lpdwDeviceID);
  63. if (FAILED(hRc))
  64. {
  65. DebugPrintEx(DEBUG_ERR,
  66. _T("Failed to InitAssignDevices. (ec: %0X8)"), hRc);
  67. //MsgBox by Caller Function
  68. goto Exit;
  69. }
  70. hRc = InitAllDevices( );
  71. if (FAILED(hRc))
  72. {
  73. DebugPrintEx(DEBUG_ERR,
  74. _T("Failed to InitRPC. (ec: %0X8)"), hRc);
  75. //MsgBox by Caller Function
  76. goto Exit;
  77. }
  78. if ( m_dwNumOfAllDevices < m_dwNumOfAssignedDevices)
  79. {
  80. DebugPrintEx(DEBUG_MSG,
  81. _T("+++m_dwNumOfAllDevices <m_dwNumOfAssignedDevices.+++ (ec: %0X8)"), hRc);
  82. hRc = E_UNEXPECTED;
  83. //MsgBox by Caller Function
  84. goto Exit;
  85. }
  86. ATLASSERT(S_OK == hRc);
  87. Exit:
  88. return hRc;
  89. }
  90. /*
  91. - CDlgNewFaxOutboundDevice::initAllDevices
  92. -
  93. * Purpose:
  94. * Initiates the configuration structure from RPC get Call.
  95. *
  96. * Arguments:
  97. *
  98. * Return:
  99. * OLE error code
  100. */
  101. HRESULT CDlgNewFaxOutboundDevice::InitAllDevices( )
  102. {
  103. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::InitAllDevices"));
  104. HRESULT hRc = S_OK;
  105. DWORD ec = ERROR_SUCCESS;
  106. PFAX_OUTBOUND_ROUTING_GROUP pFaxGroupsConfig;
  107. DWORD dwNumOfGroups;
  108. DWORD i; //index
  109. BOOL fFound = FALSE;
  110. //
  111. // get Fax Handle
  112. //
  113. if (!m_pFaxServer->GetFaxServerHandle())
  114. {
  115. ec= GetLastError();
  116. DebugPrintEx(
  117. DEBUG_ERR,
  118. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  119. ec);
  120. goto Error;
  121. }
  122. //
  123. // Retrieve the Outbound Groups configuration
  124. //
  125. if (!FaxEnumOutboundGroups(m_pFaxServer->GetFaxServerHandle(),
  126. &pFaxGroupsConfig,
  127. &dwNumOfGroups))
  128. {
  129. ec = GetLastError();
  130. DebugPrintEx(
  131. DEBUG_ERR,
  132. _T("Fail to get groups configuration. (ec: %ld)"),
  133. ec);
  134. if (IsNetworkError(ec))
  135. {
  136. DebugPrintEx(
  137. DEBUG_ERR,
  138. _T("Network Error was found. (ec: %ld)"),
  139. ec);
  140. m_pFaxServer->Disconnect();
  141. }
  142. goto Error;
  143. }
  144. //For max verification
  145. ATLASSERT(pFaxGroupsConfig);
  146. for ( i =0; i < dwNumOfGroups; i++ )
  147. {
  148. ATLASSERT(NULL != pFaxGroupsConfig);
  149. if(0 == wcscmp(ROUTING_GROUP_ALL_DEVICES, pFaxGroupsConfig->lpctstrGroupName) )
  150. {
  151. fFound = TRUE;
  152. }
  153. else
  154. {
  155. pFaxGroupsConfig++;
  156. }
  157. }
  158. if(fFound)
  159. {
  160. //
  161. // init m_dwNumOfAllDevices
  162. //
  163. m_dwNumOfAllDevices = pFaxGroupsConfig->dwNumDevices;
  164. //
  165. // init m_lpdwAllDeviceID
  166. //
  167. if (0 < m_dwNumOfAllDevices)
  168. {
  169. m_lpdwAllDeviceID = new DWORD[m_dwNumOfAllDevices];
  170. if (NULL == m_lpdwAllDeviceID)
  171. {
  172. DebugPrintEx(
  173. DEBUG_ERR,
  174. _T("Error allocating %ld device ids"),
  175. m_dwNumOfAllDevices);
  176. ec = ERROR_NOT_ENOUGH_MEMORY;
  177. goto Error;
  178. }
  179. memcpy(m_lpdwAllDeviceID, pFaxGroupsConfig->lpdwDevices, sizeof(DWORD)*m_dwNumOfAllDevices) ;
  180. }
  181. else
  182. {
  183. DebugPrintEx( DEBUG_MSG, _T("++Empty List++ List of All Devices found to be currrently empty."));
  184. m_lpdwAllDeviceID = NULL;
  185. }
  186. }
  187. else
  188. {
  189. DebugPrintEx(
  190. DEBUG_ERR,
  191. _T("UNEXPECTED ERROR - ALL DEVICES group was not found."));
  192. ec = ERROR_BAD_UNIT;
  193. goto Error;
  194. }
  195. ATLASSERT(S_OK == hRc);
  196. DebugPrintEx( DEBUG_MSG,
  197. _T("Succeed to init all devices list."));
  198. goto Exit;
  199. Error:
  200. ATLASSERT(ERROR_SUCCESS != ec);
  201. hRc = HRESULT_FROM_WIN32(ec);
  202. //DlgMsgBox -- NodeMsgBox(GetFaxServerErrorMsg(ec));
  203. Exit:
  204. return (hRc);
  205. }
  206. /*
  207. - CDlgNewFaxOutboundDevice::initAssignedDevices
  208. -
  209. * Purpose:
  210. * Initiates the list from given params.
  211. *
  212. * Arguments:
  213. *
  214. * Return:
  215. * OLE error code
  216. */
  217. HRESULT CDlgNewFaxOutboundDevice::InitAssignedDevices(DWORD dwNumOfDevices, LPDWORD lpdwDeviceID)
  218. {
  219. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::InitAssignedDevices"));
  220. HRESULT hRc = S_OK;
  221. //
  222. // init m_dwNumOfAssignedDevices
  223. //
  224. m_dwNumOfAssignedDevices = dwNumOfDevices;
  225. //
  226. // init m_lpdwAssignedDeviceID
  227. //
  228. if (0 < m_dwNumOfAssignedDevices)
  229. {
  230. m_lpdwAssignedDeviceID = new DWORD[m_dwNumOfAssignedDevices];
  231. if (NULL == m_lpdwAssignedDeviceID)
  232. {
  233. DebugPrintEx(
  234. DEBUG_ERR,
  235. _T("Error allocating %ld device ids"),
  236. m_dwNumOfAssignedDevices);
  237. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  238. }
  239. memcpy(m_lpdwAssignedDeviceID, lpdwDeviceID, sizeof(DWORD)*m_dwNumOfAssignedDevices) ;
  240. }
  241. else
  242. {
  243. DebugPrintEx( DEBUG_MSG, _T("List of Assigned devices found to be empty."));
  244. m_lpdwAssignedDeviceID = NULL;
  245. }
  246. return hRc;
  247. }
  248. /*
  249. + CDlgNewFaxOutboundDevice::OnInitDialog
  250. +
  251. * Purpose:
  252. * Initiate all dialog controls.
  253. *
  254. * Arguments:
  255. * [in] uMsg : Value identifying the event.
  256. * [in] lParam : Message-specific value.
  257. * [in] wParam : Message-specific value.
  258. * [in] bHandled : bool value.
  259. *
  260. - Return:
  261. - 0 or 1
  262. */
  263. LRESULT
  264. CDlgNewFaxOutboundDevice::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  265. {
  266. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::OnInitDialog"));
  267. HRESULT hRc = S_OK;
  268. BOOL fAssignedDeviceFound;
  269. BOOL fAllAssignedDevicesFound;
  270. LPDWORD lpdwDevice;
  271. LPDWORD lpdwAssignedDevice;
  272. DWORD tmp;
  273. UINT uiFoundIndex;
  274. RECT Rect;
  275. //
  276. // Attach controls
  277. //
  278. m_DeviceList.Attach(GetDlgItem(IDC_DEVICE_LISTVIEW));
  279. m_DeviceList.GetClientRect(&Rect);
  280. m_DeviceList.InsertColumn(1, NULL, LVCFMT_LEFT, (Rect.right-Rect.left), 0);
  281. //
  282. // Fill the Availble Device List
  283. //
  284. fAllAssignedDevicesFound = FALSE;
  285. uiFoundIndex = 0;
  286. lpdwDevice = &m_lpdwAllDeviceID[0];
  287. for ( DWORD i = 0; i < m_dwNumOfAllDevices; i++ )
  288. {
  289. if(!fAllAssignedDevicesFound)
  290. {
  291. fAssignedDeviceFound =FALSE;
  292. lpdwAssignedDevice = &m_lpdwAssignedDeviceID[0];
  293. tmp =0;
  294. for ( DWORD j = 0; j < m_dwNumOfAssignedDevices; j++ )
  295. {
  296. // TO DO create more incremental search here also
  297. ATLASSERT(NULL != lpdwDevice);
  298. ATLASSERT(NULL != lpdwAssignedDevice);
  299. if( *lpdwDevice == *lpdwAssignedDevice )
  300. {
  301. fAssignedDeviceFound = TRUE;
  302. //Skip this device - It was already assigned
  303. lpdwDevice++;
  304. if ( ++tmp == m_dwNumOfAssignedDevices )
  305. fAllAssignedDevicesFound = TRUE;
  306. break;
  307. }
  308. else
  309. {
  310. lpdwAssignedDevice++;
  311. }
  312. }
  313. if (!fAssignedDeviceFound)
  314. {
  315. InsertDeviceToList(uiFoundIndex++ , *lpdwDevice);
  316. lpdwDevice++;
  317. }
  318. }
  319. else //all assigned devices found
  320. {
  321. ATLASSERT(lpdwDevice);
  322. //insert the rest of all devices to list
  323. InsertDeviceToList(uiFoundIndex++ , *lpdwDevice);
  324. lpdwDevice++;
  325. }
  326. }
  327. EnableOK(FALSE);
  328. return 1; // Let the system set the focus
  329. }
  330. /*
  331. - CDlgNewFaxOutboundDevice::InsertDeviceToList
  332. -
  333. * Purpose:
  334. * Populate Avaliable devices list and discovers the devices names
  335. *
  336. * Arguments:
  337. * [in] uiIndex - index
  338. * [in] dwDeviceID - device ID
  339. *
  340. * Return:
  341. * OLE error code
  342. */
  343. HRESULT CDlgNewFaxOutboundDevice::InsertDeviceToList(UINT uiIndex, DWORD dwDeviceID)
  344. {
  345. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::InsertDeviceToList"));
  346. HRESULT hRc = S_OK;
  347. CComBSTR bstrDeviceName = NULL;
  348. //
  349. // Discover Device Name
  350. //
  351. hRc = InitDeviceNameFromID(dwDeviceID, &bstrDeviceName);
  352. if (FAILED(hRc))
  353. {
  354. //DebugPrint by Called Func.
  355. goto Exit;
  356. }
  357. //
  358. // Insert New line in the list
  359. //
  360. m_DeviceList.InsertItem(uiIndex, bstrDeviceName);
  361. m_DeviceList.SetItemData(uiIndex, dwDeviceID);
  362. Exit:
  363. return hRc;
  364. }
  365. /*
  366. - CDlgNewFaxOutboundDevice::InitDeviceNameFromID
  367. -
  368. * Purpose:
  369. * Transslate Device ID to Device Name and insert the data to
  370. * m_bstrDeviceName
  371. *
  372. * Arguments:
  373. * [in] dwDeviceID - device ID
  374. * [out] bstrDeviceName - device Name
  375. *
  376. * Return:
  377. * OLE error message
  378. */
  379. HRESULT CDlgNewFaxOutboundDevice::InitDeviceNameFromID(DWORD dwDeviceID, BSTR * pbstrDeviceName)
  380. {
  381. DEBUG_FUNCTION_NAME( _T("CFaxOutboundRoutingRuleNode::GetDeviceNameFromID"));
  382. DWORD ec = ERROR_SUCCESS;
  383. HRESULT hRc = S_OK;
  384. PFAX_PORT_INFO_EX pFaxDeviceConfig = NULL ;
  385. if (!m_pFaxServer->GetFaxServerHandle())
  386. {
  387. ec= GetLastError();
  388. DebugPrintEx(
  389. DEBUG_ERR,
  390. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  391. ec);
  392. goto Error;
  393. }
  394. //
  395. // Retrieve the Device configuration
  396. //
  397. if (!FaxGetPortEx(m_pFaxServer->GetFaxServerHandle(),
  398. dwDeviceID,
  399. &pFaxDeviceConfig))
  400. {
  401. ec = GetLastError();
  402. DebugPrintEx(
  403. DEBUG_ERR,
  404. _T("Fail to get device configuration. (ec: %ld)"),
  405. ec);
  406. if (IsNetworkError(ec))
  407. {
  408. DebugPrintEx(
  409. DEBUG_ERR,
  410. _T("Network Error was found. (ec: %ld)"),
  411. ec);
  412. m_pFaxServer->Disconnect();
  413. }
  414. goto Error;
  415. }
  416. //For max verification
  417. ATLASSERT(pFaxDeviceConfig);
  418. //
  419. // Main thing - retrieve the Device Name
  420. //
  421. *pbstrDeviceName = SysAllocString(pFaxDeviceConfig->lpctstrDeviceName);
  422. if ( !(*pbstrDeviceName) )
  423. {
  424. ec = ERROR_NOT_ENOUGH_MEMORY;
  425. goto Error;
  426. }
  427. ATLASSERT(ec == ERROR_SUCCESS);
  428. DebugPrintEx( DEBUG_MSG,
  429. _T("Succeed to get device name."));
  430. goto Exit;
  431. Error:
  432. ATLASSERT(ERROR_SUCCESS != ec);
  433. pFaxDeviceConfig = NULL;
  434. if (ERROR_BAD_UNIT != ec)
  435. {
  436. DebugPrintEx(
  437. DEBUG_ERR,
  438. TEXT("Device Not Found - Fail to discover device name from device ID."));
  439. }
  440. else
  441. {
  442. DebugPrintEx(
  443. DEBUG_ERR,
  444. TEXT("Fail to discover device name from device ID. (ec: %ld)"),
  445. ec);
  446. }
  447. hRc = HRESULT_FROM_WIN32(ec);
  448. Exit:
  449. if (NULL != pFaxDeviceConfig)
  450. {
  451. FaxFreeBuffer(pFaxDeviceConfig);
  452. }
  453. return hRc;
  454. }
  455. /*
  456. + CDlgNewFaxOutboundDevice::OnOK
  457. +
  458. * Purpose:
  459. * Initiate all dialog controls.
  460. *
  461. * Arguments:
  462. * [in] uMsg : Value identifying the event.
  463. * [in] lParam : Message-specific value.
  464. * [in] wParam : Message-specific value.
  465. * [in] bHandled : bool value.
  466. *
  467. - Return:
  468. - 0 or 1
  469. */
  470. LRESULT
  471. CDlgNewFaxOutboundDevice::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  472. {
  473. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::OnOK"));
  474. HRESULT hRc = S_OK;
  475. DWORD ec = ERROR_SUCCESS;
  476. DWORD dwIndex;
  477. UINT uiSelectedCount;
  478. int nItem;
  479. LPDWORD lpdwNewDeviceID;
  480. LPDWORD lpdwTmp;
  481. FAX_OUTBOUND_ROUTING_GROUP FaxGroupConfig;
  482. //
  483. // Step 1: Create the new devices combined list
  484. //
  485. ATLASSERT( m_DeviceList.GetSelectedCount() > 0);
  486. ATLASSERT( m_dwNumOfAssignedDevices >= 0);
  487. uiSelectedCount = m_DeviceList.GetSelectedCount();
  488. m_dwNumOfAllAssignedDevices = (DWORD)uiSelectedCount
  489. + m_dwNumOfAssignedDevices;
  490. lpdwNewDeviceID = new DWORD[m_dwNumOfAllAssignedDevices];
  491. if (NULL == lpdwNewDeviceID)
  492. {
  493. DebugPrintEx(
  494. DEBUG_ERR,
  495. _T("Error allocating %ld device ids"),
  496. m_dwNumOfAllAssignedDevices);
  497. ec = ERROR_NOT_ENOUGH_MEMORY;
  498. goto Error;
  499. }
  500. lpdwTmp = &lpdwNewDeviceID[0];
  501. DebugPrintEx( DEBUG_MSG,
  502. _T(" NumOfAllAssignedDevices = %ld \n"), m_dwNumOfAllAssignedDevices);
  503. //
  504. // Already assigned part (can be zero size)
  505. //
  506. if (m_dwNumOfAssignedDevices > 0)
  507. {
  508. memcpy( lpdwNewDeviceID, m_lpdwAssignedDeviceID, sizeof(DWORD)*m_dwNumOfAssignedDevices) ;
  509. lpdwTmp = lpdwTmp + (int)m_dwNumOfAssignedDevices;
  510. }
  511. //
  512. // New devices to assign part (cannot be zero size)
  513. //
  514. if (uiSelectedCount > 0)
  515. {
  516. nItem = -1;
  517. for (dwIndex = m_dwNumOfAssignedDevices; dwIndex < m_dwNumOfAllAssignedDevices; dwIndex++)
  518. {
  519. nItem = m_DeviceList.GetNextItem(nItem, LVNI_SELECTED);
  520. ATLASSERT(nItem != -1);
  521. *lpdwTmp = (DWORD)m_DeviceList.GetItemData(nItem);
  522. DebugPrintEx( DEBUG_MSG,
  523. _T(" NewDeviceID = %ld. DeviceOrder=%ld \n"), *lpdwTmp, (dwIndex+1));
  524. ++lpdwTmp;
  525. }
  526. }
  527. else
  528. {
  529. ATLASSERT(0); //Never reach here
  530. DlgMsgBox(this, IDS_SELECT_ITEM);
  531. return 0;
  532. }
  533. //
  534. // Step 2: insert the new Id list into the group via RPC call
  535. //
  536. //
  537. // init the group fields and insert the new DeviceIdList
  538. //
  539. ZeroMemory (&FaxGroupConfig, sizeof(FAX_OUTBOUND_ROUTING_GROUP));
  540. FaxGroupConfig.dwSizeOfStruct = sizeof(FAX_OUTBOUND_ROUTING_GROUP);
  541. FaxGroupConfig.lpctstrGroupName = m_bstrGroupName;
  542. FaxGroupConfig.dwNumDevices = m_dwNumOfAllAssignedDevices;
  543. //FaxGroupConfig.Status - actually neglected by the service
  544. FaxGroupConfig.Status = FAX_GROUP_STATUS_ALL_DEV_VALID;
  545. FaxGroupConfig.lpdwDevices = lpdwNewDeviceID;
  546. //
  547. // get RPC Handle
  548. //
  549. if (!m_pFaxServer->GetFaxServerHandle())
  550. {
  551. ec= GetLastError();
  552. DebugPrintEx(
  553. DEBUG_ERR,
  554. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  555. ec);
  556. goto Error;
  557. }
  558. //
  559. // inject the new device list
  560. //
  561. if (!FaxSetOutboundGroup(
  562. m_pFaxServer->GetFaxServerHandle(),
  563. &FaxGroupConfig))
  564. {
  565. ec = GetLastError();
  566. DebugPrintEx(
  567. DEBUG_ERR,
  568. _T("Fail to set the group with new device list. (ec: %ld)"),
  569. ec);
  570. if (IsNetworkError(ec))
  571. {
  572. DebugPrintEx(
  573. DEBUG_ERR,
  574. _T("Network Error was found. (ec: %ld)"),
  575. ec);
  576. m_pFaxServer->Disconnect();
  577. }
  578. goto Error;
  579. }
  580. //
  581. // Step 3: Close the dialog
  582. //
  583. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  584. DebugPrintEx( DEBUG_MSG,
  585. _T("The group was added successfully."));
  586. EndDialog(wID);
  587. goto Exit;
  588. Error:
  589. ATLASSERT(ERROR_SUCCESS != ec);
  590. hRc = HRESULT_FROM_WIN32(ec);
  591. PageErrorEx(IDS_FAIL_ADD_DEVICE, GetFaxServerErrorMsg(ec), m_hWnd);
  592. EnableOK(FALSE);
  593. Exit:
  594. return FAILED(hRc) ? 0 : 1;
  595. }
  596. /*
  597. - CDlgNewFaxOutboundDevice::OnListViewItemChanged
  598. -
  599. * Purpose:
  600. * Enable/Disable the submit button.
  601. *
  602. * Arguments:
  603. *
  604. * Return:
  605. * 1
  606. */
  607. LRESULT
  608. CDlgNewFaxOutboundDevice::OnListViewItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  609. {
  610. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::OnListViewItemChanged"));
  611. EnableOK( m_DeviceList.GetSelectedCount() > 0 );
  612. return 0;
  613. }
  614. /*
  615. - CDlgNewFaxOutboundDevice::EnableOK
  616. -
  617. * Purpose:
  618. * Enable (disable) apply button.
  619. *
  620. * Arguments:
  621. * [in] fEnable - the value to enable the button
  622. *
  623. * Return:
  624. * void
  625. */
  626. VOID
  627. CDlgNewFaxOutboundDevice::EnableOK(BOOL fEnable)
  628. {
  629. HWND hwndOK = GetDlgItem(IDOK);
  630. ::EnableWindow(hwndOK, fEnable);
  631. }
  632. /*
  633. - CDlgNewFaxOutboundDevice::OnCancel
  634. -
  635. * Purpose:
  636. * End dialog OnCancel.
  637. *
  638. * Arguments:
  639. *
  640. * Return:
  641. * 0
  642. */
  643. LRESULT
  644. CDlgNewFaxOutboundDevice::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  645. {
  646. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundDevice::OnCancel"));
  647. EndDialog(wID);
  648. return 0;
  649. }
  650. //////////////////////////////////////////////////////////////////////////////
  651. /*++
  652. CDlgNewFaxOutboundDevice::OnHelpRequest
  653. This is called in response to the WM_HELP Notify
  654. message and to the WM_CONTEXTMENU Notify message.
  655. WM_HELP Notify message.
  656. This message is sent when the user presses F1 or <Shift>-F1
  657. over an item or when the user clicks on the ? icon and then
  658. presses the mouse over an item.
  659. WM_CONTEXTMENU Notify message.
  660. This message is sent when the user right clicks over an item
  661. and then clicks "What's this?"
  662. --*/
  663. /////////////////////////////////////////////////////////////////////////////
  664. LRESULT
  665. CDlgNewFaxOutboundDevice::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  666. {
  667. DEBUG_FUNCTION_NAME(_T("CDlgNewFaxOutboundDevice::OnHelpRequest"));
  668. switch (uMsg)
  669. {
  670. case WM_HELP:
  671. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  672. break;
  673. case WM_CONTEXTMENU:
  674. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  675. break;
  676. }
  677. return TRUE;
  678. }
  679. /////////////////////////////////////////////////////////////////////////////