Source code of Windows XP (NT5)
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.

778 lines
19 KiB

  1. #include "stdafx.h"
  2. #include "routeext.h"
  3. #include "Route.h"
  4. #include "faxhelp.h"
  5. #include <atl21\atlwin.cpp>
  6. #define MyHideWindow(_hwnd) ::SetWindowLong((_hwnd),GWL_STYLE,::GetWindowLong((_hwnd),GWL_STYLE)&~WS_VISIBLE)
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CRouteComponentData
  9. static const GUID CRouteGUID_NODETYPE =
  10. { 0xde58ae00, 0x4c0f, 0x11d1, { 0x90, 0x83, 0x0, 0xa0, 0xc9, 0xa, 0xb5, 0x4}};
  11. const GUID* CRouteData::m_NODETYPE = &CRouteGUID_NODETYPE;
  12. const TCHAR* CRouteData::m_SZNODETYPE = _T("de58ae00-4c0f-11d1-9083-00a0c90ab504");
  13. const TCHAR* CRouteData::m_SZDISPLAY_NAME = _T("CRoute");
  14. const CLSID* CRouteData::m_SNAPIN_CLASSID = &CLSID_Route;
  15. static const LPCWSTR RoutingGuids[RM_COUNT] = {
  16. L"{6bbf7bfe-9af2-11d0-abf7-00c04fd91a4e}", // RM_EMAIL
  17. L"{9d3d0c32-9af2-11d0-abf7-00c04fd91a4e}", // RM_INBOX
  18. L"{92041a90-9af2-11d0-abf7-00c04fd91a4e}", // RM_FOLDER
  19. L"{aec1b37c-9af2-11d0-abf7-00c04fd91a4e}" // RM_PRINT
  20. };
  21. static const ULONG_PTR RoutingHelpIds[] = {
  22. IDC_ROUTE_TITLE, IDH_Fax_Modem_Routing_InboundRouting_GRP,
  23. IDC_PRINT, IDH_Fax_Modem_Routing_PrintTo,
  24. IDC_PRINT_TO, IDH_Fax_Modem_Routing_PrintTo,
  25. IDC_SAVE, IDH_Fax_Modem_Routing_SaveInFolder,
  26. IDC_INBOX, IDH_Fax_Modem_Routing_SendToLocalInbox,
  27. IDC_INBOX_PROFILE, IDH_Fax_Modem_Routing_ProfileName,
  28. IDC_INBOX_LABEL, IDH_Fax_Modem_Routing_ProfileName,
  29. IDC_DEST_FOLDER, IDH_Fax_Modem_Routing_SaveInFolder,
  30. IDC_BROWSE_DIR, IDH_Fax_Modem_Routing_SaveInFolder,
  31. IDC_EMAIL, IDH_Fax_Modem_Routing_SendToLocalInbox,
  32. 0, 0
  33. };
  34. CRoutePage::CRoutePage(
  35. TCHAR* pTitle,
  36. HANDLE FaxHandle,
  37. DWORD DeviceId,
  38. LPWSTR ComputerName
  39. ) : CPropertyPageImpl<CRoutePage> (pTitle)
  40. {
  41. DWORD rc = ERROR_SUCCESS;
  42. DWORD cMethods = 0;
  43. m_FaxHandle = FaxHandle;
  44. m_DeviceId = DeviceId;
  45. m_BaseMethod = NULL;
  46. m_PortHandle = NULL;
  47. wcscpy( m_ComputerName, ComputerName );
  48. m_MapiProfiles = NULL;
  49. if (!FaxGetMapiProfiles(m_FaxHandle, &m_MapiProfiles)) {
  50. m_MapiProfiles = NULL;
  51. }
  52. wcsncpy( m_Title, pTitle, MAX_TITLE_LEN);
  53. m_bChanged = FALSE;
  54. if (!FaxOpenPort( m_FaxHandle, m_DeviceId, PORT_OPEN_QUERY, &m_PortHandle )) {
  55. rc = GetLastError();
  56. goto exit;
  57. }
  58. if (!FaxEnumRoutingMethods( m_PortHandle, &m_BaseMethod, &cMethods )) {
  59. rc = GetLastError();
  60. } else {
  61. DWORD CurrentRM;
  62. DWORD i;
  63. for (CurrentRM = RM_EMAIL; CurrentRM < RM_COUNT; CurrentRM++) {
  64. m_RoutingMethods[CurrentRM] = NULL;
  65. for (i = 0; i < cMethods; i++) {
  66. if (_wcsicmp( m_BaseMethod[i].Guid, RoutingGuids[CurrentRM] ) == 0) {
  67. m_RoutingMethods[CurrentRM] = &m_BaseMethod[i];
  68. if (!FaxGetRoutingInfo( m_PortHandle, m_BaseMethod[i].Guid, &m_RoutingInfo[CurrentRM], &m_RoutingInfoSize[CurrentRM] )) {
  69. m_RoutingMethods[CurrentRM]->Enabled = FALSE;
  70. }
  71. break;
  72. }
  73. }
  74. }
  75. }
  76. exit:
  77. if (rc != ERROR_SUCCESS) {
  78. SystemErrorMsg( rc );
  79. }
  80. if (m_PortHandle) {
  81. FaxClose(m_PortHandle);
  82. m_PortHandle = NULL;
  83. }
  84. }
  85. HRESULT
  86. CRouteData::CreatePropertyPages(
  87. LPPROPERTYSHEETCALLBACK lpProvider,
  88. LONG_PTR handle,
  89. IUnknown* pUnk
  90. )
  91. {
  92. UINT cf = RegisterClipboardFormat(L"CF_FAX_DEVICE");
  93. HRESULT hr = S_OK;
  94. STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL};
  95. FORMATETC formatetc = { (CLIPFORMAT)cf, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
  96. LPSTREAM lpStream;
  97. DWORD cbytes;
  98. HANDLE FaxHandle;
  99. DWORD DeviceId;
  100. WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
  101. WCHAR Title[MAX_TITLE_LEN];
  102. do
  103. {
  104. // Allocate memory for the stream
  105. stgmedium.hGlobal = GlobalAlloc(GMEM_SHARE, 128);
  106. if (!stgmedium.hGlobal) {
  107. ATLTRACE(_T("Out of memory\n"));
  108. hr = E_OUTOFMEMORY;
  109. break;
  110. }
  111. hr = m_pDataObject->GetDataHere(&formatetc, &stgmedium);
  112. if (FAILED(hr)) {
  113. break;
  114. }
  115. } while (0);
  116. if (FAILED(hr)) {
  117. return(hr);
  118. }
  119. // this also frees the memory pointed to by stgmedium.hGlobal
  120. CreateStreamOnHGlobal( stgmedium.hGlobal, TRUE, &lpStream );
  121. lpStream->Read( (LPVOID) &FaxHandle, sizeof(DWORD), &cbytes );
  122. lpStream->Read( (LPVOID) &DeviceId, sizeof(DWORD), &cbytes );
  123. lpStream->Read( (LPVOID) ComputerName, sizeof(ComputerName), &cbytes );
  124. lpStream->Release();
  125. LoadString(_Module.m_hInst, IDS_TITLE, Title, MAX_TITLE_LEN);
  126. CRoutePage* pPage = new CRoutePage(Title, FaxHandle, DeviceId, ComputerName);
  127. if (!pPage) {
  128. return(E_OUTOFMEMORY);
  129. }
  130. lpProvider->AddPage(pPage->Create());
  131. return(S_OK);
  132. }
  133. LRESULT
  134. CRoutePage::OnInitDialog(
  135. UINT uMsg,
  136. WPARAM wParam,
  137. LPARAM lParam,
  138. BOOL& bHandled
  139. )
  140. {
  141. for (int i = 0; i < RM_COUNT; i++) {
  142. BOOL Enabled;
  143. LPWSTR CurSel;
  144. HWND hControl;
  145. PPRINTER_INFO_2 pPrinterInfo2, pSaved;
  146. DWORD cPrinters, dwFlags;
  147. Enabled = m_RoutingMethods[i]->Enabled;
  148. CurSel = (LPWSTR) (m_RoutingInfo[i] + sizeof(DWORD));
  149. SetChangedFlag( FALSE );
  150. switch (i) {
  151. case RM_EMAIL:
  152. MyHideWindow( GetDlgItem( IDC_EMAIL ));
  153. break;
  154. if (MAPIENABLED) {
  155. CheckDlgButton( IDC_EMAIL, Enabled ? BST_CHECKED : BST_UNCHECKED );
  156. } else {
  157. MyHideWindow( GetDlgItem( IDC_EMAIL ) );
  158. }
  159. break;
  160. case RM_INBOX:
  161. if (MAPIENABLED) {
  162. ::SendMessage( hControl = GetDlgItem( IDC_INBOX_PROFILE ), CB_RESETCONTENT, 0, 0 );
  163. CheckDlgButton( IDC_INBOX, Enabled ? BST_CHECKED : BST_UNCHECKED );
  164. ::EnableWindow( GetDlgItem( IDC_INBOX_LABEL ), Enabled );
  165. ::EnableWindow( hControl, Enabled );
  166. EnumMapiProfiles( hControl );
  167. ::SendMessage( hControl, CB_SETCURSEL, 0, 0 );
  168. if (*CurSel) {
  169. ::SendMessage( hControl, CB_SELECTSTRING, 0, (LPARAM) CurSel );
  170. }
  171. } else {
  172. ::EnableWindow( GetDlgItem( IDC_INBOX ), FALSE );
  173. ::EnableWindow( GetDlgItem( IDC_INBOX_LABEL ), FALSE );
  174. ::EnableWindow( GetDlgItem( IDC_INBOX_PROFILE ), FALSE );
  175. }
  176. break;
  177. case RM_FOLDER:
  178. CheckDlgButton( IDC_SAVE, Enabled ? BST_CHECKED : BST_UNCHECKED );
  179. ::EnableWindow( GetDlgItem( IDC_DEST_FOLDER ), Enabled );
  180. ::EnableWindow( GetDlgItem( IDC_BROWSE_DIR ), Enabled );
  181. SendDlgItemMessage( IDC_DEST_FOLDER, EM_SETLIMITTEXT, MAX_PATH - 16, 0 );
  182. if (*CurSel) {
  183. SetDlgItemText( IDC_DEST_FOLDER, CurSel );
  184. }
  185. break;
  186. case RM_PRINT:
  187. BOOL bPrinters = FALSE;
  188. dwFlags = m_ComputerName[0] ?
  189. PRINTER_ENUM_NAME :
  190. (PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS);
  191. hControl = GetDlgItem( IDC_PRINT_TO );
  192. pPrinterInfo2 = (PPRINTER_INFO_2) MyEnumPrinters(m_ComputerName, 2, &cPrinters, dwFlags);
  193. if (pSaved = pPrinterInfo2) {
  194. //
  195. // Filtering out fax printers from the list
  196. //
  197. for ( ; cPrinters--; pPrinterInfo2++) {
  198. if (_wcsicmp(pPrinterInfo2->pDriverName, FAX_DRIVER_NAME) != 0) {
  199. ::SendMessage( hControl, CB_ADDSTRING, 0, (LPARAM) pPrinterInfo2->pPrinterName);
  200. bPrinters = TRUE;
  201. }
  202. }
  203. MemFree(pSaved);
  204. }
  205. CheckDlgButton( IDC_PRINT, (Enabled && bPrinters) ? BST_CHECKED : BST_UNCHECKED );
  206. ::EnableWindow( GetDlgItem(IDC_PRINT), bPrinters);
  207. if (*CurSel) {
  208. ::SendMessage( hControl, CB_SELECTSTRING, 0, (LPARAM) CurSel );
  209. } else {
  210. ::SendMessage( hControl, CB_SETCURSEL, 0, 0 );
  211. }
  212. ::EnableWindow( GetDlgItem( IDC_PRINT_TO ), (Enabled && bPrinters) );
  213. break;
  214. }
  215. }
  216. ::SendMessage(GetParent(), PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
  217. return 1;
  218. }
  219. LRESULT
  220. CRoutePage::OnEmail(
  221. INT code,
  222. INT id,
  223. HWND hwnd,
  224. BOOL& bHandled
  225. )
  226. {
  227. SetChangedFlag( TRUE );
  228. return 1;
  229. }
  230. LRESULT
  231. CRoutePage::OnPrint(
  232. INT code,
  233. INT id,
  234. HWND hwnd,
  235. BOOL& bHandled
  236. )
  237. {
  238. ::EnableWindow( GetDlgItem( IDC_PRINT_TO ), IsDlgButtonChecked( id ) == BST_CHECKED ? TRUE : FALSE );
  239. SetChangedFlag( TRUE );
  240. return 1;
  241. }
  242. LRESULT
  243. CRoutePage::OnPrintTo(
  244. INT code,
  245. INT id,
  246. HWND hwnd,
  247. BOOL& bHandled
  248. )
  249. {
  250. if (code == CBN_SELCHANGE) {
  251. SetChangedFlag( TRUE );
  252. }
  253. return 1;
  254. }
  255. LRESULT
  256. CRoutePage::OnSaveTo(
  257. INT code,
  258. INT id,
  259. HWND hwnd,
  260. BOOL& bHandled
  261. )
  262. {
  263. ::EnableWindow( GetDlgItem( IDC_DEST_FOLDER ), IsDlgButtonChecked( id ) == BST_CHECKED ? TRUE : FALSE );
  264. ::EnableWindow( GetDlgItem( IDC_BROWSE_DIR ), IsDlgButtonChecked( id ) == BST_CHECKED ? TRUE : FALSE );
  265. SetChangedFlag( TRUE );
  266. return 1;
  267. }
  268. LRESULT
  269. CRoutePage::OnInbox(
  270. INT code,
  271. INT id,
  272. HWND hwnd,
  273. BOOL& bHandled
  274. )
  275. {
  276. ::EnableWindow( GetDlgItem( IDC_INBOX_PROFILE ), IsDlgButtonChecked( id ) == BST_CHECKED ? TRUE : FALSE );
  277. ::EnableWindow( GetDlgItem( IDC_INBOX_LABEL ), IsDlgButtonChecked( id ) == BST_CHECKED ? TRUE : FALSE );
  278. SetChangedFlag( TRUE );
  279. return 1;
  280. }
  281. LRESULT
  282. CRoutePage::OnProfile(
  283. INT code,
  284. INT id,
  285. HWND hwnd,
  286. BOOL& bHandled
  287. )
  288. {
  289. if (code == CBN_SELCHANGE) {
  290. SetChangedFlag( TRUE );
  291. }
  292. return 1;
  293. }
  294. LRESULT
  295. CRoutePage::OnDestDir(
  296. INT code,
  297. INT id,
  298. HWND hwnd,
  299. BOOL& bHandled
  300. )
  301. {
  302. if (code == EN_UPDATE) {
  303. SetChangedFlag( TRUE );
  304. }
  305. return 1;
  306. }
  307. LRESULT
  308. CRoutePage::OnBrowseDir(
  309. INT code,
  310. INT id,
  311. HWND hwnd,
  312. BOOL& bHandled
  313. )
  314. {
  315. BrowseForDirectory();
  316. return 1;
  317. }
  318. #define INFO_SIZE (MAX_PATH * sizeof(WCHAR) + sizeof(DWORD))
  319. BOOL
  320. CRoutePage::OnApply()
  321. {
  322. BYTE SetInfo[RM_COUNT][INFO_SIZE];
  323. LPWSTR lpCurSel;
  324. LPDWORD Enabled;
  325. DWORD ec;
  326. DWORD OneEnabled = 0;
  327. DWORD i;
  328. if (!m_bChanged) {
  329. return TRUE;
  330. }
  331. for (i = 0; i < RM_COUNT; i++) {
  332. INT SelIndex;
  333. HWND hControl;
  334. lpCurSel = (LPWSTR)(SetInfo[i] + sizeof(DWORD));
  335. Enabled = (LPDWORD) SetInfo[i];
  336. *Enabled = 0;
  337. ZeroMemory( lpCurSel, MAX_PATH * sizeof(WCHAR) );
  338. switch (i) {
  339. case RM_PRINT:
  340. *Enabled = (IsDlgButtonChecked( IDC_PRINT ) == BST_CHECKED);
  341. if (*Enabled) {
  342. SelIndex = (INT)::SendMessage( hControl = GetDlgItem( IDC_PRINT_TO ), CB_GETCURSEL, 0, 0 );
  343. if (SelIndex != CB_ERR) {
  344. ::SendMessage( hControl, CB_GETLBTEXT, SelIndex, (LPARAM) lpCurSel );
  345. } else {
  346. lpCurSel[0] = 0;
  347. }
  348. if (lpCurSel[0] == 0) {
  349. DisplayMessageDialog( 0, IDS_PRINT_TO );
  350. return FALSE;
  351. }
  352. }
  353. break;
  354. case RM_EMAIL:
  355. if (!MAPIENABLED) {
  356. break;
  357. }
  358. *Enabled = (IsDlgButtonChecked( IDC_EMAIL ) == BST_CHECKED);
  359. break;
  360. case RM_INBOX:
  361. if (!MAPIENABLED) {
  362. break;
  363. }
  364. *Enabled = (IsDlgButtonChecked( IDC_INBOX ) == BST_CHECKED);
  365. if (*Enabled) {
  366. SelIndex = (INT)::SendMessage( hControl = GetDlgItem( IDC_INBOX_PROFILE ), CB_GETCURSEL, 0, 0 );
  367. if (SelIndex != CB_ERR) {
  368. ::SendMessage( hControl, CB_GETLBTEXT, SelIndex, (LPARAM) lpCurSel );
  369. } else {
  370. lpCurSel[0] = 0;
  371. }
  372. if (lpCurSel[0] == 0) {
  373. DisplayMessageDialog( 0, IDS_INBOX_PROFILE );
  374. return FALSE;
  375. }
  376. }
  377. break;
  378. case RM_FOLDER:
  379. *Enabled = (IsDlgButtonChecked( IDC_SAVE ) == BST_CHECKED);
  380. if (*Enabled) {
  381. GetDlgItemText( IDC_DEST_FOLDER, lpCurSel, MAX_PATH - 1 );
  382. if (lpCurSel[0] == 0) {
  383. DisplayMessageDialog( 0, IDS_DEST_FOLDER );
  384. return FALSE;
  385. }
  386. }
  387. }
  388. OneEnabled |= *Enabled;
  389. }
  390. if (!OneEnabled) {
  391. DisplayMessageDialog( 0, IDS_ONE_ENABLE );
  392. return FALSE;
  393. }
  394. if (!FaxOpenPort( m_FaxHandle, m_DeviceId, PORT_OPEN_QUERY | PORT_OPEN_MODIFY, &m_PortHandle )) {
  395. ec = GetLastError();
  396. DisplayMessageDialog( 0, IDS_CANT_SAVE );
  397. return FALSE;
  398. }
  399. ec = ERROR_SUCCESS;
  400. for (i = 0; i < RM_COUNT; i++) {
  401. Enabled = (LPDWORD) SetInfo[i];
  402. if (!FaxEnableRoutingMethod(
  403. m_PortHandle,
  404. m_RoutingMethods[i]->Guid,
  405. *Enabled
  406. )) {
  407. ec = GetLastError();
  408. DisplayMessageDialog( 0, IDS_CANT_SAVE );
  409. if (ec == ERROR_ACCESS_DENIED) {
  410. break;
  411. }
  412. }
  413. else if (*Enabled && i!= RM_EMAIL && !FaxSetRoutingInfo(
  414. m_PortHandle,
  415. m_RoutingMethods[i]->Guid,
  416. &SetInfo[i][0],
  417. INFO_SIZE)) {
  418. ec = GetLastError();
  419. DisplayMessageDialog( 0, IDS_CANT_SAVE );
  420. if (ec == ERROR_ACCESS_DENIED) {
  421. break;
  422. }
  423. }
  424. }
  425. if (m_PortHandle) {
  426. FaxClose( m_PortHandle );
  427. m_PortHandle = NULL;
  428. }
  429. return (ec == ERROR_SUCCESS);
  430. }
  431. VOID
  432. CRoutePage::SystemErrorMsg(
  433. DWORD ErrorCode
  434. )
  435. {
  436. LPTSTR lpMsgBuf;
  437. FormatMessage(
  438. FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  439. NULL,
  440. ErrorCode,
  441. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  442. (LPTSTR) &lpMsgBuf,
  443. 0,
  444. NULL
  445. );
  446. MessageBox( lpMsgBuf, m_Title );
  447. MemFree( lpMsgBuf );
  448. }
  449. VOID
  450. CRoutePage::EnumMapiProfiles(
  451. HWND hwnd
  452. )
  453. /*++
  454. Routine Description:
  455. Put the mapi profiles in the combo box
  456. Arguments:
  457. hwnd - window handle to mapi profiles combo box
  458. Return Value:
  459. NONE
  460. --*/
  461. {
  462. LPWSTR MapiProfiles;
  463. MapiProfiles = (LPWSTR) m_MapiProfiles;
  464. while (MapiProfiles && *MapiProfiles) {
  465. ::SendMessage(
  466. hwnd,
  467. CB_ADDSTRING,
  468. 0,
  469. (LPARAM) MapiProfiles
  470. );
  471. MapiProfiles += wcslen(MapiProfiles) + 1;
  472. }
  473. }
  474. VOID
  475. CRoutePage::SetChangedFlag(
  476. BOOL Flag
  477. )
  478. {
  479. PropSheet_Changed( GetParent(), m_hWnd );
  480. m_bChanged = TRUE;
  481. }
  482. INT
  483. CRoutePage::DisplayMessageDialog(
  484. INT titleStrId,
  485. INT formatStrId,
  486. UINT type
  487. )
  488. /*++
  489. Routine Description:
  490. Display a message dialog box
  491. Arguments:
  492. hwndParent - Specifies a parent window for the error message dialog
  493. type - Specifies the type of message box to be displayed
  494. titleStrId - Title string (could be a string resource ID)
  495. formatStrId - Message format string (could be a string resource ID)
  496. ...
  497. Return Value:
  498. Same as the return value from MessageBox
  499. --*/
  500. {
  501. LPWSTR pTitle, pFormat, pMessage;
  502. INT result;
  503. pTitle = pFormat = pMessage = NULL;
  504. if ((pTitle = (LPWSTR)MemAlloc(MAX_TITLE_LEN * sizeof(WCHAR))) &&
  505. (pFormat = (LPWSTR)MemAlloc(MAX_STRING_LEN * sizeof(WCHAR))) &&
  506. (pMessage = (LPWSTR)MemAlloc(MAX_MESSAGE_LEN * sizeof(WCHAR)))) {
  507. //
  508. // Load dialog box title string resource
  509. //
  510. if (titleStrId == 0)
  511. titleStrId = IDS_ERROR_DLGTITLE;
  512. LoadString(_Module.m_hInst, titleStrId, pTitle, MAX_TITLE_LEN);
  513. //
  514. // Load message format string resource
  515. //
  516. LoadString(_Module.m_hInst, formatStrId, pFormat, MAX_STRING_LEN);
  517. //
  518. // Display the message box
  519. //
  520. result = MessageBox(pFormat, pTitle, type);
  521. } else {
  522. MessageBeep(MB_ICONHAND);
  523. result = 0;
  524. }
  525. MemFree(pTitle);
  526. MemFree(pFormat);
  527. MemFree(pMessage);
  528. return result;
  529. }
  530. BOOL
  531. CRoutePage::BrowseForDirectory(
  532. )
  533. /*++
  534. Routine Description:
  535. Browse for a directory
  536. Arguments:
  537. hDlg - Specifies the dialog window on which the Browse button is displayed
  538. textFieldId - Specifies the text field adjacent to the Browse button
  539. titleStrId - Specifies the title to be displayed in the browse window
  540. Return Value:
  541. TRUE if successful, FALSE if the user presses Cancel
  542. --*/
  543. {
  544. LPITEMIDLIST pidl;
  545. WCHAR buffer[MAX_PATH];
  546. WCHAR title[MAX_TITLE_LEN];
  547. VOID SHFree(LPVOID);
  548. BOOL result = FALSE;
  549. LPMALLOC pMalloc;
  550. BROWSEINFO bi = {
  551. m_hWnd,
  552. NULL,
  553. buffer,
  554. title,
  555. BIF_RETURNONLYFSDIRS,
  556. NULL,
  557. (LPARAM) buffer,
  558. };
  559. if (! LoadString(_Module.m_hInst, IDS_INBOUND_DIR, title, MAX_TITLE_LEN))
  560. title[0] = 0;
  561. if (! GetDlgItemText( IDC_DEST_FOLDER, buffer, MAX_PATH))
  562. buffer[0] = 0;
  563. if (pidl = SHBrowseForFolder(&bi)) {
  564. if (SHGetPathFromIDList(pidl, buffer)) {
  565. if (wcslen(buffer) > MAX_ARCHIVE_DIR)
  566. DisplayMessageDialog(0,IDS_DIR_TOO_LONG);
  567. else {
  568. SetDlgItemText(IDC_DEST_FOLDER, buffer);
  569. result = TRUE;
  570. }
  571. }
  572. SHGetMalloc(&pMalloc);
  573. pMalloc->Free(pidl);
  574. pMalloc->Release();
  575. }
  576. return result;
  577. }
  578. LRESULT
  579. CRoutePage::OnWmHelp(
  580. UINT uMsg,
  581. WPARAM wParam,
  582. LPARAM lParam,
  583. BOOL& bHandled
  584. )
  585. {
  586. ::WinHelp((HWND) ((LPHELPINFO) lParam)->hItemHandle,
  587. FAXCFG_HELP_FILENAME,
  588. HELP_WM_HELP,
  589. (ULONG_PTR) &RoutingHelpIds);
  590. return 1;
  591. }
  592. LRESULT
  593. CRoutePage::OnWmContextHelp(
  594. UINT uMsg,
  595. WPARAM wParam,
  596. LPARAM lParam,
  597. BOOL& bHandled
  598. )
  599. {
  600. ::WinHelp((HWND) wParam,
  601. FAXCFG_HELP_FILENAME,
  602. HELP_CONTEXTMENU,
  603. (ULONG_PTR) &RoutingHelpIds);
  604. return 1;
  605. }