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.

1664 lines
43 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // File: diagnostic.c
  4. //
  5. // Module: rasdlg.dll
  6. //
  7. // Synopsis: functions for the diagnostic tab in Dial-up preferrences
  8. // menu item under Advanced menu in connection folder
  9. //
  10. // Copyright (c) 2000-2001 Microsoft Corporation
  11. //
  12. // Author: 09/12/2000 gangz created
  13. //
  14. //+--------------------------------------------------------------------------
  15. #include "rasdlgp.h"
  16. #include "pref.h"
  17. #include "vfw.h"
  18. #include "Shellapi.h"
  19. #define WM_EL_REPORT_DONE ( WM_USER + 1 )
  20. #define WM_EL_PROGRESS_CANCEL ( WM_USER + 2 )
  21. #define WM_PB_STEPS ( WM_USER + 3 )
  22. #define WM_EL_REPORT_STATE_UPDATE ( WM_USER + 4 )
  23. #define RASDLG_DIAG_MAX_REPORT_STRING 100
  24. LONG g_lDiagTabLoaded = 0;
  25. typedef struct
  26. _ELINFO
  27. {
  28. UPINFO * pUpinfo;
  29. // Error code from Generating report functions
  30. //
  31. DWORD dwErr;
  32. DWORD dwFlagExport;
  33. WCHAR szFileOrEmail[MAX_PATH+1];
  34. // Event and thread handle for progress window
  35. //
  36. HANDLE hTProgress;
  37. HWND hwndNameOrAddress;
  38. // Flag for if user pressed cancel button on progress window
  39. //
  40. BOOL fCancelled;
  41. // Use Summarized report flag (which is less verbose )
  42. //
  43. BOOL fSimpleVerbose; //By default it is FALSE;
  44. // Window handles
  45. //
  46. HWND hwndPB;
  47. HWND hwndDlg;
  48. HWND hwndElRbView;
  49. HWND hwndElRbFile;
  50. HWND hwndElStFile;
  51. HWND hwndElEbFileName;
  52. HWND hwndElPbBrowse;
  53. HWND hwndElRbEmail;
  54. HWND hwndElEbEmailAddress;
  55. HWND hwndElCbSimpleReport;
  56. }
  57. ELINFO;
  58. typedef struct
  59. _PBARINFO
  60. {
  61. ELINFO * pElInfo;
  62. HWND hwndDlg;
  63. HWND hwndPbar;
  64. }
  65. PBARINFO;
  66. INT_PTR CALLBACK
  67. PbDlgProc(
  68. IN HWND hwndDlg,
  69. IN UINT unMsg,
  70. IN WPARAM wparam,
  71. IN LPARAM lparam );
  72. BOOL
  73. DgInit(
  74. IN HWND hwndPage,
  75. IN OUT UPARGS* pArgs );
  76. BOOL
  77. DgCommand(
  78. IN HWND hwnd,
  79. IN UPINFO* pInfo,
  80. IN WORD wNotification,
  81. IN WORD wId,
  82. IN HWND hwndCtrl );
  83. BOOL CALLBACK DgDisableAllChildWindows(
  84. IN HWND hwnd,
  85. IN LPARAM lParam );
  86. void
  87. DgTerm(
  88. IN HWND hwndPage);
  89. VOID
  90. ElTerm(
  91. IN HWND hwndDlg );
  92. DWORD
  93. ElViewLog(
  94. IN PWSTR pszFileName );
  95. BOOL
  96. ElCommand(
  97. IN ELINFO* pInfo,
  98. IN WORD wNotification,
  99. IN WORD wId,
  100. IN HWND hwndCtrl );
  101. BOOL
  102. ElInit(
  103. IN HWND hwndDlg,
  104. IN UPINFO * pUpinfo);
  105. DWORD
  106. ElGenerateReport(
  107. IN LPVOID pThreadArg );
  108. void
  109. ElEnableRadioControls(
  110. IN ELINFO * pInfo);
  111. void
  112. ElEnableAllControlsForProgress(
  113. IN ELINFO * pInfo,
  114. BOOL fEnable );
  115. BOOL
  116. ElSave(
  117. IN ELINFO * pInfo);
  118. BOOL
  119. ElAfterSave(
  120. IN ELINFO * pInfo);
  121. void
  122. ElCleanUpHandles(
  123. IN ELINFO * pInfo);
  124. INT_PTR CALLBACK
  125. ElDlgProc(
  126. IN HWND hwndDlg,
  127. IN UINT unMsg,
  128. IN WPARAM wparam,
  129. IN LPARAM lparam );
  130. // Help ID Arrays
  131. //
  132. static const DWORD g_adwDgHelp[] =
  133. {
  134. CID_DG_CB_EnableLog, HID_DG_CB_EnableLog,
  135. CID_DG_PB_Clear, HID_DG_PB_Clear,
  136. CID_DG_PB_Export, HID_DG_PB_Export,
  137. 0, 0
  138. };
  139. static const DWORD g_adwElHelp[] =
  140. {
  141. CID_EL_RB_ViewReport, HID_EL_RB_ViewReport,
  142. CID_EL_RB_File, HID_EL_RB_File,
  143. CID_EL_ST_FileName, HID_EL_ST_FileName,
  144. CID_EL_EB_FileName, HID_EL_EB_FileName,
  145. CID_EL_PB_Browse, HID_EL_PB_Browse,
  146. CID_EL_RB_Email, HID_EL_RB_Email,
  147. CID_EL_EB_EmailAddress, HID_EL_EB_EmailAddress,
  148. CID_EL_CB_SimpleReport, HID_EL_CB_SimpleReport,
  149. 0,0,
  150. };
  151. DWORD
  152. UnLoadDiagnosticDll(
  153. IN DiagnosticInfo* pInfo )
  154. {
  155. DWORD dwErr = NO_ERROR;
  156. TRACE("UnLoadDiagnosticDll");
  157. do
  158. {
  159. if ( NULL == pInfo ||
  160. NULL == pInfo->hDiagDll )
  161. {
  162. dwErr = ERROR_INVALID_PARAMETER;
  163. break;
  164. }
  165. EnterCriticalSection( &g_csDiagTab );
  166. InterlockedDecrement( &g_lDiagTabLoaded );
  167. // Unload the diagnostic library
  168. //
  169. if ( 0 == g_lDiagTabLoaded )
  170. {
  171. if ( NULL != pInfo->strDiagFuncs.UnInit )
  172. {
  173. pInfo->strDiagFuncs.UnInit();
  174. }
  175. }
  176. // Load/FreeLibrary will keep the reference counting themselves
  177. //
  178. FreeLibrary( pInfo->hDiagDll );
  179. // Reset all functional pointers
  180. //
  181. pInfo->hDiagDll = NULL;
  182. pInfo->pfnGetDiagFunc= NULL;
  183. ZeroMemory(&(pInfo->strDiagFuncs),sizeof(pInfo->strDiagFuncs));
  184. LeaveCriticalSection( &g_csDiagTab );
  185. }
  186. while(FALSE);
  187. return dwErr;
  188. }
  189. // Each call to LoadDiagnosticDll() with the same pointer has to be paired by
  190. // the call to UnLoadDiagnosticDll(), or else, things are screwed up!
  191. //
  192. DWORD
  193. LoadDiagnosticDll(
  194. IN DiagnosticInfo * pInfo)
  195. {
  196. DWORD dwErr = NO_ERROR;
  197. TRACE("LoadDiagnosticDll");
  198. do
  199. {
  200. if ( NULL == pInfo ||
  201. NULL != pInfo->hDiagDll
  202. )
  203. {
  204. dwErr = ERROR_INVALID_PARAMETER;
  205. break;
  206. }
  207. EnterCriticalSection( &g_csDiagTab );
  208. InterlockedIncrement( &g_lDiagTabLoaded );
  209. if ( !( pInfo->hDiagDll = LoadLibrary( TEXT("RASMONTR.DLL") ) ) ||
  210. !( pInfo->pfnGetDiagFunc =
  211. (DiagGetDiagnosticFunctions )GetProcAddress(
  212. pInfo->hDiagDll, "GetDiagnosticFunctions" ))
  213. )
  214. {
  215. pInfo->pfnGetDiagFunc= NULL;
  216. ZeroMemory(&(pInfo->strDiagFuncs),sizeof(pInfo->strDiagFuncs));
  217. dwErr = ERROR_CAN_NOT_COMPLETE;
  218. break;
  219. }
  220. ZeroMemory(&(pInfo->strDiagFuncs), sizeof(pInfo->strDiagFuncs));
  221. dwErr = pInfo->pfnGetDiagFunc(&pInfo->strDiagFuncs );
  222. if( NO_ERROR != dwErr ||
  223. NULL == pInfo->strDiagFuncs.Init ||
  224. NULL == pInfo->strDiagFuncs.UnInit ||
  225. NULL == pInfo->strDiagFuncs.GetReport ||
  226. NULL == pInfo->strDiagFuncs.SetAll ||
  227. NULL == pInfo->strDiagFuncs.SetAllRas ||
  228. NULL == pInfo->strDiagFuncs.GetState ||
  229. NULL == pInfo->strDiagFuncs.ClearAll
  230. )
  231. {
  232. ZeroMemory(&(pInfo->strDiagFuncs),sizeof(pInfo->strDiagFuncs));
  233. pInfo->pfnGetDiagFunc = NULL;
  234. dwErr = NO_ERROR == dwErr ? ERROR_CAN_NOT_COMPLETE : dwErr;
  235. }
  236. // Call the Init() function only when the first time rasmontr.dll is
  237. // loadded
  238. //
  239. if( 1 == g_lDiagTabLoaded )
  240. {
  241. pInfo->strDiagFuncs.Init();
  242. }
  243. LeaveCriticalSection( &g_csDiagTab );
  244. }
  245. while(FALSE);
  246. if( NO_ERROR != dwErr &&
  247. NULL != pInfo->hDiagDll )
  248. {
  249. UnLoadDiagnosticDll( pInfo );
  250. }
  251. return dwErr;
  252. } // End of Loading Diagnostic functions
  253. void DgApply(
  254. IN UPINFO* pInfo )
  255. {
  256. if(NULL == pInfo )
  257. {
  258. return;
  259. }
  260. if( NULL == pInfo->diagInfo.pfnGetDiagFunc ||
  261. NULL == pInfo->diagInfo.strDiagFuncs.SetAll )
  262. {
  263. return ;
  264. }
  265. else
  266. {
  267. BOOL fEnable = FALSE;
  268. fEnable = Button_GetCheck( pInfo->hwndDgCbEnableDiagLog );
  269. pInfo->diagInfo.strDiagFuncs.SetAll( fEnable );
  270. }
  271. return;
  272. }
  273. //For .Net 530448
  274. BOOL CALLBACK DgDisableAllChildWindows(
  275. IN HWND hwnd, // handle to child window
  276. IN LPARAM lParam )
  277. {
  278. BOOL fEnable = (BOOL)lParam;
  279. EnableWindow( hwnd, fEnable);
  280. return TRUE;
  281. }
  282. BOOL
  283. DgInit(
  284. IN HWND hwndPage,
  285. IN OUT UPARGS* pArgs )
  286. // Called on WM_INITDIALOG. 'hwndPage' is the handle of the property
  287. // page.
  288. //
  289. // Return false if focus was set, true otherwise.
  290. //
  291. {
  292. UPINFO* pInfo = NULL;
  293. HWND hwndDlg;
  294. TRACE( "DgInit" );
  295. do
  296. {
  297. pInfo = UpContext( hwndPage );
  298. if (pInfo)
  299. {
  300. break;
  301. }
  302. // Now means this is the show-only-diagnostic case
  303. hwndDlg = GetParent( hwndPage );
  304. // Allocate the context information block. Initialize it enough so that
  305. // it can be destroyed properly, and associate the context with the
  306. // window.
  307. //
  308. pInfo = Malloc( sizeof(*pInfo) );
  309. if (!pInfo)
  310. {
  311. TRACE( "Context NOT allocated in DgInit()" );
  312. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  313. UpExitInit( hwndDlg );
  314. break;
  315. }
  316. ZeroMemory( pInfo, sizeof(UPINFO) );
  317. pInfo->pArgs = pArgs;
  318. pInfo->hwndDlg = hwndDlg;
  319. pInfo->hwndFirstPage = hwndPage;
  320. pInfo->fShowOnlyDiagnostic = TRUE;
  321. if (!SetProp( hwndDlg, g_contextId, pInfo ))
  322. {
  323. TRACE(" Context NOT set" );
  324. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_UNKNOWN, NULL );
  325. Free( pInfo );
  326. pInfo = NULL;
  327. UpExitInit( hwndDlg );
  328. break;
  329. }
  330. TRACE( "Context set in DgInit()" );
  331. break;
  332. }while(FALSE);
  333. if ( pInfo )
  334. {
  335. pInfo->hwndDg = hwndPage;
  336. pInfo->hwndDgCbEnableDiagLog =
  337. GetDlgItem( hwndPage, CID_DG_CB_EnableLog );
  338. ASSERT( pInfo->hwndDgCbEnableDiagLog );
  339. pInfo->hwndDgPbClear=
  340. GetDlgItem( hwndPage, CID_DG_PB_Clear );
  341. ASSERT( pInfo->hwndDgPbClear );
  342. pInfo->hwndDgPbExport =
  343. GetDlgItem( hwndPage, CID_DG_PB_Export );
  344. ASSERT( pInfo->hwndDgPbExport );
  345. // load Diagnostic functions
  346. //
  347. // Have to zero memory, or else LoadDiagnosticDll may fail
  348. ZeroMemory( &pInfo->diagInfo, sizeof(pInfo->diagInfo ) );
  349. if ( NO_ERROR == LoadDiagnosticDll( &pInfo->diagInfo) )
  350. {
  351. BOOL fEnable = FALSE;
  352. fEnable = pInfo->diagInfo.strDiagFuncs.GetState();
  353. Button_SetCheck( pInfo->hwndDgCbEnableDiagLog,
  354. fEnable
  355. );
  356. }
  357. }
  358. //Diagnostic is only available to admind/power users
  359. if( !FIsUserAdminOrPowerUser() )
  360. {
  361. EnumChildWindows( hwndPage,
  362. DgDisableAllChildWindows,
  363. (LPARAM)FALSE);
  364. }
  365. return TRUE;
  366. }
  367. void
  368. ElEnableRadioControls(
  369. IN ELINFO * pInfo)
  370. {
  371. if( NULL == pInfo )
  372. {
  373. return;
  374. }
  375. if ( Button_GetCheck( pInfo->hwndElRbView ) )
  376. {
  377. EnableWindow( pInfo->hwndElStFile, FALSE );
  378. EnableWindow( pInfo->hwndElEbFileName, FALSE );
  379. EnableWindow( pInfo->hwndElPbBrowse, FALSE );
  380. EnableWindow( pInfo->hwndElEbEmailAddress, FALSE );
  381. }
  382. else if ( Button_GetCheck( pInfo->hwndElRbFile) )
  383. {
  384. EnableWindow( pInfo->hwndElStFile, TRUE );
  385. EnableWindow( pInfo->hwndElEbFileName, TRUE );
  386. EnableWindow( pInfo->hwndElPbBrowse, TRUE );
  387. EnableWindow( pInfo->hwndElEbEmailAddress, FALSE );
  388. }
  389. else if ( Button_GetCheck( pInfo->hwndElRbEmail ) )
  390. {
  391. EnableWindow( pInfo->hwndElStFile, FALSE );
  392. EnableWindow( pInfo->hwndElEbFileName, FALSE );
  393. EnableWindow( pInfo->hwndElPbBrowse, FALSE );
  394. EnableWindow( pInfo->hwndElEbEmailAddress, TRUE );
  395. }
  396. }
  397. BOOL
  398. ElInit(
  399. IN HWND hwndDlg,
  400. IN UPINFO * pUpinfo)
  401. {
  402. ELINFO * pInfo = NULL;
  403. TRACE("ElInit");
  404. pInfo = Malloc(sizeof(ELINFO));
  405. if( NULL == pInfo )
  406. {
  407. ErrorDlg( hwndDlg, SID_OP_LoadDlg, ERROR_NOT_ENOUGH_MEMORY, NULL );
  408. EndDialog( hwndDlg, FALSE );
  409. return TRUE;
  410. }
  411. // Initilization for ElCallBack()
  412. //
  413. ZeroMemory( pInfo, sizeof(*pInfo) );
  414. pInfo->pUpinfo = pUpinfo;
  415. pInfo->hwndDlg = hwndDlg;
  416. pInfo->hTProgress = NULL;
  417. pInfo->fSimpleVerbose = FALSE; // By default use verbose diagnostic report
  418. pInfo->dwErr = NO_ERROR;
  419. pInfo->dwFlagExport = 0;
  420. pInfo->hwndElRbView =
  421. GetDlgItem(hwndDlg, CID_EL_RB_ViewReport);
  422. ASSERT( pInfo->hwndElRbView );
  423. pInfo->hwndElRbFile =
  424. GetDlgItem(hwndDlg, CID_EL_RB_File);
  425. ASSERT( pInfo->hwndElRbFile );
  426. pInfo->hwndElStFile =
  427. GetDlgItem(hwndDlg, CID_EL_ST_FileName );
  428. ASSERT( pInfo->hwndElStFile );
  429. pInfo->hwndElEbFileName =
  430. GetDlgItem(hwndDlg, CID_EL_EB_FileName );
  431. ASSERT( pInfo->hwndElEbFileName );
  432. pInfo->hwndElPbBrowse =
  433. GetDlgItem(hwndDlg, CID_EL_PB_Browse);
  434. ASSERT(pInfo->hwndElPbBrowse);
  435. pInfo->hwndElRbEmail =
  436. GetDlgItem( hwndDlg, CID_EL_RB_Email );
  437. ASSERT( pInfo->hwndElRbEmail );
  438. pInfo->hwndElEbEmailAddress =
  439. GetDlgItem( hwndDlg, CID_EL_EB_EmailAddress );
  440. ASSERT( pInfo->hwndElEbEmailAddress );
  441. pInfo->hwndElCbSimpleReport =
  442. GetDlgItem( hwndDlg, CID_EL_CB_SimpleReport );
  443. ASSERT( pInfo->hwndElCbSimpleReport );
  444. SetWindowLongPtr( hwndDlg, DWLP_USER, (ULONG_PTR )pInfo );
  445. // Add context help button to title bar.
  446. //
  447. AddContextHelpButton( hwndDlg );
  448. // Limit the length of file name or email address to be 256
  449. //
  450. Edit_LimitText( pInfo->hwndElEbFileName, PWLEN );
  451. Edit_LimitText( pInfo->hwndElEbEmailAddress, PWLEN );
  452. // By default, enable the view edit box
  453. //
  454. Button_SetCheck( pInfo->hwndElRbView, TRUE );
  455. pInfo->hwndNameOrAddress = NULL; // For view button
  456. Button_SetCheck( pInfo->hwndElRbEmail, FALSE );
  457. Button_SetCheck( pInfo->hwndElRbFile, FALSE );
  458. ElEnableRadioControls( pInfo );
  459. return TRUE;
  460. }
  461. // Starts hh.exe on the pszFileName htm file
  462. //
  463. DWORD
  464. ElViewLog(
  465. IN PWSTR pszFileName )
  466. {
  467. WCHAR szCmd[ (MAX_PATH * 2) + 50 + 1 ];
  468. WCHAR szExe[ MAX_PATH];
  469. STARTUPINFO si;
  470. HINSTANCE h;
  471. PROCESS_INFORMATION pi;
  472. BOOL f;
  473. DWORD dwErr = NO_ERROR;
  474. do
  475. {
  476. h = FindExecutable(pszFileName, NULL,szExe);
  477. if( (HINSTANCE)31 == h )
  478. {
  479. lstrcpyW(szExe,L"hh.exe ");
  480. }
  481. else
  482. if( (HINSTANCE)32 >= h )
  483. {
  484. dwErr = GetLastError(); break;
  485. }
  486. wsprintfW( szCmd, L"\"%s\" \"%s\"", szExe, pszFileName );
  487. ZeroMemory( &si, sizeof(si) );
  488. si.cb = sizeof(si);
  489. f = CreateProcessW(
  490. NULL, // App Name
  491. szCmd, // Command Line String
  492. NULL, // Process SD
  493. NULL, // Thread SD
  494. TRUE, // Handle inheritance option
  495. 0, // Creation flags
  496. NULL, // new environment block
  497. NULL, // Current directory name
  498. &si, // Startup info
  499. &pi ); // Process info
  500. if (f)
  501. {
  502. WaitForInputIdle( pi.hProcess, INFINITE);
  503. CloseHandle( pi.hThread );
  504. CloseHandle( pi.hProcess );
  505. }
  506. else
  507. {
  508. dwErr = GetLastError();
  509. break;
  510. }
  511. }
  512. while( FALSE );
  513. return dwErr;
  514. }
  515. DWORD ElCallBack(
  516. IN GET_REPORT_STRING_CB* pInfo)
  517. {
  518. DWORD dwErr = NO_ERROR;
  519. ELINFO * pElInfo = NULL;
  520. do
  521. {
  522. if ( NULL == pInfo ||
  523. NULL == (pElInfo = (ELINFO *) pInfo->pContext)
  524. )
  525. {
  526. dwErr = ERROR_INVALID_PARAMETER;
  527. break;
  528. }
  529. if ( pElInfo->hwndDlg )
  530. {
  531. SendMessage( pElInfo->hwndDlg,
  532. WM_EL_REPORT_STATE_UPDATE,
  533. 0,
  534. (LPARAM)pInfo );
  535. }
  536. if ( pElInfo->fCancelled )
  537. {
  538. pElInfo->fCancelled = FALSE;
  539. dwErr = ERROR_CANCELLED;
  540. break;
  541. }
  542. }
  543. while(FALSE);
  544. return dwErr;
  545. }
  546. DWORD
  547. ElGenerateReport(
  548. IN LPVOID pThreadArg )
  549. {
  550. ELINFO * pInfo = (ELINFO *) pThreadArg;
  551. DWORD dwErr = NO_ERROR;
  552. TRACE("ElGenerateReport");
  553. do
  554. {
  555. if ( NULL == pInfo )
  556. {
  557. dwErr = ERROR_INVALID_PARAMETER;
  558. break;
  559. }
  560. if ( NULL == pInfo->hwndPB ||
  561. NULL == pInfo->szFileOrEmail
  562. )
  563. {
  564. dwErr = ERROR_INVALID_PARAMETER;
  565. break;
  566. }
  567. if( NULL == pInfo->pUpinfo->diagInfo.strDiagFuncs.GetReport )
  568. {
  569. dwErr = ERROR_INVALID_PARAMETER;
  570. break;
  571. }
  572. dwErr = pInfo->pUpinfo->diagInfo.strDiagFuncs.GetReport(
  573. pInfo->dwFlagExport,
  574. (PWSTR)pInfo->szFileOrEmail,
  575. (DiagGetReportCb)ElCallBack,
  576. (PVOID)pInfo);
  577. }
  578. while(FALSE);
  579. if(pInfo)
  580. {
  581. pInfo->dwErr = dwErr;
  582. // Prefast warning
  583. //
  584. SendMessage( pInfo->hwndDlg, WM_EL_REPORT_DONE, 0, 0 );
  585. }
  586. return dwErr;
  587. }
  588. void
  589. ElEnableAllControlsForProgress(
  590. IN ELINFO * pInfo,
  591. BOOL fEnable )
  592. {
  593. if ( NULL == pInfo )
  594. {
  595. return;
  596. }
  597. EnableWindow( pInfo->hwndDlg, fEnable);
  598. }
  599. DWORD
  600. ElCleanLog()
  601. {
  602. WIN32_FIND_DATA strFileData;
  603. HANDLE h = NULL;
  604. DWORD dwErr = NO_ERROR, dwLen;
  605. TCHAR szFile[ 2*MAX_PATH + 50 ];
  606. TCHAR szExt[]=TEXT("ras*.tmp.htm");
  607. do
  608. {
  609. dwLen = GetTempPath( MAX_PATH, szFile );
  610. if( 0 == dwLen ||
  611. MAX_PATH < dwLen )
  612. {
  613. dwErr = GetLastError();
  614. break;
  615. }
  616. if( NULL == lstrcat(szFile, szExt ) )
  617. {
  618. dwErr = ERROR_CAN_NOT_COMPLETE;
  619. break;
  620. }
  621. h = FindFirstFile(szFile, &strFileData );
  622. if ( INVALID_HANDLE_VALUE != h )
  623. {
  624. lstrcpy(szFile+dwLen,TEXT("\0") );
  625. if( NULL == lstrcat(szFile, strFileData.cFileName) )
  626. {
  627. dwErr = ERROR_CAN_NOT_COMPLETE;
  628. break;
  629. }
  630. DeleteFile(szFile);
  631. while( FindNextFile(h, &strFileData ) )
  632. {
  633. lstrcpy(szFile+dwLen,TEXT("\0") );
  634. if( NULL == lstrcat(szFile, strFileData.cFileName) )
  635. {
  636. dwErr = ERROR_CAN_NOT_COMPLETE;
  637. break;
  638. }
  639. DeleteFile(szFile);
  640. }
  641. }
  642. else
  643. {
  644. dwErr = GetLastError();
  645. break;
  646. }
  647. }
  648. while(FALSE);
  649. return dwErr;
  650. }
  651. BOOL
  652. ElSave(
  653. IN ELINFO * pInfo)
  654. {
  655. BOOL fViewChecked = FALSE ,fFileChecked = FALSE;
  656. BOOL fEmailChecked = FALSE, fRet = TRUE;
  657. DWORD dwThreadId;
  658. TRACE("ElSave()");
  659. do
  660. {
  661. if ( NULL == pInfo )
  662. {
  663. fRet = FALSE; // Do not set up Timer
  664. break;
  665. }
  666. if ( NULL == pInfo->pUpinfo->diagInfo.pfnGetDiagFunc ||
  667. NULL == pInfo->pUpinfo->diagInfo.strDiagFuncs.GetReport)
  668. {
  669. ErrorDlg( pInfo->hwndDlg,
  670. SID_DG_LoadDiag,
  671. ERROR_UNKNOWN,
  672. NULL );
  673. fRet = FALSE;
  674. break;
  675. }
  676. fViewChecked = Button_GetCheck( pInfo->hwndElRbView );
  677. fFileChecked = Button_GetCheck( pInfo->hwndElRbFile );
  678. fEmailChecked = Button_GetCheck( pInfo->hwndElRbEmail );
  679. {
  680. int tmp;
  681. tmp = (int)fViewChecked + (int)fFileChecked +
  682. (int)fEmailChecked ;
  683. if( 0 >= tmp ||
  684. 1 < tmp )
  685. {
  686. fRet = FALSE;
  687. break;
  688. }
  689. }
  690. if ( fViewChecked )
  691. {
  692. pInfo->dwFlagExport = RAS_DIAG_DISPLAY_FILE |(
  693. pInfo->fSimpleVerbose ? 0:
  694. RAS_DIAG_VERBOSE_REPORT);
  695. pInfo->hwndNameOrAddress = NULL;
  696. }
  697. else
  698. if ( fFileChecked )
  699. {
  700. pInfo->dwFlagExport = RAS_DIAG_EXPORT_TO_FILE |(
  701. pInfo->fSimpleVerbose ? 0:
  702. RAS_DIAG_VERBOSE_REPORT);
  703. pInfo->hwndNameOrAddress = pInfo->hwndElEbFileName;
  704. }
  705. else
  706. {
  707. pInfo->dwFlagExport = RAS_DIAG_EXPORT_TO_EMAIL |(
  708. pInfo->fSimpleVerbose ? 0:
  709. RAS_DIAG_VERBOSE_REPORT);
  710. pInfo->hwndNameOrAddress = pInfo->hwndElEbEmailAddress;
  711. }
  712. if ( pInfo->hwndNameOrAddress )
  713. {
  714. GetWindowTextW( pInfo->hwndNameOrAddress,
  715. pInfo->szFileOrEmail,
  716. PWLEN+1);
  717. if ( 0 == lstrlenW( pInfo->szFileOrEmail ) )
  718. {
  719. MsgDlgUtil( pInfo->hwndDlg,
  720. fFileChecked ? SID_EnterFileName :
  721. SID_EnterEmailAddress,
  722. NULL,
  723. g_hinstDll,
  724. SID_PopupTitle );
  725. fRet = FALSE;
  726. break;
  727. }
  728. }
  729. // Warning the user that the process can take them a long time
  730. //
  731. {
  732. MSGARGS msg;
  733. ZeroMemory( &msg, sizeof(msg) );
  734. msg.dwFlags = MB_ICONWARNING+MB_YESNO ;
  735. if ( IDNO == MsgDlgUtil( pInfo->hwndDlg,
  736. SID_DG_ExportWarning,
  737. &msg,
  738. g_hinstDll,
  739. SID_PopupTitle )
  740. )
  741. {
  742. fRet = FALSE;
  743. break;
  744. }
  745. }
  746. pInfo->fCancelled = FALSE; // Reset the cancel flag
  747. ElEnableAllControlsForProgress( pInfo, FALSE );
  748. pInfo->hwndPB =CreateDialogParam(
  749. g_hinstDll, // handle to module
  750. MAKEINTRESOURCE( DID_PB_Progress ), // dialog box template
  751. pInfo->hwndDlg, // handle to owner window
  752. PbDlgProc, // dialog box procedure
  753. (LPARAM )pInfo // initialization value
  754. );
  755. if ( NULL == pInfo->hwndPB )
  756. {
  757. ElCleanUpHandles( pInfo );
  758. ElEnableAllControlsForProgress( pInfo, TRUE);
  759. ErrorDlg( pInfo->hwndDlg,
  760. SID_OPERATION_FAILURE,
  761. pInfo->dwErr,
  762. NULL );
  763. fRet = FALSE;
  764. break;
  765. }
  766. ElCleanLog();
  767. pInfo->hTProgress = CreateThread(
  768. NULL,
  769. 0,
  770. ElGenerateReport,
  771. (LPVOID )pInfo,
  772. 0,
  773. (LPDWORD )&dwThreadId );
  774. if ( NULL == pInfo->hTProgress )
  775. {
  776. ElCleanUpHandles( pInfo );
  777. ElEnableAllControlsForProgress( pInfo, TRUE);
  778. ErrorDlg( pInfo->hwndDlg,
  779. SID_OPERATION_FAILURE,
  780. pInfo->dwErr,
  781. NULL );
  782. fRet = FALSE;
  783. break;
  784. }
  785. CenterWindow( pInfo->hwndPB, pInfo->hwndDlg );
  786. SendMessage( pInfo->hwndPB, PBM_STEPIT, 0, 0);
  787. }
  788. while(FALSE);
  789. return fRet;
  790. } // End of ElSave()
  791. void
  792. ElCleanUpHandles(
  793. IN ELINFO * pInfo)
  794. {
  795. TRACE("ElCleanUpHandles");
  796. if ( NULL == pInfo )
  797. {
  798. return ;
  799. }
  800. // Clean up all handles
  801. //
  802. if( pInfo->hTProgress)
  803. {
  804. CloseHandle( pInfo->hTProgress );
  805. pInfo->hTProgress = NULL;
  806. }
  807. if ( pInfo->hwndPB )
  808. {
  809. DestroyWindow( pInfo->hwndPB );
  810. pInfo->hwndPB = NULL;
  811. }
  812. return;
  813. }
  814. BOOL
  815. ElAfterSave(
  816. IN ELINFO * pInfo)
  817. {
  818. BOOL fRet = TRUE;
  819. BOOL fViewChecked = FALSE, fFileChecked = FALSE, fEmailChecked = FALSE;
  820. TRACE("ElAfterSave");
  821. if ( NULL == pInfo )
  822. {
  823. return FALSE;
  824. }
  825. ElCleanUpHandles( pInfo );
  826. ElEnableAllControlsForProgress( pInfo, TRUE);
  827. fViewChecked = Button_GetCheck( pInfo->hwndElRbView );
  828. fFileChecked = Button_GetCheck( pInfo->hwndElRbFile );
  829. fEmailChecked = Button_GetCheck( pInfo->hwndElRbEmail );
  830. do
  831. {
  832. if ( NO_ERROR != pInfo->dwErr ||
  833. fViewChecked && (0 == lstrlenW(pInfo->szFileOrEmail))
  834. )
  835. {
  836. ErrorDlg( pInfo->hwndDlg,
  837. fViewChecked ? SID_DG_GetLogFailure :
  838. fFileChecked ? SID_DG_ToFileFail :
  839. SID_DG_ToEmailFail ,
  840. pInfo->dwErr,
  841. NULL );
  842. fRet = FALSE;
  843. break;
  844. }
  845. if ( fViewChecked )
  846. {
  847. if( NO_ERROR != ElViewLog( pInfo->szFileOrEmail) )
  848. {
  849. fRet = FALSE;
  850. ErrorDlg( pInfo->hwndDlg,
  851. SID_DG_LoadLogFailure,
  852. GetLastError(),
  853. NULL );
  854. break;
  855. }
  856. }
  857. }
  858. while(FALSE);
  859. // Reset Error code
  860. //
  861. pInfo->dwErr = NO_ERROR;
  862. return fRet;
  863. }
  864. BOOL
  865. ElCancel(
  866. IN ELINFO * pInfo )
  867. {
  868. BOOL fRet = TRUE;
  869. TRACE("ElCancel");
  870. do
  871. {
  872. if( NULL == pInfo )
  873. {
  874. fRet = FALSE;
  875. break;
  876. }
  877. if( NULL != pInfo->hTProgress )
  878. {
  879. fRet = FALSE;
  880. break;
  881. }
  882. }
  883. while(FALSE);
  884. return fRet;
  885. }
  886. BOOL
  887. ElCommand(
  888. IN ELINFO* pInfo,
  889. IN WORD wNotification,
  890. IN WORD wId,
  891. IN HWND hwndCtrl )
  892. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  893. // is the notification code of the command. 'wId' is the control/menu
  894. // identifier of the command. 'HwndCtrl' is the control window handle of
  895. // the command.
  896. //
  897. // Returns true if processed message, false otherwise.
  898. //
  899. {
  900. BOOL fRet = FALSE;
  901. TRACE3( "ElCommand(n=%d,i=%d,c=$%x)",
  902. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  903. switch (wId)
  904. {
  905. case IDOK:
  906. {
  907. ElSave( pInfo );
  908. fRet = TRUE;
  909. }
  910. break;
  911. case IDCANCEL:
  912. {
  913. TRACE( "Cancel pressed" );
  914. if( ElCancel( pInfo ) )
  915. {
  916. EndDialog( pInfo->hwndDlg, FALSE );
  917. }
  918. fRet = TRUE;
  919. }
  920. break;
  921. case CID_EL_RB_ViewReport:
  922. {
  923. ElEnableRadioControls( pInfo );
  924. fRet = TRUE;
  925. }
  926. break;
  927. case CID_EL_RB_File:
  928. {
  929. ElEnableRadioControls( pInfo );
  930. fRet = TRUE;
  931. }
  932. break;
  933. case CID_EL_RB_Email:
  934. {
  935. ElEnableRadioControls( pInfo );
  936. fRet = TRUE;
  937. }
  938. break;
  939. case CID_EL_CB_SimpleReport:
  940. {
  941. pInfo->fSimpleVerbose =
  942. Button_GetCheck( pInfo->hwndElCbSimpleReport);
  943. }
  944. break;
  945. case CID_EL_PB_Browse:
  946. {
  947. OPENFILENAMEW strOpenFile;
  948. WCHAR szFileName[PWLEN+1] = L"\0";
  949. WCHAR szTitle[256+1] ;
  950. if ( !LoadStringW( g_hinstDll,
  951. (UINT )CID_PB_ST_StepsDone,
  952. szTitle,
  953. 256 )
  954. )
  955. {
  956. szTitle[0] = L'\0';
  957. }
  958. ZeroMemory( &strOpenFile, sizeof(strOpenFile) );
  959. strOpenFile.lStructSize = sizeof(OPENFILENAME);
  960. strOpenFile.hwndOwner = pInfo->hwndDlg;
  961. strOpenFile.lpstrFilter = L"HTML format Log files(*.htm)\0*.htm\0\0";
  962. strOpenFile.lpstrDefExt = L"htm";
  963. strOpenFile.lpstrFile = szFileName;
  964. strOpenFile.nMaxFile = PWLEN+1;
  965. strOpenFile.lpstrTitle = szTitle;
  966. strOpenFile.nMaxFileTitle = lstrlenW(szTitle);
  967. if ( GetSaveFileNameW(&strOpenFile) )
  968. {
  969. SetWindowTextW( pInfo->hwndElEbFileName,
  970. szFileName);
  971. }
  972. fRet = TRUE;
  973. }
  974. break;
  975. }
  976. return fRet;
  977. }//end of ElCommand()
  978. INT_PTR CALLBACK
  979. ElDlgProc(
  980. IN HWND hwndDlg,
  981. IN UINT unMsg,
  982. IN WPARAM wparam,
  983. IN LPARAM lparam )
  984. {
  985. static DWORD dwCount = 0;
  986. switch (unMsg)
  987. {
  988. case WM_INITDIALOG:
  989. {
  990. return ElInit(hwndDlg, (UPINFO*)lparam);
  991. }
  992. case WM_HELP:
  993. case WM_CONTEXTMENU:
  994. {
  995. ContextHelp( g_adwElHelp, hwndDlg, unMsg, wparam, lparam );
  996. break;
  997. }
  998. case WM_EL_REPORT_STATE_UPDATE:
  999. {
  1000. GET_REPORT_STRING_CB * pReportCB = NULL;
  1001. ELINFO* pInfo = (ELINFO *)GetWindowLongPtr( hwndDlg, DWLP_USER );
  1002. ASSERT (pInfo);
  1003. if ( NULL == pInfo )
  1004. {
  1005. break;
  1006. }
  1007. pReportCB = (GET_REPORT_STRING_CB *)lparam;
  1008. if ( NULL == pReportCB )
  1009. {
  1010. break;
  1011. }
  1012. SendMessage( pInfo->hwndPB, WM_PB_STEPS, 0 , lparam);
  1013. }
  1014. break;
  1015. case WM_EL_REPORT_DONE:
  1016. {
  1017. ELINFO* pInfo = (ELINFO *)GetWindowLongPtr( hwndDlg, DWLP_USER );
  1018. ASSERT (pInfo);
  1019. if ( NULL == pInfo )
  1020. {
  1021. break;
  1022. }
  1023. if ( ElAfterSave( pInfo ) )
  1024. {
  1025. EndDialog( pInfo->hwndDlg,TRUE );
  1026. }
  1027. }
  1028. break;
  1029. case WM_EL_PROGRESS_CANCEL:
  1030. {
  1031. ELINFO* pInfo = (ELINFO *)GetWindowLongPtr( hwndDlg, DWLP_USER );
  1032. ASSERT (pInfo);
  1033. if ( NULL == pInfo )
  1034. {
  1035. break;
  1036. }
  1037. pInfo->fCancelled = TRUE;
  1038. }
  1039. break;
  1040. case WM_COMMAND:
  1041. {
  1042. ELINFO* pInfo = (ELINFO *)GetWindowLongPtr( hwndDlg, DWLP_USER );
  1043. ASSERT (pInfo);
  1044. if ( NULL == pInfo )
  1045. {
  1046. break;
  1047. }
  1048. return ElCommand( pInfo,
  1049. HIWORD( wparam ),
  1050. LOWORD( wparam ),
  1051. (HWND )lparam );
  1052. break;
  1053. }
  1054. case WM_DESTROY:
  1055. {
  1056. ElTerm( hwndDlg );
  1057. break;
  1058. }
  1059. }
  1060. return FALSE;
  1061. }
  1062. VOID
  1063. ElTerm(
  1064. IN HWND hwndDlg )
  1065. // Dialog termination. Releases the context block. 'HwndDlg' is the
  1066. // handle of a dialog.
  1067. //
  1068. {
  1069. ELINFO* pInfo = NULL;
  1070. TRACE( "ElTerm" );
  1071. pInfo = (ELINFO* )GetWindowLongPtr( hwndDlg, DWLP_USER );
  1072. if (pInfo)
  1073. {
  1074. Free( pInfo );
  1075. TRACE( "Context freed" );
  1076. }
  1077. }//end of ElTerm()
  1078. void
  1079. DgTerm(
  1080. IN HWND hwndPage)
  1081. {
  1082. UPINFO* pInfo = NULL;
  1083. TRACE( "DgTerm" );
  1084. return;
  1085. pInfo = UpContext( hwndPage );
  1086. if(pInfo)
  1087. {
  1088. UnLoadDiagnosticDll( &pInfo->diagInfo);
  1089. Free( pInfo );
  1090. }
  1091. RemoveProp( GetParent( hwndPage ), g_contextId );
  1092. }
  1093. void
  1094. DgEnableButtons(
  1095. IN UPINFO * pInfo,
  1096. IN BOOL fEnable )
  1097. {
  1098. EnableWindow( pInfo->hwndDgCbEnableDiagLog, fEnable );
  1099. EnableWindow( pInfo->hwndDgPbClear, fEnable );
  1100. EnableWindow( pInfo->hwndDgPbExport, fEnable );
  1101. }
  1102. BOOL
  1103. DgCommand(
  1104. IN HWND hwnd,
  1105. IN UPINFO* pInfo,
  1106. IN WORD wNotification,
  1107. IN WORD wId,
  1108. IN HWND hwndCtrl )
  1109. // Called on WM_COMMAND. 'PInfo' is the dialog context. 'WNotification'
  1110. // is the notification code of the command. 'wId' is the control/menu
  1111. // identifier of the command. 'HwndCtrl' is the control window handle of
  1112. // the command.
  1113. //
  1114. // Returns true if processed message, false otherwise.
  1115. //
  1116. {
  1117. BOOL fRet = FALSE;
  1118. TRACE3( "DgCommand(n=%d,i=%d,c=$%x)",
  1119. (DWORD )wNotification, (DWORD )wId, (ULONG_PTR )hwndCtrl );
  1120. switch (wId)
  1121. {
  1122. case CID_DG_CB_EnableLog:
  1123. {
  1124. if ( NULL == pInfo->diagInfo.pfnGetDiagFunc ||
  1125. NULL == pInfo->diagInfo.strDiagFuncs.SetAll
  1126. )
  1127. {
  1128. ErrorDlg( hwnd, SID_DG_LoadDiag, ERROR_UNKNOWN, NULL );
  1129. break;
  1130. }
  1131. }
  1132. break;
  1133. case CID_DG_PB_Clear:
  1134. {
  1135. if( NULL == pInfo->diagInfo.pfnGetDiagFunc ||
  1136. NULL == pInfo->diagInfo.strDiagFuncs.GetState ||
  1137. NULL == pInfo->diagInfo.strDiagFuncs.ClearAll )
  1138. {
  1139. ErrorDlg( hwnd, SID_DG_LoadDiag, ERROR_UNKNOWN, NULL );
  1140. }
  1141. else
  1142. {
  1143. pInfo->diagInfo.strDiagFuncs.ClearAll();
  1144. }
  1145. #if 0
  1146. Button_SetCheck( pInfo->hwndDgCbEnableDiagLog,
  1147. pInfo->diagInfo.strDiagFuncs.GetState()
  1148. );
  1149. #endif
  1150. fRet = TRUE;
  1151. break;
  1152. }
  1153. case CID_DG_PB_Export:
  1154. {
  1155. int nStatus;
  1156. if( NULL == pInfo->diagInfo.pfnGetDiagFunc ||
  1157. NULL == pInfo->diagInfo.strDiagFuncs.GetReport)
  1158. {
  1159. ErrorDlg( hwnd, SID_DG_LoadDiag, ERROR_UNKNOWN, NULL );
  1160. }
  1161. else
  1162. {
  1163. nStatus =
  1164. (BOOL )DialogBoxParam(
  1165. g_hinstDll,
  1166. MAKEINTRESOURCE( DID_EL_ExportLog ),
  1167. hwnd,
  1168. ElDlgProc,
  1169. (LPARAM )pInfo );
  1170. if (nStatus == -1)
  1171. {
  1172. ErrorDlg( hwnd, SID_DG_LoadDiag, ERROR_UNKNOWN, NULL );
  1173. }
  1174. }
  1175. fRet = TRUE;
  1176. break;
  1177. }
  1178. }
  1179. return fRet;
  1180. }
  1181. INT_PTR CALLBACK
  1182. DgDlgProc(
  1183. IN HWND hwnd,
  1184. IN UINT unMsg,
  1185. IN WPARAM wparam,
  1186. IN LPARAM lparam )
  1187. // DialogProc callback for the Diagnostic page of the Entry property sheet.
  1188. // Parameters and return value are as described for standard windows
  1189. // 'DialogProc's.
  1190. //
  1191. {
  1192. switch (unMsg)
  1193. {
  1194. case WM_INITDIALOG:
  1195. {
  1196. return DgInit( hwnd, (UPARGS* )(((PROPSHEETPAGE* )lparam)->lParam) );
  1197. }
  1198. case WM_HELP:
  1199. case WM_CONTEXTMENU:
  1200. {
  1201. ContextHelp( g_adwDgHelp, hwnd, unMsg, wparam, lparam );
  1202. break;
  1203. }
  1204. case WM_COMMAND:
  1205. {
  1206. UPINFO* pInfo = UpContext (hwnd);
  1207. ASSERT(pInfo);
  1208. if ( NULL == pInfo )
  1209. {
  1210. break;
  1211. }
  1212. return DgCommand( hwnd,
  1213. pInfo,
  1214. HIWORD( wparam ),
  1215. LOWORD( wparam ),
  1216. (HWND )lparam );
  1217. }
  1218. break;
  1219. case WM_NOTIFY:
  1220. {
  1221. switch (((NMHDR* )lparam)->code)
  1222. {
  1223. case PSN_APPLY:
  1224. {
  1225. UPINFO* pInfo = UpContext (hwnd);
  1226. ASSERT(pInfo);
  1227. // If not a show-only-diagnostic case,
  1228. // The diagnostic enabling/disabling should be done
  1229. // in the by GeDlgProc()
  1230. //
  1231. if ( NULL == pInfo ||
  1232. !pInfo->fShowOnlyDiagnostic )
  1233. {
  1234. break;
  1235. }
  1236. SetWindowLong(
  1237. hwnd,
  1238. DWLP_MSGRESULT,
  1239. PSNRET_NOERROR );
  1240. return TRUE;
  1241. }
  1242. }
  1243. break;
  1244. }
  1245. case WM_DESTROY:
  1246. {
  1247. UPINFO* pInfo = UpContext (hwnd);
  1248. // If not a show-only-diagnostic case,
  1249. // The freeing pInfo memory should be done
  1250. // in the by GeDlgProc()
  1251. //
  1252. if ( NULL == pInfo ||
  1253. !pInfo->fShowOnlyDiagnostic )
  1254. {
  1255. break;
  1256. }
  1257. DgTerm( hwnd );
  1258. break;
  1259. }
  1260. }
  1261. return FALSE;
  1262. }
  1263. INT_PTR CALLBACK
  1264. PbDlgProc(
  1265. IN HWND hwndDlg,
  1266. IN UINT unMsg,
  1267. IN WPARAM wparam,
  1268. IN LPARAM lparam )
  1269. {
  1270. static HCURSOR hCursorDefault = NULL;
  1271. static HCURSOR hCursor = NULL;
  1272. switch (unMsg)
  1273. {
  1274. case WM_INITDIALOG:
  1275. {
  1276. HWND hwndTmp = NULL;
  1277. WNDPROC pOldWndProc = NULL;
  1278. hCursor = LoadCursor( NULL, IDC_WAIT );
  1279. if ( hCursor )
  1280. {
  1281. hCursorDefault = (HCURSOR)SetClassLongPtr( hwndDlg,
  1282. GCLP_HCURSOR,
  1283. (LONG_PTR)hCursor);
  1284. }
  1285. hwndTmp = GetDlgItem(hwndDlg,CID_PB_ProgressBar);
  1286. if ( hwndTmp )
  1287. {
  1288. SendMessage( hwndTmp,
  1289. PBM_SETRANGE,
  1290. 0, MAKELPARAM(0, 100));
  1291. SendMessage( hwndTmp,
  1292. PBM_SETSTEP,
  1293. (WPARAM)1,
  1294. 0);
  1295. }
  1296. }
  1297. break;
  1298. case WM_DESTROY:
  1299. {
  1300. if ( hCursorDefault )
  1301. {
  1302. SetClassLongPtr( hwndDlg,
  1303. GCLP_HCURSOR,
  1304. (LONG_PTR) (hCursorDefault) );
  1305. }
  1306. }
  1307. break;
  1308. case WM_COMMAND:
  1309. {
  1310. switch ( LOWORD( wparam ) )
  1311. {
  1312. case IDCANCEL:
  1313. {
  1314. EnableWindow( GetDlgItem(hwndDlg, IDCANCEL),
  1315. FALSE);
  1316. PostMessage( GetParent(hwndDlg),
  1317. WM_EL_PROGRESS_CANCEL, 0, 0 );
  1318. }
  1319. break;
  1320. }
  1321. }
  1322. break;
  1323. case PBM_STEPIT:
  1324. {
  1325. if( GetDlgItem(hwndDlg,CID_PB_ProgressBar) )
  1326. {
  1327. SendMessage( GetDlgItem(hwndDlg,CID_PB_ProgressBar),
  1328. PBM_STEPIT, 0 , 0);
  1329. }
  1330. }
  1331. break;
  1332. case WM_PB_STEPS:
  1333. {
  1334. WCHAR szStepText[45], szBuf[20];
  1335. WCHAR szJobText[RASDLG_DIAG_MAX_REPORT_STRING]=L"\0";
  1336. DWORD dwLen = 1;
  1337. GET_REPORT_STRING_CB * pReportCB = NULL;
  1338. pReportCB = (GET_REPORT_STRING_CB *)lparam;
  1339. if ( NULL == pReportCB )
  1340. {
  1341. break;
  1342. }
  1343. if( pReportCB->pwszState )
  1344. {
  1345. dwLen = lstrlenW(pReportCB->pwszState) + 1;
  1346. if( RASDLG_DIAG_MAX_REPORT_STRING <= dwLen )
  1347. {
  1348. dwLen = RASDLG_DIAG_MAX_REPORT_STRING;
  1349. }
  1350. if( dwLen < 1 )
  1351. {
  1352. dwLen = 1;
  1353. }
  1354. lstrcpynW( szJobText, pReportCB->pwszState, dwLen );
  1355. SetWindowTextW( GetDlgItem(hwndDlg, CID_PB_ST_State),
  1356. szJobText );
  1357. }
  1358. // Prefast warning
  1359. //
  1360. if ( LoadStringW( g_hinstDll,
  1361. (UINT )SID_PB_StepsDone,
  1362. szBuf,
  1363. sizeof(szBuf) / sizeof(WCHAR) )
  1364. )
  1365. {
  1366. wsprintfW(szStepText, L"%s: %ld%%", szBuf,
  1367. ( pReportCB->dwPercent > 100 ) ?
  1368. 100 : pReportCB->dwPercent );
  1369. SetWindowTextW( GetDlgItem(hwndDlg, CID_PB_ST_StepsDone ),
  1370. szStepText );
  1371. }
  1372. if( GetDlgItem(hwndDlg,CID_PB_ProgressBar) )
  1373. {
  1374. SendMessage( GetDlgItem(hwndDlg,CID_PB_ProgressBar),
  1375. PBM_SETPOS,
  1376. (WPARAM)(pReportCB->dwPercent),
  1377. 0 );
  1378. }
  1379. }
  1380. break;
  1381. }
  1382. return FALSE;
  1383. }