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.

789 lines
20 KiB

  1. // ClientConsole.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "..\admin\cfgwzrd\FaxCfgWzExp.h"
  5. #define __FILE_ID__ 1
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CClientConsoleApp
  13. BEGIN_MESSAGE_MAP(CClientConsoleApp, CWinApp)
  14. //{{AFX_MSG_MAP(CClientConsoleApp)
  15. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  16. // NOTE - the ClassWizard will add and remove mapping macros here.
  17. // DO NOT EDIT what you see in these blocks of generated code!
  18. //}}AFX_MSG_MAP
  19. // Standard file based document commands
  20. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  21. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  22. END_MESSAGE_MAP()
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CClientConsoleApp construction
  25. CClientConsoleApp::CClientConsoleApp():
  26. m_hInstMail(NULL),
  27. m_bRTLUI(FALSE),
  28. m_bClassRegistered(FALSE)
  29. {
  30. }
  31. /////////////////////////////////////////////////////////////////////////////
  32. // The one and only CClientConsoleApp object
  33. CClientConsoleApp theApp;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CClientConsoleApp initialization
  36. BOOL CClientConsoleApp::InitInstance()
  37. {
  38. MODIFY_FORMAT_MASK(DBG_PRNT_THREAD_ID,0);
  39. BOOL bRes = FALSE;
  40. DBG_ENTER (TEXT("CClientConsoleApp::InitInstance"), bRes);
  41. if(IsRTLUILanguage())
  42. {
  43. //
  44. // Set Right-to-Left layout for RTL languages
  45. //
  46. m_bRTLUI = TRUE;
  47. SetRTLProcessLayout();
  48. }
  49. //
  50. // Parse command line for standard shell commands, DDE, file open
  51. //
  52. ParseCommandLine(m_cmdLineInfo);
  53. //
  54. // See if we need to active previous instance
  55. //
  56. try
  57. {
  58. m_PrivateClassName = CLIENT_CONSOLE_CLASS;
  59. if (m_cmdLineInfo.IsSingleServer())
  60. {
  61. //
  62. // Append server name to window class name
  63. //
  64. m_PrivateClassName += m_cmdLineInfo.GetSingleServerName();
  65. }
  66. }
  67. catch (...)
  68. {
  69. CALL_FAIL (MEM_ERR, TEXT("CString exception"), ERROR_NOT_ENOUGH_MEMORY);
  70. return bRes;
  71. }
  72. if (!m_cmdLineInfo.ForceNewInstance())
  73. {
  74. //
  75. // User did not force a new instance- check for previous instance
  76. //
  77. if(!FirstInstance())
  78. {
  79. //
  80. // Other instance located and activated
  81. //
  82. return bRes;
  83. }
  84. }
  85. //
  86. // Implicit launch of fax configuration wizard
  87. //
  88. if (!LaunchConfigWizard(FALSE))
  89. {
  90. //
  91. // User refused to enter a dialing location - stop the client console.
  92. //
  93. VERBOSE (DBG_MSG, TEXT("User refused to enter a dialing location - stop the client console."));
  94. return bRes;
  95. }
  96. //
  97. // Register our unique class name that you wish to use
  98. //
  99. WNDCLASS wndcls = {0};
  100. wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
  101. wndcls.lpfnWndProc = ::DefWindowProc;
  102. wndcls.hInstance = AfxGetInstanceHandle();
  103. wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
  104. wndcls.hCursor = LoadCursor(IDC_ARROW);
  105. wndcls.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  106. wndcls.lpszMenuName = NULL;
  107. wndcls.lpszClassName = m_PrivateClassName;
  108. //
  109. // Register the new class and exit if it fails
  110. //
  111. if(!AfxRegisterClass(&wndcls))
  112. {
  113. CALL_FAIL (GENERAL_ERR, TEXT("AfxRegisterClass"), GetLastError());
  114. return bRes;
  115. }
  116. m_bClassRegistered = TRUE;
  117. //
  118. // Standard initialization
  119. // If you are not using these features and wish to reduce the size
  120. // of your final executable, you should remove from the following
  121. // the specific initialization routines you do not need.
  122. //
  123. #ifdef _AFXDLL
  124. Enable3dControls(); // Call this when using MFC in a shared DLL
  125. #else
  126. Enable3dControlsStatic(); // Call this when linking to MFC statically
  127. #endif
  128. //
  129. // Change the app's resource to our resource DLL.
  130. //
  131. HINSTANCE hResource = GetResourceHandle();
  132. if(!hResource)
  133. {
  134. return FALSE;
  135. }
  136. AfxSetResourceHandle (hResource);
  137. //
  138. // Generate a really random seed
  139. //
  140. srand( (unsigned)time( NULL ) );
  141. //
  142. // Set the registry location or the app.
  143. //
  144. SetRegistryKey (REGKEY_CLIENT);
  145. //
  146. // Set application name
  147. //
  148. CString cstrAppName;
  149. DWORD dwRes = LoadResourceString (cstrAppName, AFX_IDS_APP_TITLE);
  150. if (ERROR_SUCCESS != dwRes)
  151. {
  152. return bRes;
  153. }
  154. ASSERTION (m_pszAppName); // Loaded from exe name
  155. free((void*)m_pszAppName);
  156. m_pszAppName = _tcsdup(cstrAppName);
  157. //
  158. // Check for minimal version of ComCtl32.dll
  159. //
  160. #define COM_CTL_VERSION_4_70 PACKVERSION(4,70)
  161. DWORD dwComCtl32Version = GetDllVersion(TEXT("comctl32.dll"));
  162. VERBOSE (DBG_MSG, TEXT("COMCTL32.DLL Version is : 0x%08X"), dwComCtl32Version);
  163. if (dwComCtl32Version < COM_CTL_VERSION_4_70)
  164. {
  165. AlignedAfxMessageBox (IDS_BAD_COMCTL32, MB_OK | MB_ICONHAND);
  166. return bRes;
  167. }
  168. //
  169. // Register the application's document templates. Document templates
  170. // serve as the connection between documents, frame windows and views.
  171. //
  172. CSingleDocTemplate* pDocTemplate;
  173. try
  174. {
  175. pDocTemplate = new CSingleDocTemplate(
  176. IDR_MAINFRAME,
  177. RUNTIME_CLASS(CClientConsoleDoc),
  178. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  179. RUNTIME_CLASS(CLeftView));
  180. }
  181. catch (...)
  182. {
  183. CALL_FAIL (MEM_ERR, TEXT("new CSingleDocTemplate"), ERROR_NOT_ENOUGH_MEMORY);
  184. PopupError (ERROR_NOT_ENOUGH_MEMORY);
  185. return bRes;
  186. }
  187. AddDocTemplate(pDocTemplate);
  188. //
  189. // Read the initial settings
  190. //
  191. CMessageFolder::ReadConfiguration ();
  192. //
  193. // Load MAPI library
  194. //
  195. if (1 == ::GetProfileInt (TEXT("Mail"), TEXT("MAPI"), 0))
  196. {
  197. //
  198. // If there's an entry in WIN.INI under the [Mail] section saying MAPI=1, then
  199. // and only then, MAPI is available to us.
  200. // Search MSDN for "Initializing a Simple MAPI Client" and read for yourself if
  201. // you don't believe me.
  202. //
  203. m_hInstMail = ::LoadLibrary(TEXT("MAPI32.DLL"));
  204. if(NULL == m_hInstMail)
  205. {
  206. dwRes = GetLastError();
  207. CALL_FAIL (GENERAL_ERR, TEXT("LoadLibrary(\"MAPI32.DLL\")"), dwRes);
  208. }
  209. }
  210. OnFileNew();
  211. // The one and only window has been initialized, so show and update it.
  212. m_pMainWnd->ShowWindow(SW_SHOW);
  213. m_pMainWnd->UpdateWindow();
  214. bRes = TRUE;
  215. return bRes;
  216. } // CClientConsoleApp::InitInstance
  217. int
  218. CClientConsoleApp::ExitInstance()
  219. {
  220. DWORD dwRes = ERROR_SUCCESS;
  221. DBG_ENTER (TEXT("CClientConsoleApp::ExitInstance"));
  222. if(NULL != m_hInstMail)
  223. {
  224. if(!FreeLibrary(m_hInstMail))
  225. {
  226. dwRes = GetLastError();
  227. CALL_FAIL (GENERAL_ERR, TEXT("FreeLibrary (MAPI32.DLL)"), dwRes);
  228. }
  229. }
  230. //
  231. // Remove left of temp preview files
  232. //
  233. DeleteTempPreviewFiles (NULL, TRUE);
  234. if(m_bClassRegistered)
  235. {
  236. //
  237. // Unregister our class
  238. //
  239. ::UnregisterClass(m_PrivateClassName, AfxGetInstanceHandle());
  240. m_bClassRegistered = FALSE;
  241. }
  242. FreeResInstance();
  243. return CWinApp::ExitInstance();
  244. }
  245. BOOL
  246. CClientConsoleApp::LaunchConfigWizard(
  247. BOOL bExplicit
  248. )
  249. /*++
  250. Routine name : CClientConsoleApp::LaunchConfigWizard
  251. Routine description:
  252. launch Fax Configuration Wizard for Windows XP platform only
  253. Arguments:
  254. bExplicit [in] - TRUE if it's explicit launch
  255. Return Value:
  256. TRUE if the client console should continue.
  257. If FALSE, the user failed to set a dialing location and the client console should quit.
  258. --*/
  259. {
  260. DBG_ENTER(TEXT("CClientConsoleApp::LaunchConfigWizard"));
  261. if(!IsWinXPOS())
  262. {
  263. return TRUE;
  264. }
  265. HMODULE hConfigWizModule = LoadLibrary(FAX_CONFIG_WIZARD_DLL);
  266. if(hConfigWizModule)
  267. {
  268. FAX_CONFIG_WIZARD fpFaxConfigWiz;
  269. BOOL bAbort = FALSE;
  270. fpFaxConfigWiz = (FAX_CONFIG_WIZARD)GetProcAddress(hConfigWizModule,
  271. FAX_CONFIG_WIZARD_PROC);
  272. if(fpFaxConfigWiz)
  273. {
  274. if(!fpFaxConfigWiz(bExplicit, &bAbort))
  275. {
  276. CALL_FAIL (GENERAL_ERR, TEXT("FaxConfigWizard"), GetLastError());
  277. }
  278. }
  279. else
  280. {
  281. CALL_FAIL (GENERAL_ERR, TEXT("GetProcAddress(FaxConfigWizard)"), GetLastError());
  282. }
  283. if(!FreeLibrary(hConfigWizModule))
  284. {
  285. CALL_FAIL (GENERAL_ERR, TEXT("FreeLibrary(FxsCgfWz.dll)"), GetLastError());
  286. }
  287. if (bAbort)
  288. {
  289. //
  290. // User refused to enter a dialing location - stop the client console.
  291. //
  292. return FALSE;
  293. }
  294. }
  295. else
  296. {
  297. CALL_FAIL (GENERAL_ERR, TEXT("LoadLibrary(FxsCgfWz.dll)"), GetLastError());
  298. }
  299. return TRUE;
  300. }
  301. void
  302. CClientConsoleApp::InboxViewed()
  303. /*++
  304. Routine name : CClientConsoleApp::InboxViewed
  305. Routine description:
  306. Report to the Fax Monitor that the Inbox folder has been viewed
  307. Return Value:
  308. none
  309. --*/
  310. {
  311. DBG_ENTER(TEXT("CClientConsoleApp::InboxViewed"));
  312. if(!IsWinXPOS())
  313. {
  314. return;
  315. }
  316. HWND hWndFaxMon = FindWindow(FAXSTAT_WINCLASS, NULL);
  317. if (hWndFaxMon)
  318. {
  319. PostMessage(hWndFaxMon, WM_FAXSTAT_INBOX_VIEWED, 0, 0);
  320. }
  321. }
  322. void
  323. CClientConsoleApp::OutboxViewed()
  324. /*++
  325. Routine name : CClientConsoleApp::OutboxViewed
  326. Routine description:
  327. Report to the Fax Monitor that the Outbox folder has been viewed
  328. Return Value:
  329. none
  330. --*/
  331. {
  332. DBG_ENTER(TEXT("CClientConsoleApp::InboxViewed"));
  333. if(!IsWinXPOS())
  334. {
  335. return;
  336. }
  337. HWND hWndFaxMon = FindWindow(FAXSTAT_WINCLASS, NULL);
  338. if (hWndFaxMon)
  339. {
  340. PostMessage(hWndFaxMon, WM_FAXSTAT_OUTBOX_VIEWED, 0, 0);
  341. }
  342. }
  343. VOID
  344. CClientConsoleApp::PrepareForModal ()
  345. /*++
  346. Routine name : CClientConsoleApp::PrepareForModal
  347. Routine description:
  348. Prepares for a modal dialog box.
  349. Call this function before displaying another process window or a modeless dialog that you wish
  350. to appear modal.
  351. You must call ReturnFromModal() right after the process / modeless dialog returns.
  352. Author:
  353. Eran Yariv (EranY), Apr, 2001
  354. Arguments:
  355. Return Value:
  356. None.
  357. --*/
  358. {
  359. EnableModeless(FALSE);
  360. //
  361. // Some extra precautions are required to use MAPISendMail as it
  362. // tends to enable the parent window in between dialogs (after
  363. // the login dialog, but before the send note dialog).
  364. //
  365. m_pMainWnd->EnableWindow(FALSE);
  366. m_pMainWnd->SetCapture();
  367. ::SetFocus(NULL);
  368. m_pMainWnd->m_nFlags |= WF_STAYDISABLED;
  369. } // CClientConsoleApp::PrepareForModal
  370. VOID
  371. CClientConsoleApp::ReturnFromModal ()
  372. /*++
  373. Routine name : CClientConsoleApp::ReturnFromModal
  374. Routine description:
  375. Reverts back from the PrepareForModal function.
  376. Author:
  377. Eran Yariv (EranY), Apr, 2001
  378. Arguments:
  379. Return Value:
  380. None.
  381. --*/
  382. {
  383. //
  384. // After returning from the process / modeless dialog, the window must
  385. // be re-enabled and focus returned to the frame to undo the workaround
  386. // done before at PrepareForModal().
  387. //
  388. ::ReleaseCapture();
  389. m_pMainWnd->m_nFlags &= ~WF_STAYDISABLED;
  390. m_pMainWnd->EnableWindow(TRUE);
  391. ::SetActiveWindow(NULL);
  392. m_pMainWnd->SetActiveWindow();
  393. m_pMainWnd->SetFocus();
  394. ::EnableWindow(m_pMainWnd->m_hWnd, TRUE);
  395. EnableModeless(TRUE);
  396. //
  397. // Return the Main Frame to the foreground
  398. //
  399. ::SetWindowPos(m_pMainWnd->m_hWnd,
  400. HWND_TOPMOST,
  401. 0,
  402. 0,
  403. 0,
  404. 0,
  405. SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
  406. ::SetWindowPos(m_pMainWnd->m_hWnd,
  407. HWND_NOTOPMOST,
  408. 0,
  409. 0,
  410. 0,
  411. 0,
  412. SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
  413. } // CClientConsoleApp::ReturnFromModal
  414. DWORD
  415. CClientConsoleApp::SendMail(
  416. CString& cstrFile
  417. )
  418. /*++
  419. Routine name : CClientConsoleApp::SendMail
  420. Routine description:
  421. create a new mail message with attached file
  422. Author:
  423. Alexander Malysh (AlexMay), Mar, 2000
  424. Arguments:
  425. cstrFile [in] - file name for attach
  426. Return Value:
  427. Standard Win32 error code
  428. --*/
  429. {
  430. DWORD dwRes = ERROR_SUCCESS;
  431. DBG_ENTER (TEXT("CClientConsoleApp::SendMail"), dwRes);
  432. ASSERTION(m_hInstMail);
  433. CWaitCursor wait;
  434. MAPISENDMAIL *pfnMAPISendMail;
  435. pfnMAPISendMail = (MAPISENDMAIL *)GetProcAddress(m_hInstMail, "MAPISendMail");
  436. if (!pfnMAPISendMail)
  437. {
  438. AlignedAfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
  439. dwRes = GetLastError ();
  440. return dwRes;
  441. }
  442. //
  443. // Prepare the file description (for the attachment)
  444. //
  445. MapiFileDesc fileDesc = {0};
  446. fileDesc.nPosition = (ULONG)-1;
  447. char szFileName[MAX_PATH+1];
  448. #ifdef _UNICODE
  449. _wcstombsz(szFileName, cstrFile, MAX_PATH);
  450. #else
  451. strncpy(szFileName, cstrFile, MAX_PATH);
  452. #endif
  453. fileDesc.lpszPathName = szFileName;
  454. //
  455. // Prepare the message (empty with 1 attachment)
  456. //
  457. MapiMessage message = {0};
  458. message.nFileCount = 1;
  459. message.lpFiles = &fileDesc;
  460. PrepareForModal();
  461. //
  462. // Try to send the message
  463. //
  464. dwRes = pfnMAPISendMail( 0,
  465. (ULONG_PTR)m_pMainWnd->m_hWnd,
  466. &message,
  467. MAPI_LOGON_UI | MAPI_DIALOG,
  468. 0
  469. );
  470. if (ERROR_SUCCESS != dwRes)
  471. {
  472. CALL_FAIL (GENERAL_ERR, TEXT("MAPISendMail"), dwRes);
  473. if ( dwRes != SUCCESS_SUCCESS &&
  474. dwRes != MAPI_USER_ABORT &&
  475. dwRes != MAPI_E_LOGIN_FAILURE)
  476. {
  477. AlignedAfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
  478. }
  479. dwRes = ERROR_SUCCESS;
  480. }
  481. ReturnFromModal();
  482. return dwRes;
  483. } // CClientConsoleApp::SendMail
  484. /////////////////////////////////////////////////////////////////////////////
  485. // CAboutDlg dialog used for App About
  486. class CAboutDlg : public CDialog
  487. {
  488. public:
  489. CAboutDlg();
  490. CString m_cstrVersion;
  491. // Dialog Data
  492. //{{AFX_DATA(CAboutDlg)
  493. enum { IDD = IDD_ABOUTBOX };
  494. //}}AFX_DATA
  495. // ClassWizard generated virtual function overrides
  496. //{{AFX_VIRTUAL(CAboutDlg)
  497. protected:
  498. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  499. //}}AFX_VIRTUAL
  500. // Implementation
  501. protected:
  502. //{{AFX_MSG(CAboutDlg)
  503. // No message handlers
  504. //}}AFX_MSG
  505. DECLARE_MESSAGE_MAP()
  506. };
  507. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  508. {
  509. //{{AFX_DATA_INIT(CAboutDlg)
  510. //}}AFX_DATA_INIT
  511. }
  512. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  513. {
  514. CDialog::DoDataExchange(pDX);
  515. //{{AFX_DATA_MAP(CAboutDlg)
  516. DDX_Text(pDX, IDC_ABOUT_VERSION, m_cstrVersion);
  517. //}}AFX_DATA_MAP
  518. }
  519. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  520. //{{AFX_MSG_MAP(CAboutDlg)
  521. // No message handlers
  522. //}}AFX_MSG_MAP
  523. END_MESSAGE_MAP()
  524. // App command to run the dialog
  525. void CClientConsoleApp::OnAppAbout()
  526. {
  527. DWORD dwRes = ERROR_SUCCESS;
  528. DBG_ENTER (TEXT("CClientConsoleApp::OnAppAbout"));
  529. if(!m_pMainWnd)
  530. {
  531. ASSERTION_FAILURE;
  532. return;
  533. }
  534. if (IsWinXPOS())
  535. {
  536. HICON hIcon = LoadIcon(IDR_MAINFRAME);
  537. if(!hIcon)
  538. {
  539. dwRes = GetLastError();
  540. CALL_FAIL (GENERAL_ERR, TEXT("LoadIcon"), dwRes);
  541. PopupError(dwRes);
  542. return;
  543. }
  544. if(!::ShellAbout(m_pMainWnd->m_hWnd, m_pszAppName, TEXT(""), hIcon))
  545. {
  546. dwRes = ERROR_CAN_NOT_COMPLETE;
  547. CALL_FAIL (GENERAL_ERR, TEXT("ShellAbout"), dwRes);
  548. PopupError(dwRes);
  549. return;
  550. }
  551. return;
  552. }
  553. CAboutDlg aboutDlg;
  554. //
  555. // get version
  556. //
  557. TCHAR tszVersionNum[100] = {0};
  558. TCHAR tszBuildNum[100] = {0};
  559. _sntprintf(tszVersionNum, ARR_SIZE(tszVersionNum) - 1, TEXT("%d.%d"), VERMAJOR, VERMINOR);
  560. #ifdef DEBUG
  561. _sntprintf(tszBuildNum, ARR_SIZE(tszBuildNum) - 1, TEXT("%dchk"), BUILD);
  562. #else
  563. _sntprintf(tszBuildNum, ARR_SIZE(tszBuildNum) - 1, TEXT("%d"), BUILD);
  564. #endif
  565. try
  566. {
  567. AfxFormatString2(aboutDlg.m_cstrVersion,
  568. IDS_VERSION_FORMAT,
  569. tszVersionNum,
  570. tszBuildNum);
  571. }
  572. catch(...)
  573. {
  574. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  575. CALL_FAIL (MEM_ERR, TEXT("AfxFormatString2"), dwRes);
  576. PopupError(dwRes);
  577. return;
  578. }
  579. aboutDlg.DoModal();
  580. }
  581. BOOL
  582. CClientConsoleApp::FirstInstance ()
  583. /*++
  584. Routine name : CClientConsoleApp::FirstInstance
  585. Routine description:
  586. Checks if this is the first instance of the client console.
  587. If not, activates the other instance (first found) and optionally posts messages
  588. to it with the parsed command line parameters.
  589. Author:
  590. Eran Yariv (EranY), May, 2001
  591. Arguments:
  592. Return Value:
  593. TRUE if this is the first instance of the client console, FALSE otherwise.
  594. --*/
  595. {
  596. DBG_ENTER (TEXT("CClientConsoleApp::FirstInstance"));
  597. CWnd *pWndPrev; // Previous Client console mainframe window
  598. CWnd *pWndChild; // Previous Client console top-most window
  599. DWORDLONG dwlStartupMsg;
  600. //
  601. // Determine if another window with your class name exists...
  602. //
  603. pWndPrev = CWnd::FindWindow(m_PrivateClassName, NULL);
  604. if (pWndPrev && pWndPrev->m_hWnd)
  605. {
  606. //
  607. // If so, does it have any popups?
  608. //
  609. pWndChild = pWndPrev->GetLastActivePopup();
  610. //
  611. // If iconic, restore the main window
  612. //
  613. if (pWndPrev->IsIconic())
  614. {
  615. pWndPrev->ShowWindow(SW_RESTORE);
  616. }
  617. //
  618. // Bring the main window or its popup to the foreground
  619. //
  620. pWndChild->SetForegroundWindow();
  621. if (m_cmdLineInfo.IsOpenFolder())
  622. {
  623. //
  624. // The user specified a specific startup folder.
  625. // Post a private message to the previous instance, telling it to switch to the requested folder.
  626. //
  627. pWndPrev->PostMessage (WM_CONSOLE_SET_ACTIVE_FOLDER, WPARAM(m_cmdLineInfo.GetFolderType()), 0);
  628. }
  629. dwlStartupMsg = m_cmdLineInfo.GetMessageIdToSelect();
  630. if (dwlStartupMsg)
  631. {
  632. //
  633. // The user specified a specific startup message to select.
  634. // Post a private message to the previous instance, telling it to select to the requested message.
  635. //
  636. ULARGE_INTEGER uli;
  637. uli.QuadPart = dwlStartupMsg;
  638. pWndPrev->PostMessage (WM_CONSOLE_SELECT_ITEM, WPARAM(uli.LowPart), LPARAM(uli.HighPart));
  639. }
  640. //
  641. // And we're done activating the previous instance
  642. //
  643. return FALSE;
  644. }
  645. //
  646. // First instance. Proceed as normal.
  647. //
  648. return TRUE;
  649. } // CClientConsoleApp::FirstInstance
  650. /////////////////////////////////////////////////////////////////////////////
  651. // CClientConsoleApp message handlers