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.

651 lines
18 KiB

  1. // FileLogs.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <strsafe.h>
  5. #include "smlogcfg.h"
  6. #include "fileprop.h"
  7. #include "smlogs.h"
  8. #include "smcfgmsg.h"
  9. #include "smlogqry.h"
  10. #include "fileprop.h" // for eValueRange
  11. #include "FileLogs.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. USE_HANDLE_MACROS("SMLOGCFG(filelogs.cpp)");
  18. static ULONG
  19. s_aulHelpIds[] =
  20. {
  21. IDC_FILES_FOLDER_EDIT, IDH_FILES_FOLDER_EDIT,
  22. IDC_FILES_FOLDER_BTN, IDH_FILES_FOLDER_BTN,
  23. IDC_FILES_FILENAME_EDIT, IDH_FILES_FILENAME_EDIT,
  24. IDC_FILES_SIZE_MAX_BTN, IDH_FILES_SIZE_MAX_BTN,
  25. IDC_FILES_SIZE_LIMIT_EDIT,IDH_FILES_SIZE_LIMIT_EDIT,
  26. IDC_FILES_SIZE_LIMIT_BTN, IDH_FILES_SIZE_LIMIT_BTN,
  27. 0,0
  28. };
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CFileLogs dialog
  31. CFileLogs::CFileLogs(CWnd* pParent /*=NULL*/)
  32. : CDialog(CFileLogs::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(CFileLogs)
  35. m_strFileBaseName = L"";
  36. m_strFolderName = L"";
  37. m_nFileSizeRdo = 0;
  38. m_bAutoNameSuffix = FALSE;
  39. m_dwMaxSize = 0;
  40. m_dwFocusControl = 0;
  41. //}}AFX_DATA_INIT
  42. }
  43. void CFileLogs::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CFilesProperty::eValueRange eMaxFileSize;
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CFileLogs)
  48. DDX_Text(pDX, IDC_FILES_FILENAME_EDIT, m_strFileBaseName);
  49. DDV_MaxChars(pDX, m_strFileBaseName, (SLQ_MAX_BASE_NAME_LEN));
  50. DDX_Text(pDX, IDC_FILES_FOLDER_EDIT, m_strFolderName);
  51. DDV_MaxChars(pDX, m_strFolderName, MAX_PATH);
  52. DDX_Radio(pDX, IDC_FILES_SIZE_MAX_BTN, m_nFileSizeRdo);
  53. if ( SLF_BIN_FILE == m_dwLogFileTypeValue ) {
  54. eMaxFileSize = CFilesProperty::eMaxCtrSeqBinFileLimit;
  55. } else if ( SLF_SEQ_TRACE_FILE == m_dwLogFileTypeValue ) {
  56. eMaxFileSize = CFilesProperty::eMaxTrcSeqBinFileLimit;
  57. } else {
  58. eMaxFileSize = CFilesProperty::eMaxFileLimit;
  59. }
  60. ValidateTextEdit(pDX, IDC_FILES_SIZE_LIMIT_EDIT, 9, &m_dwMaxSize, CFilesProperty::eMinFileLimit, eMaxFileSize);
  61. //}}AFX_DATA_MAP
  62. if ( pDX->m_bSaveAndValidate ) {
  63. if (((CButton *)GetDlgItem(IDC_FILES_SIZE_MAX_BTN))->GetCheck() == 1) {
  64. m_dwMaxSizeInternal = SLQ_DISK_MAX_SIZE;
  65. } else {
  66. m_dwMaxSizeInternal = m_dwMaxSize;
  67. }
  68. }
  69. }
  70. BEGIN_MESSAGE_MAP(CFileLogs, CDialog)
  71. //{{AFX_MSG_MAP(CFileLogs)
  72. ON_WM_HELPINFO()
  73. ON_WM_CONTEXTMENU()
  74. ON_BN_CLICKED(IDC_FILES_FOLDER_BTN, OnFilesFolderBtn)
  75. ON_EN_CHANGE(IDC_FILES_FILENAME_EDIT, OnChangeFilesFilenameEdit)
  76. ON_EN_CHANGE(IDC_FILES_FOLDER_EDIT, OnChangeFilesFolderEdit)
  77. ON_EN_CHANGE(IDC_FILES_SIZE_LIMIT_EDIT, OnChangeFilesSizeLimitEdit)
  78. ON_BN_CLICKED(IDC_FILES_SIZE_LIMIT_BTN, OnFilesSizeLimitBtn)
  79. ON_NOTIFY(UDN_DELTAPOS, IDC_FILES_SIZE_LIMIT_SPIN, OnDeltaposFilesSizeLimitSpin)
  80. ON_BN_CLICKED(IDC_FILES_SIZE_MAX_BTN, OnFilesSizeMaxBtn)
  81. ON_EN_KILLFOCUS(IDC_FILES_FILENAME_EDIT, OnKillfocusFilesFilenameEdit)
  82. ON_EN_KILLFOCUS(IDC_FILES_FOLDER_EDIT, OnKillfocusFilesFolderEdit)
  83. ON_EN_KILLFOCUS(IDC_FILES_SIZE_LIMIT_EDIT, OnKillfocusFilesSizeLimitEdit)
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CFileLogs message handlers
  88. int
  89. BrowseCallbackProc(
  90. HWND hwnd,
  91. UINT uMsg,
  92. LPARAM /*lParam*/,
  93. LPARAM lpData
  94. )
  95. /*++
  96. Routine Description:
  97. Callback function for SHBrowseForFolder
  98. Arguments:
  99. hwnd - Handle to the browse dialog box
  100. uMsg - Identifying the reason for the callback
  101. lParam - Message parameter
  102. lpData - Application-defined value given in BROWSEINFO.lParam
  103. Return Value:
  104. 0
  105. --*/
  106. {
  107. if (uMsg == BFFM_INITIALIZED && NULL != lpData ) {
  108. INT iBufLen = MAX_PATH+1;
  109. WCHAR* szBuffer = NULL;
  110. CFileLogs* pdlgFileLogs = NULL;
  111. pdlgFileLogs = (CFileLogs*) lpData;
  112. if ( NULL != pdlgFileLogs ) {
  113. szBuffer = new WCHAR [ iBufLen ];
  114. if ( NULL != szBuffer ) {
  115. // GetDlgItemText size includes space for NULL character.
  116. if ( pdlgFileLogs->GetDlgItemText (IDC_FILES_FOLDER_EDIT, szBuffer, iBufLen)) {
  117. SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) szBuffer);
  118. }
  119. delete [] szBuffer;
  120. }
  121. }
  122. }
  123. return 0;
  124. }
  125. void
  126. CFileLogs::OnFilesFolderBtn()
  127. {
  128. HRESULT hr = NOERROR;
  129. BROWSEINFO bi;
  130. LPMALLOC pMalloc = NULL;
  131. LPITEMIDLIST pidlItem = NULL;
  132. LPITEMIDLIST pidlRoot = NULL;
  133. INT iBufLen = MAX_PATH;
  134. WCHAR* szFolderName;
  135. CString strTitle;
  136. ResourceStateManager rsm;
  137. m_hModule = (HINSTANCE)GetModuleHandleW (_CONFIG_DLL_NAME_W_);
  138. hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_DRIVES, &pidlRoot);
  139. if ( SUCCEEDED ( hr ) ) {
  140. hr = SHGetMalloc(&pMalloc);
  141. }
  142. if ( FAILED ( hr ) || pMalloc == NULL || pidlRoot == NULL) {
  143. //
  144. // Something wrong from SHELL api, just return
  145. //
  146. return;
  147. }
  148. // SHBrowseForFolder restricts the return buffer to length MAX_PATH
  149. szFolderName = new WCHAR [ iBufLen ];
  150. if ( NULL != szFolderName ) {
  151. bi.hwndOwner = m_hWnd;
  152. bi.pidlRoot = (LPCITEMIDLIST)pidlRoot;
  153. bi.pszDisplayName = szFolderName;
  154. strTitle.LoadString ( IDS_SELECT_FILE_FOLDER );
  155. bi.lpszTitle = strTitle.GetBuffer ( strTitle.GetLength() );
  156. bi.ulFlags = BIF_RETURNONLYFSDIRS |
  157. BIF_NEWDIALOGSTYLE |
  158. BIF_RETURNFSANCESTORS |
  159. BIF_DONTGOBELOWDOMAIN ;
  160. bi.lpfn = BrowseCallbackProc;
  161. bi.lParam = (LPARAM)this;
  162. pidlItem = SHBrowseForFolder (&bi);
  163. if ( pidlItem != NULL ) {
  164. SHGetPathFromIDList(pidlItem, szFolderName);
  165. SetDlgItemText (IDC_FILES_FOLDER_EDIT, szFolderName);
  166. } // else ignore if they canceled out
  167. delete [] szFolderName;
  168. } // else malloc failed
  169. // Todo; Error message
  170. //
  171. // Free the ITEMIDLIST structure returned from shell
  172. //
  173. pMalloc->Free(pidlRoot);
  174. if (pidlItem != NULL) {
  175. pMalloc->Free(pidlItem);
  176. }
  177. }
  178. void CFileLogs::OnChangeFilesFilenameEdit()
  179. {
  180. CString strOldText;
  181. // When the user hits OK in the folder browse dialog,
  182. // the file name might not have changed.
  183. strOldText = m_strFileBaseName;
  184. UpdateData( TRUE );
  185. if ( 0 != strOldText.Compare ( m_strFileBaseName ) ) {
  186. // UpdateSampleFileName();
  187. }
  188. }
  189. void CFileLogs::OnChangeFilesFolderEdit()
  190. {
  191. CString strOldText;
  192. // When the user hits OK in the folder browse dialog,
  193. // the folder name might not have changed.
  194. strOldText = m_strFolderName;
  195. UpdateData( TRUE );
  196. if ( 0 != strOldText.Compare ( m_strFolderName ) ) {
  197. // UpdateSampleFileName();
  198. }
  199. }
  200. void CFileLogs::OnChangeFilesSizeLimitEdit()
  201. {
  202. UpdateData( TRUE );
  203. }
  204. void CFileLogs::OnFilesSizeLimitBtn()
  205. {
  206. FileSizeBtn(FALSE);
  207. }
  208. void CFileLogs::OnDeltaposFilesSizeLimitSpin(NMHDR* pNMHDR, LRESULT* pResult)
  209. {
  210. CFilesProperty::eValueRange eMaxFileSize;
  211. if ( SLF_BIN_FILE == m_dwLogFileTypeValue ) {
  212. eMaxFileSize = CFilesProperty::eMaxCtrSeqBinFileLimit;
  213. } else if ( SLF_SEQ_TRACE_FILE == m_dwLogFileTypeValue ) {
  214. eMaxFileSize = CFilesProperty::eMaxTrcSeqBinFileLimit;
  215. } else {
  216. eMaxFileSize = CFilesProperty::eMaxFileLimit;
  217. }
  218. OnDeltaposSpin(pNMHDR, pResult, & m_dwMaxSize, CFilesProperty::eMinFileLimit, eMaxFileSize);
  219. }
  220. void CFileLogs::OnFilesSizeMaxBtn()
  221. {
  222. FileSizeBtn(FALSE);
  223. }
  224. void CFileLogs::OnKillfocusFilesFilenameEdit()
  225. {
  226. CString strOldText;
  227. strOldText = m_strFileBaseName;
  228. UpdateData ( TRUE );
  229. }
  230. void CFileLogs::OnKillfocusFilesFolderEdit()
  231. {
  232. CString strOldText;
  233. strOldText = m_strFolderName;
  234. UpdateData ( TRUE );
  235. }
  236. void CFileLogs::OnKillfocusFilesSizeLimitEdit()
  237. {
  238. DWORD dwOldValue;
  239. dwOldValue = m_dwMaxSize;
  240. UpdateData ( TRUE );
  241. }
  242. BOOL CFileLogs::OnInitDialog()
  243. {
  244. BOOL bLimitBtnSet;
  245. BOOL bReturn = TRUE;
  246. CDialog::OnInitDialog();
  247. // set the buttons
  248. m_nFileSizeRdo = 1;
  249. if (m_dwMaxSizeInternal == SLQ_DISK_MAX_SIZE) {
  250. m_nFileSizeRdo = 0;
  251. m_dwMaxSize = 1; // default
  252. } else {
  253. m_nFileSizeRdo = 1;
  254. m_dwMaxSize = m_dwMaxSizeInternal;
  255. }
  256. bLimitBtnSet = (m_nFileSizeRdo == 1);
  257. GetDlgItem(IDC_FILES_SIZE_LIMIT_EDIT)->EnableWindow(bLimitBtnSet);
  258. // Disable the file browse button for remote machines
  259. ASSERT ( NULL != m_pLogQuery );
  260. if ( NULL != m_pLogQuery ) {
  261. if ( !m_pLogQuery->GetLogService()->IsLocalMachine() ) {
  262. GetDlgItem ( IDC_FILES_FOLDER_BTN )->EnableWindow ( FALSE );
  263. }
  264. }
  265. UpdateData(FALSE);
  266. FileSizeBtnEnable();
  267. FileSizeBtn(FALSE);
  268. if ( 0 != m_dwFocusControl ) {
  269. GetDlgItem ( m_dwFocusControl )->SetFocus();
  270. bReturn = FALSE;
  271. }
  272. return bReturn; // return TRUE unless you set the focus to a control
  273. // EXCEPTION: OCX Property Pages should return FALSE
  274. }
  275. void CFileLogs::OnOK()
  276. {
  277. // load data from dialog
  278. if ( UpdateData (TRUE) ) {
  279. if ( IsValidLocalData() ) {
  280. CDialog::OnOK();
  281. }
  282. }
  283. }
  284. void
  285. CFileLogs::OnDeltaposSpin(
  286. NMHDR *pNMHDR,
  287. LRESULT *pResult,
  288. DWORD *pValue,
  289. DWORD dMinValue,
  290. DWORD dMaxValue)
  291. {
  292. NM_UPDOWN* pNMUpDown;
  293. LONG lValue;
  294. BOOL bResult = TRUE;
  295. UpdateData(TRUE);
  296. ASSERT(dMinValue <= dMaxValue);
  297. if ( NULL != pNMHDR
  298. && NULL != pResult
  299. && NULL != pValue )
  300. {
  301. pNMUpDown = (NM_UPDOWN *) pNMHDR;
  302. lValue = (LONG) (*pValue);
  303. if (lValue == INVALID_DWORD) {
  304. lValue = (DWORD) dMinValue;
  305. } else {
  306. if ( ((lValue >= (LONG) dMinValue + 1) && (pNMUpDown->iDelta > 0))
  307. || ((lValue <= (LONG) dMaxValue - 1) && (pNMUpDown->iDelta < 0)))
  308. {
  309. lValue += (pNMUpDown->iDelta * -1);
  310. if (lValue > (LONG) dMaxValue) {
  311. lValue = (DWORD) dMaxValue;
  312. } else if (lValue < (LONG) dMinValue) {
  313. lValue = (DWORD) dMinValue;
  314. }
  315. } else if (lValue > (LONG) dMaxValue) {
  316. lValue = (DWORD) dMaxValue;
  317. } else if (lValue < (LONG) dMinValue) {
  318. lValue = (DWORD) dMinValue;
  319. } else {
  320. bResult = FALSE;
  321. }
  322. }
  323. if (bResult) {
  324. *pValue = lValue;
  325. UpdateData(FALSE);
  326. }
  327. *pResult = 0;
  328. } else {
  329. ASSERT ( FALSE );
  330. }
  331. return;
  332. }
  333. void CFileLogs::FileSizeBtnEnable()
  334. {
  335. if ( ( SLF_BIN_CIRC_FILE == m_dwLogFileTypeValue )
  336. ||( SLF_CIRC_TRACE_FILE == m_dwLogFileTypeValue ) ) {
  337. ((CButton *)GetDlgItem(IDC_FILES_SIZE_LIMIT_BTN))->SetCheck(1);
  338. ((CButton *)GetDlgItem(IDC_FILES_SIZE_MAX_BTN))->SetCheck(0);
  339. GetDlgItem(IDC_FILES_SIZE_MAX_BTN)->EnableWindow ( FALSE );
  340. } else {
  341. GetDlgItem(IDC_FILES_SIZE_MAX_BTN)->EnableWindow ( TRUE );
  342. }
  343. }
  344. void CFileLogs::FileSizeBtn(BOOL bInit)
  345. {
  346. INT m_nFileSizeOld;
  347. m_nFileSizeOld = m_nFileSizeRdo;
  348. UpdateData ( TRUE );
  349. if (bInit || (m_nFileSizeOld != m_nFileSizeRdo)) {
  350. BOOL bMaxBtnSet, bLimitBtnSet;
  351. // *** This can be replaced since DDX_Radio implemented.
  352. // get btn state
  353. bMaxBtnSet = ((CButton *)GetDlgItem(IDC_FILES_SIZE_MAX_BTN))->GetCheck() == 1;
  354. bLimitBtnSet = ((CButton *)GetDlgItem(IDC_FILES_SIZE_LIMIT_BTN))->GetCheck() == 1;
  355. ASSERT (bLimitBtnSet != bMaxBtnSet);
  356. GetDlgItem(IDC_FILES_SIZE_LIMIT_EDIT)->EnableWindow(bLimitBtnSet);
  357. GetDlgItem(IDC_FILES_SIZE_LIMIT_SPIN)->EnableWindow(bLimitBtnSet);
  358. GetDlgItem(IDC_FILES_SIZE_LIMIT_UNITS)->EnableWindow(bLimitBtnSet);
  359. }
  360. }
  361. BOOL CFileLogs::IsValidLocalData()
  362. {
  363. BOOL bIsValid = TRUE;
  364. CFilesProperty::eValueRange eMaxFileSize;
  365. INT iPrevLength = 0;
  366. ResourceStateManager rsm;
  367. // assumes UpdateData has been called
  368. // Trim folder name and file name before validation
  369. iPrevLength = m_strFolderName.GetLength();
  370. m_strFolderName.TrimLeft();
  371. m_strFolderName.TrimRight();
  372. if ( iPrevLength != m_strFolderName.GetLength() ) {
  373. SetDlgItemText ( IDC_FILES_FOLDER_EDIT, m_strFolderName );
  374. }
  375. iPrevLength = m_strFileBaseName.GetLength();
  376. m_strFileBaseName.TrimLeft();
  377. m_strFileBaseName.TrimRight();
  378. if ( iPrevLength != m_strFileBaseName.GetLength() ) {
  379. SetDlgItemText ( IDC_FILES_FILENAME_EDIT, m_strFileBaseName );
  380. }
  381. if ( bIsValid ) {
  382. if ( m_strFolderName.IsEmpty() ) {
  383. CString strMessage;
  384. strMessage.LoadString ( IDS_FILE_ERR_NOFOLDERNAME );
  385. MessageBox ( strMessage, m_pLogQuery->GetLogName(), MB_OK | MB_ICONERROR);
  386. (GetDlgItem(IDC_FILES_FOLDER_EDIT))->SetFocus();
  387. bIsValid = FALSE;
  388. }
  389. }
  390. if ( bIsValid ) {
  391. if ( m_strFileBaseName.IsEmpty() ) {
  392. if ( !m_bAutoNameSuffix ) {
  393. CString strMessage;
  394. strMessage.LoadString ( IDS_FILE_ERR_NOFILENAME );
  395. MessageBox ( strMessage, m_pLogQuery->GetLogName(), MB_OK | MB_ICONERROR);
  396. (GetDlgItem(IDC_FILES_FILENAME_EDIT))->SetFocus();
  397. bIsValid = FALSE;
  398. }
  399. } else {
  400. if ( !FileNameIsValid ( &m_strFileBaseName ) ){
  401. CString strMessage;
  402. strMessage.LoadString (IDS_ERRMSG_INVALIDCHAR);
  403. MessageBox( strMessage, m_pLogQuery->GetLogName(), MB_OK| MB_ICONERROR );
  404. (GetDlgItem(IDC_FILES_FILENAME_EDIT))->SetFocus();
  405. bIsValid = FALSE;
  406. }
  407. }
  408. }
  409. if ( bIsValid ) {
  410. if ( m_pLogQuery->GetLogService()->IsLocalMachine() ) {
  411. ProcessDirPath ( m_pLogQuery->GetLogService()->GetDefaultLogFileFolder(),
  412. m_strFolderName,
  413. m_pLogQuery->GetLogName(),
  414. this,
  415. bIsValid,
  416. TRUE );
  417. if ( !bIsValid ) {
  418. GetDlgItem(IDC_FILES_FOLDER_EDIT)->SetFocus();
  419. }
  420. }
  421. }
  422. if (bIsValid)
  423. {
  424. if ( SLQ_DISK_MAX_SIZE != m_dwMaxSizeInternal ) {
  425. if ( SLF_BIN_FILE == m_dwLogFileTypeValue ) {
  426. eMaxFileSize = CFilesProperty::eMaxCtrSeqBinFileLimit;
  427. } else if ( SLF_SEQ_TRACE_FILE == m_dwLogFileTypeValue ) {
  428. eMaxFileSize = CFilesProperty::eMaxTrcSeqBinFileLimit;
  429. } else {
  430. eMaxFileSize = CFilesProperty::eMaxFileLimit;
  431. }
  432. bIsValid = ValidateDWordInterval(IDC_FILES_SIZE_LIMIT_EDIT,
  433. m_pLogQuery->GetLogName(),
  434. (long) m_dwMaxSizeInternal,
  435. CFilesProperty::eMinFileLimit,
  436. eMaxFileSize);
  437. }
  438. }
  439. return bIsValid;
  440. }
  441. void
  442. CFileLogs::ValidateTextEdit(
  443. CDataExchange * pDX,
  444. int nIDC,
  445. int nMaxChars,
  446. DWORD* pValue,
  447. DWORD /* minValue */,
  448. DWORD /* maxValue */)
  449. {
  450. HWND hWndCtrl = NULL;
  451. LONG currentValue = INVALID_DWORD;
  452. WCHAR szW[MAXSTR];
  453. CString strTemp;
  454. // This method can only be called within DoDataExchange,
  455. // because it throws an exception.
  456. ASSERT ( nMaxChars < MAXSTR );
  457. if ( NULL != pDX ) {
  458. hWndCtrl = pDX->PrepareEditCtrl(nIDC);
  459. }
  460. if ( NULL != pDX && NULL != pValue && NULL != hWndCtrl ) {
  461. if (pDX->m_bSaveAndValidate)
  462. {
  463. * pValue = (DWORD) currentValue;
  464. ::GetWindowText(hWndCtrl, szW, MAXSTR);
  465. strTemp = szW;
  466. DDV_MaxChars(pDX, strTemp, nMaxChars);
  467. if (szW[0] >= L'0' && szW[0] <= L'9') {
  468. currentValue = _wtol(szW);
  469. * pValue = (DWORD) currentValue;
  470. }
  471. } else {
  472. if ( INVALID_DWORD != *pValue ) {
  473. StringCchPrintf ( szW, MAXSTR, L"%lu", *pValue );
  474. } else {
  475. szW[0] = L'\0';
  476. }
  477. GetDlgItem(nIDC)->SetWindowText(szW);
  478. }
  479. } else {
  480. ASSERT ( FALSE );
  481. }
  482. }
  483. BOOL
  484. CFileLogs::ValidateDWordInterval(int nIDC,
  485. LPCWSTR strLogName,
  486. long lValue,
  487. DWORD minValue,
  488. DWORD maxValue)
  489. {
  490. CString strMsg;
  491. BOOL bResult = (lValue >= (long) minValue)
  492. && (lValue <= (long) maxValue);
  493. if (! bResult)
  494. {
  495. strMsg.Format ( IDS_ERRMSG_INVALIDDWORD, minValue, maxValue );
  496. MessageBox(strMsg, strLogName, MB_OK | MB_ICONERROR);
  497. GetDlgItem(nIDC)->SetFocus();
  498. strMsg.Empty();
  499. }
  500. return (bResult);
  501. }
  502. BOOL
  503. CFileLogs::OnHelpInfo(HELPINFO * pHelpInfo)
  504. {
  505. if (pHelpInfo->iCtrlId >= IDC_FILELOG_FIRST_HELP_CTRL_ID ||
  506. pHelpInfo->iCtrlId == IDOK ||
  507. pHelpInfo->iCtrlId == IDCANCEL ) {
  508. InvokeWinHelp(WM_HELP,
  509. NULL,
  510. (LPARAM) pHelpInfo,
  511. m_strHelpFilePath,
  512. s_aulHelpIds);
  513. }
  514. return TRUE;
  515. }
  516. void
  517. CFileLogs::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  518. {
  519. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)(pWnd->m_hWnd), NULL, m_strHelpFilePath, s_aulHelpIds);
  520. return;
  521. }
  522. DWORD
  523. CFileLogs::SetContextHelpFilePath(const CString& rstrPath)
  524. {
  525. DWORD dwStatus = ERROR_SUCCESS;
  526. MFC_TRY
  527. m_strHelpFilePath = rstrPath;
  528. MFC_CATCH_DWSTATUS
  529. return dwStatus;
  530. }