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.

1228 lines
36 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1997 - 1999
  4. Module Name:
  5. LocalFileLoggingPage2.cpp
  6. Abstract:
  7. Implementation file for the CLocalFileLoggingPage2 class.
  8. We implement the class needed to handle the second property page
  9. for the LocalFileLogging node.
  10. Author:
  11. Michael A. Maguire 12/15/97
  12. Revision History:
  13. mmaguire 12/15/97 - created
  14. --*/
  15. //////////////////////////////////////////////////////////////////////////////
  16. //////////////////////////////////////////////////////////////////////////////
  17. // BEGIN INCLUDES
  18. //
  19. // standard includes:
  20. //
  21. #include "Precompiled.h"
  22. //
  23. // where we can find declaration for main class in this file:
  24. //
  25. #include "LocalFileLoggingPage2.h"
  26. #include "ChangeNotification.h"
  27. //
  28. //
  29. // where we can find declarations needed in this file:
  30. //
  31. #include <SHLOBJ.H>
  32. #include "LocalFileLoggingNode.h"
  33. #include "LoggingMethodsNode.h"
  34. #include "LogMacNd.h"
  35. //
  36. // END INCLUDES
  37. //////////////////////////////////////////////////////////////////////////////
  38. #define LOG_FILE_FORMAT__IAS1 0
  39. #define LOG_FILE_FORMAT__ODBC 0xFFFF
  40. #define LOG_SIZE_LIMIT 100000
  41. #define LOG_SIZE_LIMIT_DIGITS 6 // log(100000)
  42. //////////////////////////////////////////////////////////////////////////////
  43. /*++
  44. CLocalFileLoggingPage2::CLocalFileLoggingPage2
  45. Constructor
  46. --*/
  47. //////////////////////////////////////////////////////////////////////////////
  48. CLocalFileLoggingPage2::CLocalFileLoggingPage2( LONG_PTR hNotificationHandle, CLocalFileLoggingNode *pLocalFileLoggingNode, TCHAR* pTitle, BOOL bOwnsNotificationHandle )
  49. : CIASPropertyPage<CLocalFileLoggingPage2> ( hNotificationHandle, pTitle, bOwnsNotificationHandle )
  50. {
  51. ATLTRACE(_T("# +++ CLocalFileLoggingPage2::CLocalFileLoggingPage2\n"));
  52. _ASSERTE( pLocalFileLoggingNode != NULL );
  53. // Add the help button to the page
  54. // m_psp.dwFlags |= PSP_HASHELP;
  55. // Initialize the pointer to the stream into which the Sdo pointer will be marshalled.
  56. m_pStreamSdoAccountingMarshal = NULL;
  57. // Initialize the pointer to the stream into which the Sdo pointer will be marshalled.
  58. m_pStreamSdoServiceControlMarshal = NULL;
  59. // We immediately save off a parent to the client node.
  60. // We will use only the SDO, and notify the parent of the client object
  61. // we are modifying that it (and its children) may need to refresh
  62. // themselves with new data from the SDO's.
  63. m_pParentOfNodeBeingModified = pLocalFileLoggingNode->m_pParentNode;
  64. m_pNodeBeingModified = pLocalFileLoggingNode;
  65. }
  66. //////////////////////////////////////////////////////////////////////////////
  67. /*++
  68. CLocalFileLoggingPage2::~CLocalFileLoggingPage2
  69. Destructor
  70. --*/
  71. //////////////////////////////////////////////////////////////////////////////
  72. CLocalFileLoggingPage2::~CLocalFileLoggingPage2( void )
  73. {
  74. ATLTRACE(_T("# --- CLocalFileLoggingPage2::~CLocalFileLoggingPage2\n"));
  75. // Release this stream pointer if this hasn't already been done.
  76. if( m_pStreamSdoAccountingMarshal != NULL )
  77. {
  78. m_pStreamSdoAccountingMarshal->Release();
  79. };
  80. if( m_pStreamSdoServiceControlMarshal != NULL )
  81. {
  82. m_pStreamSdoServiceControlMarshal->Release();
  83. };
  84. }
  85. //////////////////////////////////////////////////////////////////////////////
  86. /*++
  87. CLocalFileLoggingPage2::OnInitDialog
  88. --*/
  89. //////////////////////////////////////////////////////////////////////////////
  90. LRESULT CLocalFileLoggingPage2::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  91. {
  92. ATLTRACE(_T("# CLocalFileLoggingPage2::OnInitDialog\n"));
  93. // Check for preconditions:
  94. _ASSERTE( m_pStreamSdoAccountingMarshal != NULL );
  95. _ASSERT( m_pSynchronizer != NULL );
  96. // Since we've been examined, we must add to the ref count of pages who need to
  97. // give their approval before they can be allowed to commit changes.
  98. m_pSynchronizer->RaiseCount();
  99. HRESULT hr;
  100. CComBSTR bstrTemp;
  101. BOOL bTemp;
  102. LONG lTemp;
  103. // Unmarshall an ISdo interface pointer.
  104. // The code setting up this page should make sure that it has
  105. // marshalled the Sdo interface pointer into m_pStreamSdoAccountingMarshal.
  106. hr = CoGetInterfaceAndReleaseStream(
  107. m_pStreamSdoAccountingMarshal //Pointer to the stream from which the object is to be marshaled
  108. , IID_ISdo //Reference to the identifier of the interface
  109. , (LPVOID *) &m_spSdoAccounting //Address of output variable that receives the interface pointer requested in riid
  110. );
  111. // CoGetInterfaceAndReleaseStream releases this pointer even if it fails.
  112. // We set it to NULL so that our destructor doesn't try to release this again.
  113. m_pStreamSdoAccountingMarshal = NULL;
  114. if( FAILED( hr) || m_spSdoAccounting == NULL )
  115. {
  116. ShowErrorDialog( m_hWnd, IDS_ERROR__NO_SDO, NULL, hr, IDS_ERROR__LOGGING_TITLE );
  117. return 0;
  118. }
  119. // Unmarshall an ISdo interface pointer.
  120. // The code setting up this page should make sure that it has
  121. // marshalled the Sdo interface pointer into m_pStreamSdoServiceControlMarshal.
  122. hr = CoGetInterfaceAndReleaseStream(
  123. m_pStreamSdoServiceControlMarshal //Pointer to the stream from which the object is to be marshaled
  124. , IID_ISdoServiceControl //Reference to the identifier of the interface
  125. , (LPVOID *) &m_spSdoServiceControl //Address of output variable that receives the interface pointer requested in riid
  126. );
  127. // CoGetInterfaceAndReleaseStream releases this pointer even if it fails.
  128. // We set it to NULL so that our destructor doesn't try to release this again.
  129. m_pStreamSdoServiceControlMarshal = NULL;
  130. if( FAILED( hr) || m_spSdoServiceControl == NULL )
  131. {
  132. ShowErrorDialog( m_hWnd, IDS_ERROR__NO_SDO, NULL, hr, IDS_ERROR__LOGGING_TITLE );
  133. return 0;
  134. }
  135. // Initialize the data on the property page.
  136. // hr = GetSdoBOOL( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW, &bTemp, IDS_ERROR__LOCAL_FILE_LOGGING_READING_AUTOMATICALLY_OPEN_NEW_LOG, m_hWnd, NULL );
  137. // if( SUCCEEDED( hr ) )
  138. // {
  139. // SendDlgItemMessage( IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG, BM_SETCHECK, bTemp, 0);
  140. //
  141. // // Initialize the dirty bits;
  142. // // We do this after we've set all the data above otherwise we get false
  143. // // notifications that data has changed when we set the edit box text.
  144. // m_fDirtyAutomaticallyOpenNewLog = FALSE;
  145. // }
  146. // else
  147. // {
  148. // if( OLE_E_BLANK == hr )
  149. // {
  150. // SendDlgItemMessage( IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG, BM_SETCHECK, FALSE, 0);
  151. // m_fDirtyAutomaticallyOpenNewLog = TRUE;
  152. // SetModified( TRUE );
  153. // }
  154. // }
  155. lTemp = 0;
  156. hr = GetSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW_FREQUENCY, &lTemp, IDS_ERROR__LOCAL_FILE_LOGGING_READING_NEW_LOG_FREQUENCY, m_hWnd, NULL );
  157. if( SUCCEEDED( hr ) )
  158. {
  159. m_fDirtyFrequency = FALSE;
  160. }
  161. else
  162. {
  163. if( OLE_E_BLANK == hr )
  164. {
  165. m_fDirtyFrequency = TRUE;
  166. SetModified( TRUE );
  167. }
  168. }
  169. NEW_LOG_FILE_FREQUENCY nlffFrequency = (NEW_LOG_FILE_FREQUENCY) lTemp;
  170. switch( nlffFrequency )
  171. {
  172. case IAS_LOGGING_DAILY:
  173. ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY ), BM_SETCHECK, 1, 0 );
  174. break;
  175. case IAS_LOGGING_WEEKLY:
  176. ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY ), BM_SETCHECK, 1, 0 );
  177. break;
  178. case IAS_LOGGING_MONTHLY:
  179. ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY ), BM_SETCHECK, 1, 0 );
  180. break;
  181. case IAS_LOGGING_WHEN_FILE_SIZE_REACHES:
  182. ::SendMessage( GetDlgItem(IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES ), BM_SETCHECK, 1, 0 );
  183. break;
  184. case IAS_LOGGING_UNLIMITED_SIZE:
  185. ::SendMessage( GetDlgItem(IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__UNLIMITED ), BM_SETCHECK, 1, 0 );
  186. break;
  187. default:
  188. // Invalid logging frequency.
  189. _ASSERTE( FALSE );
  190. break;
  191. }
  192. ::SendMessage( GetDlgItem(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE ), EM_LIMITTEXT, LOG_SIZE_LIMIT_DIGITS, 0 );
  193. hr = GetSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW_SIZE, &lTemp, IDS_ERROR__LOCAL_FILE_LOGGING_READING_WHEN_LOG_FILE_SIZE, m_hWnd, NULL );
  194. if( SUCCEEDED( hr ) )
  195. {
  196. TCHAR szNumberAsText[IAS_MAX_STRING];
  197. _ltot( lTemp, szNumberAsText, 10 /* Base */ );
  198. SetDlgItemText(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE, szNumberAsText );
  199. m_fDirtyLogFileSize = FALSE;
  200. }
  201. else
  202. {
  203. if( OLE_E_BLANK == hr )
  204. {
  205. SetDlgItemText(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE, _T("") );
  206. m_fDirtyLogFileSize = TRUE;
  207. SetModified( TRUE );
  208. }
  209. }
  210. hr = GetSdoBSTR( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_FILE_DIRECTORY, &bstrTemp, IDS_ERROR__LOCAL_FILE_LOGGING_READING_LOG_FILE_DIRECTORY, m_hWnd, NULL );
  211. if( SUCCEEDED( hr ) )
  212. {
  213. SetDlgItemText( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY, bstrTemp );
  214. m_fDirtyLogFileDirectory = FALSE;
  215. }
  216. else
  217. {
  218. if( OLE_E_BLANK == hr )
  219. {
  220. SetDlgItemText( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY, _T("") );
  221. m_fDirtyLogFileDirectory = TRUE;
  222. SetModified( TRUE );
  223. }
  224. }
  225. bstrTemp.Empty();
  226. // The log file name is not something we set -- the server's accounting provider determines it based on the frequency we choose.
  227. //
  228. // hr = m_spSdoAccounting->GetProperty( PROPERTY_ACCOUNTING_LOG_FILE, &spVariant );
  229. // if( SUCCEEDED( hr ) )
  230. // {
  231. // _ASSERTE( spVariant.vt == VT_BSTR );
  232. // SetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, spVariant.bstrVal );
  233. // }
  234. // else
  235. // {
  236. // m_spSdoClient->LastError( &bstrError );
  237. // ShowErrorDialog( m_hWnd, IDS_ERROR__CANT_READ_DATA_FROM_SDO, bstrError );
  238. // }
  239. // spVariant.Clear();
  240. hr = GetSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_IAS1_FORMAT, &lTemp, IDS_ERROR__LOCAL_FILE_LOGGING_READING_LOG_FILE_FORMAT, m_hWnd, NULL );
  241. if( SUCCEEDED( hr ) )
  242. {
  243. switch( lTemp )
  244. {
  245. case LOG_FILE_FORMAT__IAS1:
  246. // W3C format (IAS 1.0)
  247. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_IAS1, BM_SETCHECK, TRUE, 0);
  248. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_ODBC, BM_SETCHECK, FALSE, 0);
  249. break;
  250. case LOG_FILE_FORMAT__ODBC:
  251. // ODBC format
  252. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_ODBC, BM_SETCHECK, TRUE, 0);
  253. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_IAS1, BM_SETCHECK, FALSE, 0);
  254. break;
  255. default:
  256. // Unknown log file format.
  257. _ASSERTE( FALSE );
  258. }
  259. m_fDirtyLogInV1Format = FALSE;
  260. }
  261. else
  262. {
  263. if( OLE_E_BLANK == hr )
  264. {
  265. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_ODBC, BM_SETCHECK, TRUE, 0);
  266. SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_IAS1, BM_SETCHECK, FALSE, 0);
  267. m_fDirtyLogInV1Format = TRUE;
  268. SetModified( TRUE );
  269. }
  270. }
  271. // SetAutomaticallyOpenNewLogDependencies();
  272. SetLogFileFrequencyDependencies();
  273. // Check to see whether we are local or remote, and disable Browse
  274. // button if we are remote.
  275. // We need access here to some server-global data.
  276. _ASSERTE( m_pParentOfNodeBeingModified != NULL );
  277. CLoggingMachineNode * pServerNode = ((CLoggingMethodsNode *) m_pParentOfNodeBeingModified)->GetServerRoot();
  278. _ASSERTE( pServerNode != NULL );
  279. if( pServerNode->m_bConfigureLocal )
  280. {
  281. // We are local.
  282. ::EnableWindow( GetDlgItem( IDC_BUTTON_LOCAL_FILE_LOGGING_PAGE2__BROWSE ), TRUE );
  283. }
  284. else
  285. {
  286. // We are remote
  287. ::EnableWindow( GetDlgItem( IDC_BUTTON_LOCAL_FILE_LOGGING_PAGE2__BROWSE ), FALSE );
  288. }
  289. return TRUE; // ISSUE: what do we need to be returning here?
  290. }
  291. //////////////////////////////////////////////////////////////////////////////
  292. /*++
  293. CLocalFileLoggingPage2::OnChange
  294. Called when the WM_COMMAND message is sent to our page with any of the
  295. BN_CLICKED, EN_CHANGE or CBN_SELCHANGE notifications.
  296. This is our chance to check to see what the user has touched, set the
  297. dirty bits for these items so that only they will be saved,
  298. and enable the Apply button.
  299. --*/
  300. //////////////////////////////////////////////////////////////////////////////
  301. LRESULT CLocalFileLoggingPage2::OnChange(
  302. UINT uMsg
  303. , WPARAM wParam
  304. , HWND hwnd
  305. , BOOL& bHandled
  306. )
  307. {
  308. ATLTRACE(_T("# CLocalFileLoggingPage2::OnChange\n"));
  309. // Check for preconditions:
  310. // None.
  311. // We don't want to prevent anyone else down the chain from receiving a message.
  312. bHandled = FALSE;
  313. // Figure out which item has changed and set the dirty bit for that item.
  314. int iItemID = (int) LOWORD(wParam);
  315. switch( iItemID )
  316. {
  317. // case IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG:
  318. // m_fDirtyAutomaticallyOpenNewLog = TRUE;
  319. // break;
  320. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY:
  321. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY:
  322. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY:
  323. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES:
  324. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__UNLIMITED:
  325. m_fDirtyFrequency = TRUE;
  326. break;
  327. case IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE:
  328. m_fDirtyLogFileSize = TRUE;
  329. break;
  330. case IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY:
  331. m_fDirtyLogFileDirectory = TRUE;
  332. break;
  333. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_ODBC:
  334. case IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_IAS1:
  335. m_fDirtyLogInV1Format = TRUE;
  336. break;
  337. default:
  338. return TRUE;
  339. break;
  340. }
  341. // We should only get here if the item that changed was
  342. // one of the ones we were checking for.
  343. // This enables the Apply button.
  344. SetModified( TRUE );
  345. return TRUE; // ISSUE: what do we need to be returning here?
  346. }
  347. //////////////////////////////////////////////////////////////////////////////
  348. /*++
  349. CLocalFileLoggingPage2::BrowseCallbackProc
  350. Needed so that we can set the directory which the Browse for Directory dialog displays.
  351. --*/
  352. //////////////////////////////////////////////////////////////////////////////
  353. int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
  354. {
  355. switch(uMsg)
  356. {
  357. case BFFM_INITIALIZED:
  358. // pData contains the data we passed in as BROWSEINFO.lParam
  359. // It should a string form of the directory we want the browser to show initially.
  360. if( NULL != pData )
  361. {
  362. // WParam is TRUE since you are passing a path.
  363. // It would be FALSE if you were passing a pidl.
  364. SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)pData);
  365. }
  366. break;
  367. default:
  368. break;
  369. }
  370. return 0;
  371. }
  372. //////////////////////////////////////////////////////////////////////////////
  373. /*++
  374. CLocalFileLoggingPage2::OnBrowse
  375. Action to be taken when the user clicks on the browse button to choose
  376. a directory where log files should be saved.
  377. --*/
  378. //////////////////////////////////////////////////////////////////////////////
  379. LRESULT CLocalFileLoggingPage2::OnBrowse(
  380. UINT uMsg
  381. , WPARAM wParam
  382. , HWND hwnd
  383. , BOOL& bHandled
  384. )
  385. {
  386. ATLTRACE(_T("# CLocalFileLoggingPage2::OnBrowse\n"));
  387. #ifdef USE_GETSAVEFILENAME
  388. OPENFILENAME ofnInfo;
  389. TCHAR szFileName[MAX_PATH + 1]; // buffer must be one TCHAR longer than we say it is later -- see KB Q137194
  390. TCHAR szDialogTitle[IAS_MAX_STRING];
  391. // Initialize the data structure we will pass to GetSaveFileName.
  392. memset(&ofnInfo, 0, sizeof(OPENFILENAME));
  393. // Put a NULL in the first character of szFileName to indicate that
  394. // no initialization is necessary.
  395. szFileName[0] = NULL;
  396. // Set the dialog title.
  397. int nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_BROWSE_DIALOG__TITLE, szDialogTitle, IAS_MAX_STRING );
  398. _ASSERT( nLoadStringResult > 0 );
  399. ofnInfo.lStructSize = sizeof(OPENFILENAME);
  400. ofnInfo.hwndOwner = hwnd;
  401. ofnInfo.lpstrFile = szFileName;
  402. ofnInfo.nMaxFile = MAX_PATH;
  403. ofnInfo.lpstrTitle = szDialogTitle;
  404. if( 0 != GetSaveFileName( &ofnInfo ) )
  405. {
  406. // The user hit OK. We should save the chosen directory in the text box.
  407. CComBSTR bstrText = ofnInfo.lpstrFile;
  408. SetDlgItemText(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY, bstrText );
  409. }
  410. else
  411. {
  412. // An error occured or the user hit cancel -- find out which.
  413. DWORD dwError = CommDlgExtendedError();
  414. if( 0 == dwError )
  415. {
  416. // The user simply cancelled or closed the dialog box -- no error occured.
  417. }
  418. else
  419. {
  420. // Some error occurred.
  421. // ISSUE: We should be giving more detailed error info here.
  422. ShowErrorDialog( m_hWnd, USE_DEFAULT, NULL, 0, IDS_ERROR__LOGGING_TITLE);
  423. }
  424. }
  425. #else // DON'T USE_GETSAVEFILENAME
  426. BROWSEINFO biInfo;
  427. TCHAR szFileName[MAX_PATH + 1];
  428. TCHAR szDialogTitle[IAS_MAX_STRING];
  429. // Initialize the data structure we will pass to GetSaveFileName.
  430. memset(&biInfo, 0, sizeof(BROWSEINFO));
  431. // Put a NULL in the first character of szFileName to indicate that
  432. // no initialization is necessary.
  433. szFileName[0] = NULL;
  434. // Set the dialog title.
  435. int nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_BROWSE_DIALOG__TITLE, szDialogTitle, IAS_MAX_STRING );
  436. _ASSERT( nLoadStringResult > 0 );
  437. CComBSTR bstrText;
  438. GetDlgItemText(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY,(BSTR &) bstrText );
  439. biInfo.hwndOwner = hwnd;
  440. biInfo.pszDisplayName = szFileName;
  441. biInfo.lpszTitle = szDialogTitle;
  442. biInfo.lpfn = BrowseCallbackProc;
  443. biInfo.lParam = (LPARAM) bstrText.m_str;
  444. LPITEMIDLIST lpItemIDList;
  445. lpItemIDList = SHBrowseForFolder( & biInfo );
  446. if( lpItemIDList != NULL )
  447. {
  448. // The user hit OK. We should save the chosen directory in the text box.
  449. // ISSUE: Need to release the lpItemIDLust structure allocated by the call
  450. // using the shell's task allocator (how???)
  451. // Convert the ItemIDList to a path.
  452. // We clobber the old szFileName here because we don't care about it. (It didn't have the full path.)
  453. BOOL bSuccess = SHGetPathFromIDList( lpItemIDList, szFileName );
  454. if( bSuccess )
  455. {
  456. CComBSTR bstrText = szFileName;
  457. SetDlgItemText(IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY, bstrText );
  458. }
  459. else
  460. {
  461. // Handle error
  462. ShowErrorDialog( m_hWnd, IDS_ERROR__NOT_A_VALID_DIRECTORY, NULL, 0 , IDS_ERROR__LOGGING_TITLE );
  463. }
  464. }
  465. else
  466. {
  467. // An error occured or the user hit cancel -- find out which.
  468. // SHBrowseInfo seems to have no error checking capabilities.
  469. // The docs say that if it succeeded, it returns non-NULL, and
  470. // if the user chooses Cancel, it returns NULL.
  471. // I tried GetLastError to make sure that there was no error,
  472. // but it gives back 0x00000006 "Invalid handle" even if I
  473. // do SetLastError(0) before I make any calls.
  474. // So it seems that we have no choice but to assume that
  475. // if we get here, there was no error,
  476. // it was simply that the user chose Cancel.
  477. }
  478. #endif // USE_GETSAVEFILENAME
  479. return TRUE; // ISSUE: what do we need to be returning here?
  480. }
  481. //////////////////////////////////////////////////////////////////////////////
  482. /*++
  483. CLocalFileLoggingPage2::OnApply
  484. Return values:
  485. TRUE if the page can be destroyed,
  486. FALSE if the page should not be destroyed (i.e. there was invalid data)
  487. Remarks:
  488. OnApply gets called for each page in on a property sheet if that
  489. page has been visited, regardless of whether any values were changed.
  490. If you never switch to a tab, then its OnApply method will never get called.
  491. --*/
  492. //////////////////////////////////////////////////////////////////////////////
  493. BOOL CLocalFileLoggingPage2::OnApply()
  494. {
  495. ATLTRACE(_T("# CLocalFileLoggingPage2::OnApply\n"));
  496. // Check for preconditions:
  497. _ASSERT( m_pSynchronizer != NULL );
  498. if( m_spSdoAccounting == NULL )
  499. {
  500. ShowErrorDialog( m_hWnd, IDS_ERROR__NO_SDO, NULL, 0, IDS_ERROR__LOGGING_TITLE );
  501. return FALSE;
  502. }
  503. CComBSTR bstrNumberAsText;
  504. BOOL bResult;
  505. HRESULT hr;
  506. BOOL bTemp;
  507. LONG lTemp;
  508. CComBSTR bstrTemp;
  509. // if( m_fDirtyAutomaticallyOpenNewLog )
  510. // {
  511. // bTemp = SendDlgItemMessage( IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG, BM_GETCHECK, 0, 0);
  512. // hr = PutSdoBOOL( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW, bTemp, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_AUTOMATICALLY_OPEN_NEW_LOG, m_hWnd, NULL );
  513. // if( FAILED( hr ) )
  514. // {
  515. // // Reset the ref count so all pages know that we need to play the game again.
  516. // m_pSynchronizer->ResetCountToHighest();
  517. //
  518. // // This uses the resource ID of this page to make this page the current page.
  519. // PropSheet_SetCurSelByID( GetParent(), IDD );
  520. //
  521. // return FALSE;
  522. // }
  523. // else
  524. // {
  525. // // We succeeded.
  526. //
  527. // // Turn off the dirty bit.
  528. // m_fDirtyAutomaticallyOpenNewLog = FALSE;
  529. // }
  530. // }
  531. if( m_fDirtyFrequency )
  532. {
  533. NEW_LOG_FILE_FREQUENCY nlffFrequency = IAS_LOGGING_MONTHLY;
  534. if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY ), BM_GETCHECK, 0, 0 ) )
  535. nlffFrequency = IAS_LOGGING_DAILY;
  536. else if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY ), BM_GETCHECK, 0, 0 ) )
  537. nlffFrequency = IAS_LOGGING_WEEKLY;
  538. else if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY ), BM_GETCHECK, 0, 0 ) )
  539. nlffFrequency = IAS_LOGGING_MONTHLY;
  540. else if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__UNLIMITED ), BM_GETCHECK, 0, 0 ) )
  541. nlffFrequency = IAS_LOGGING_UNLIMITED_SIZE;
  542. else
  543. nlffFrequency = IAS_LOGGING_WHEN_FILE_SIZE_REACHES;
  544. hr = PutSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW_FREQUENCY, nlffFrequency, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_NEW_LOG_FREQUENCY, m_hWnd, NULL );
  545. if( FAILED( hr ) )
  546. {
  547. // Reset the ref count so all pages know that we need to play the game again.
  548. m_pSynchronizer->ResetCountToHighest();
  549. // This uses the resource ID of this page to make this page the current page.
  550. PropSheet_SetCurSelByID( GetParent(), IDD );
  551. return FALSE;
  552. }
  553. else
  554. {
  555. // We succeeded.
  556. // Turn off the dirty bit.
  557. m_fDirtyFrequency = FALSE;
  558. }
  559. }
  560. if( m_fDirtyLogFileSize )
  561. {
  562. // When a user enters some (potentially invalid) data, but
  563. // then disables the option using that data, we don't try to save this data.
  564. int iChecked = ::SendMessage( GetDlgItem(IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES), BM_GETCHECK, 0, 0 );
  565. int iEnabled = ::IsWindowEnabled( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES ) );
  566. if( iChecked && iEnabled )
  567. {
  568. bResult = GetDlgItemText( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE, (BSTR &) bstrNumberAsText );
  569. if( ! bResult )
  570. {
  571. // We couldn't retrieve a BSTR, in other words the field was blank.
  572. // This is an error.
  573. ShowErrorDialog( m_hWnd, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_WHEN_LOG_FILE_SIZE_NOT_ZERO, NULL, 0, IDS_ERROR__LOGGING_TITLE );
  574. // Reset the ref count so all pages know that we need to play the game again.
  575. m_pSynchronizer->ResetCountToHighest();
  576. // This uses the resource ID of this page to make this page the current page.
  577. PropSheet_SetCurSelByID( GetParent(), IDD );
  578. return FALSE;
  579. }
  580. lTemp = _ttol( bstrNumberAsText );
  581. if( lTemp <= 0 || lTemp > LOG_SIZE_LIMIT)
  582. {
  583. // If result here was zero, this indicates an error.
  584. ShowErrorDialog( m_hWnd, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_WHEN_LOG_FILE_SIZE_NOT_ZERO, NULL, 0, IDS_ERROR__LOGGING_TITLE );
  585. // Reset the ref count so all pages know that we need to play the game again.
  586. m_pSynchronizer->ResetCountToHighest();
  587. // This uses the resource ID of this page to make this page the current page.
  588. PropSheet_SetCurSelByID( GetParent(), IDD );
  589. return FALSE;
  590. }
  591. bstrNumberAsText.Empty();
  592. hr = PutSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_OPEN_NEW_SIZE, lTemp, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_WHEN_LOG_FILE_SIZE, m_hWnd, NULL );
  593. if( FAILED( hr ) )
  594. {
  595. // Reset the ref count so all pages know that we need to play the game again.
  596. m_pSynchronizer->ResetCountToHighest();
  597. // This uses the resource ID of this page to make this page the current page.
  598. PropSheet_SetCurSelByID( GetParent(), IDD );
  599. return FALSE;
  600. }
  601. else
  602. {
  603. // We succeeded.
  604. // Turn off the dirty bit.
  605. m_fDirtyLogFileSize = FALSE;
  606. }
  607. }
  608. }
  609. if( m_fDirtyLogFileDirectory )
  610. {
  611. bResult = GetDlgItemText( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_DIRECTORY, (BSTR &) bstrTemp );
  612. if( ! bResult )
  613. {
  614. // We couldn't retrieve a BSTR, so we need to initialize this variant to a null BSTR.
  615. bstrTemp = _T("");
  616. }
  617. hr = PutSdoBSTR( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_FILE_DIRECTORY, &bstrTemp, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_LOG_FILE_DIRECTORY, m_hWnd, NULL );
  618. if( FAILED( hr ) )
  619. {
  620. // Reset the ref count so all pages know that we need to play the game again.
  621. m_pSynchronizer->ResetCountToHighest();
  622. // This uses the resource ID of this page to make this page the current page.
  623. PropSheet_SetCurSelByID( GetParent(), IDD );
  624. return FALSE;
  625. }
  626. else
  627. {
  628. // We succeeded.
  629. // Turn off the dirty bit.
  630. m_fDirtyLogFileDirectory = FALSE;
  631. }
  632. bstrTemp.Empty();
  633. }
  634. // The log file name is not something we set -- the server's accounting provider determines it based on the frequency we choose.
  635. //
  636. // spVariant.vt = VT_BSTR;
  637. // bResult = GetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, spVariant.bstrVal );
  638. // if( ! bResult )
  639. // {
  640. // // We couldn't retrieve a BSTR, so we need to initialize this variant to a null BSTR.
  641. // spVariant.bstrVal = SysAllocString( _T("") );
  642. // }
  643. // hr = m_spSdoAccounting->PutProperty( PROPERTY_ACCOUNTING_LOG_FILE, &spVariant );
  644. // spVariant.Clear();
  645. // if( FAILED( hr ) )
  646. // {
  647. // // Figure out error and give back appropriate messsage.
  648. //
  649. // m_spSdoClient->LastError( &bstrError );
  650. // ShowErrorDialog( m_hWnd, IDS_ERROR__CANT_WRITE_DATA_TO_SDO, bstrError );
  651. //
  652. // // Reset the ref count so all pages know that we need to play the game again.
  653. // m_pSynchronizer->ResetCountToHighest();
  654. //
  655. // // This uses the resource ID of this page to make this page the current page.
  656. // PropSheet_SetCurSelByID( GetParent(), IDD );
  657. //
  658. // return FALSE;
  659. // }
  660. if( m_fDirtyLogInV1Format )
  661. {
  662. if( SendDlgItemMessage( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__FORMAT_IAS1, BM_GETCHECK, 0, 0) )
  663. {
  664. lTemp = LOG_FILE_FORMAT__IAS1;
  665. }
  666. else
  667. {
  668. lTemp = LOG_FILE_FORMAT__ODBC;
  669. }
  670. hr = PutSdoI4( m_spSdoAccounting, PROPERTY_ACCOUNTING_LOG_IAS1_FORMAT, lTemp, IDS_ERROR__LOCAL_FILE_LOGGING_WRITING_LOG_FILE_FORMAT, m_hWnd, NULL );
  671. if( FAILED( hr ) )
  672. {
  673. // Reset the ref count so all pages know that we need to play the game again.
  674. m_pSynchronizer->ResetCountToHighest();
  675. // This uses the resource ID of this page to make this page the current page.
  676. PropSheet_SetCurSelByID( GetParent(), IDD );
  677. return FALSE;
  678. }
  679. else
  680. {
  681. // We succeeded.
  682. // Turn off the dirty bit.
  683. m_fDirtyLogInV1Format = FALSE;
  684. }
  685. }
  686. // If we made it to here, try to apply the changes.
  687. // Check to see if there are other pages which have not yet validated their data.
  688. LONG lRefCount = m_pSynchronizer->LowerCount();
  689. if( lRefCount <= 0 )
  690. {
  691. // There is nobody else left, so now we can commit the data.
  692. hr = m_spSdoAccounting->Apply();
  693. if( FAILED( hr ) )
  694. {
  695. if(hr == DB_E_NOTABLE) // assume, the RPC connection has problem
  696. ShowErrorDialog( m_hWnd, IDS_ERROR__NOTABLE_TO_WRITE_SDO, NULL, 0, IDS_ERROR__LOGGING_TITLE );
  697. else
  698. {
  699. // m_spSdoAccounting->LastError( &bstrError );
  700. // ShowErrorDialog( m_hWnd, IDS_ERROR__CANT_WRITE_DATA_TO_SDO, bstrError );
  701. ShowErrorDialog( m_hWnd, IDS_ERROR__CANT_WRITE_DATA_TO_SDO, NULL, 0, IDS_ERROR__LOGGING_TITLE );
  702. }
  703. // Reset the ref count so all pages know that we need to play the game again.
  704. m_pSynchronizer->ResetCountToHighest();
  705. // This uses the resource ID of this page to make this page the current page.
  706. PropSheet_SetCurSelByID( GetParent(), IDD );
  707. return FALSE;
  708. }
  709. else
  710. {
  711. // We succeeded.
  712. // The data was accepted, so notify the main context of our snapin
  713. // that it may need to update its views.
  714. CChangeNotification * pChangeNotification = new CChangeNotification();
  715. pChangeNotification->m_dwFlags = CHANGE_UPDATE_RESULT_NODE;
  716. pChangeNotification->m_pNode = m_pNodeBeingModified;
  717. pChangeNotification->m_pParentNode = m_pParentOfNodeBeingModified;
  718. HRESULT hr = PropertyChangeNotify( (LPARAM) pChangeNotification );
  719. _ASSERTE( SUCCEEDED( hr ) );
  720. // Tell the service to reload data.
  721. HRESULT hrTemp = m_spSdoServiceControl->ResetService();
  722. if( FAILED( hrTemp ) )
  723. {
  724. // Fail silently.
  725. }
  726. }
  727. }
  728. return TRUE;
  729. }
  730. //////////////////////////////////////////////////////////////////////////////
  731. /*++
  732. CLocalFileLoggingPage2::OnQueryCancel
  733. Return values:
  734. TRUE if the page can be destroyed,
  735. FALSE if the page should not be destroyed (i.e. there was invalid data)
  736. Remarks:
  737. OnQueryCancel gets called for each page in on a property sheet if that
  738. page has been visited, regardless of whether any values were changed.
  739. If you never switch to a tab, then its OnQueryCancel method will never get called.
  740. --*/
  741. //////////////////////////////////////////////////////////////////////////////
  742. BOOL CLocalFileLoggingPage2::OnQueryCancel()
  743. {
  744. ATLTRACE(_T("# CLocalFileLoggingPage2::OnQueryCancel\n"));
  745. HRESULT hr;
  746. if( m_spSdoAccounting != NULL )
  747. {
  748. // If the user wants to cancel, we should make sure that we rollback
  749. // any changes the user may have started.
  750. // If the user had not already tried to commit something,
  751. // a cancel on an SDO will hopefully be designed to be benign.
  752. hr = m_spSdoAccounting->Restore();
  753. // Don't care about the HRESULT, but it might be good to see it for debugging.
  754. }
  755. return TRUE;
  756. }
  757. //////////////////////////////////////////////////////////////////////////////
  758. /*++
  759. CLocalFileLoggingPage2::OnAutomaticallyOpenNewLog
  760. Remarks:
  761. Called when the user clicks on the Enable Logging check box.
  762. --*/
  763. //////////////////////////////////////////////////////////////////////////////
  764. //LRESULT CLocalFileLoggingPage2::OnAutomaticallyOpenNewLog(
  765. // UINT uMsg
  766. // , WPARAM wParam
  767. // , HWND hwnd
  768. // , BOOL& bHandled
  769. // )
  770. //{
  771. // ATLTRACE(_T("# CLocalFileLoggingPage2::OnAutomaticallyOpenNewLog\n"));
  772. //
  773. // // The Enable Logging button has been checked -- check dependencies.
  774. // SetAutomaticallyOpenNewLogDependencies();
  775. //
  776. // // This return value is ignored.
  777. // return TRUE;
  778. //}
  779. //////////////////////////////////////////////////////////////////////////////
  780. /*++
  781. CLocalFileLoggingPage2::OnNewLogInterval
  782. Remarks:
  783. Called when the user clicks on the Enable Logging check box.
  784. --*/
  785. //////////////////////////////////////////////////////////////////////////////
  786. LRESULT CLocalFileLoggingPage2::OnNewLogInterval(
  787. UINT uMsg
  788. , WPARAM wParam
  789. , HWND hwnd
  790. , BOOL& bHandled
  791. )
  792. {
  793. ATLTRACE(_T("# CLocalFileLoggingPage2::OnNewLogInterval\n"));
  794. // The Enable Logging button has been checked -- check dependencies.
  795. SetLogFileFrequencyDependencies();
  796. // This return value is ignored.
  797. return TRUE;
  798. }
  799. //////////////////////////////////////////////////////////////////////////////
  800. /*++
  801. CLocalFileLoggingPage2::SetAutomaticallyOpenNewLogDependencies
  802. Remarks:
  803. Utility to set state of items which may depend on the
  804. Enable Logging check box.
  805. Call whenever something changes the state of IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG.
  806. This will worry about all items dependent on this item.
  807. --*/
  808. //////////////////////////////////////////////////////////////////////////////
  809. //void CLocalFileLoggingPage2::SetAutomaticallyOpenNewLogDependencies( void )
  810. //{
  811. // ATLTRACE(_T("# CLocalFileLoggingPage2::SetAutomaticallyOpenNewLogDependencies\n"));
  812. //
  813. // // Ascertain what the state of the check box is.
  814. // int iChecked = ::SendMessage( GetDlgItem(IDC_CHECK_LOCAL_FILE_LOGGING_PAGE2__AUTOMATICALLY_OPEN_NEW_LOG), BM_GETCHECK, 0, 0 );
  815. //
  816. // if( iChecked )
  817. // {
  818. // // Make sure the correct items are enabled.
  819. //
  820. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY), TRUE );
  821. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY), TRUE );
  822. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY), TRUE );
  823. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES), TRUE );
  824. //
  825. // }
  826. // else
  827. // {
  828. // // Make sure the correct items are enabled.
  829. //
  830. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY), FALSE );
  831. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY), FALSE );
  832. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY), FALSE );
  833. // ::EnableWindow( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES), FALSE );
  834. //
  835. // }
  836. //
  837. // // WHEN_LOG_FILE_REACHES button has items depending on it
  838. // SetLogFileFrequencyDependencies();
  839. //
  840. //}
  841. //////////////////////////////////////////////////////////////////////////////
  842. /*++
  843. CLocalFileLoggingPage2::SetLogFileFrequencyDependencies
  844. Remarks:
  845. Utility to set state of items which may depend on the
  846. "When log file size reaches" radio button.
  847. Call whenever something changes the state of
  848. IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES
  849. or any of the other logging frequency radio buttons.
  850. --*/
  851. //////////////////////////////////////////////////////////////////////////////
  852. void CLocalFileLoggingPage2::SetLogFileFrequencyDependencies( void )
  853. {
  854. ATLTRACE(_T("# CLocalFileLoggingPage2::SetLogFileFrequencyDependencies\n"));
  855. int nLoadStringResult;
  856. TCHAR szDaily[IAS_MAX_STRING];
  857. TCHAR szWeekly[IAS_MAX_STRING];
  858. TCHAR szMonthly[IAS_MAX_STRING];
  859. TCHAR szWhenLogFileSizeReaches[IAS_MAX_STRING];
  860. nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_PAGE2__DAILY_FORMAT, szDaily, IAS_MAX_STRING );
  861. _ASSERT( nLoadStringResult > 0 );
  862. nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_PAGE2__WEEKLY_FORMAT, szWeekly, IAS_MAX_STRING );
  863. _ASSERT( nLoadStringResult > 0 );
  864. nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_PAGE2__MONTHLY_FORMAT, szMonthly, IAS_MAX_STRING );
  865. _ASSERT( nLoadStringResult > 0 );
  866. nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_SIZE_REACHES_FORMAT, szWhenLogFileSizeReaches, IAS_MAX_STRING );
  867. _ASSERT( nLoadStringResult > 0 );
  868. // Set the text to appear as the log file name.
  869. if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__DAILY ), BM_GETCHECK, 0, 0 ) )
  870. SetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, szDaily );
  871. else if( ::SendMessage( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WEEKLY ), BM_GETCHECK, 0, 0 ) )
  872. SetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, szWeekly );
  873. else if( ::SendMessage( GetDlgItem(IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__MONTHLY ), BM_GETCHECK, 0, 0 ) )
  874. SetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, szMonthly );
  875. else
  876. // This takes care of both the UNLIMITED and the WHEN_LOG_FILE_SIZE_REACHES case -- they both
  877. // use the same format of filename.
  878. SetDlgItemText( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_NAME, szWhenLogFileSizeReaches );
  879. // Ascertain what the state of the IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES radio button is.
  880. int iChecked = ::SendMessage( GetDlgItem(IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES), BM_GETCHECK, 0, 0 );
  881. int iEnabled = ::IsWindowEnabled( GetDlgItem( IDC_RADIO_LOCAL_FILE_LOGGING_PAGE2__WHEN_LOG_FILE_REACHES ) );
  882. if( iChecked && iEnabled )
  883. {
  884. // Make sure the correct items are enabled.
  885. ::EnableWindow( GetDlgItem( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE_UNITS), TRUE );
  886. ::EnableWindow( GetDlgItem( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE), TRUE );
  887. }
  888. else
  889. {
  890. // Make sure the correct items are enabled.
  891. ::EnableWindow( GetDlgItem( IDC_STATIC_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE_UNITS), FALSE );
  892. ::EnableWindow( GetDlgItem( IDC_EDIT_LOCAL_FILE_LOGGING_PAGE2__LOG_FILE_SIZE), FALSE );
  893. }
  894. }
  895. /////////////////////////////////////////////////////////////////////////////
  896. /*++
  897. CLocalFileLoggingPage2::GetHelpPath
  898. Remarks:
  899. This method is called to get the help file path within
  900. an compressed HTML document when the user presses on the Help
  901. button of a property sheet.
  902. It is an override of atlsnap.h CIASPropertyPageImpl::OnGetHelpPath.
  903. --*/
  904. //////////////////////////////////////////////////////////////////////////////
  905. HRESULT CLocalFileLoggingPage2::GetHelpPath( LPTSTR szHelpPath )
  906. {
  907. ATLTRACE(_T("# CLocalFileLoggingPage2::GetHelpPath\n"));
  908. // Check for preconditions:
  909. #ifdef UNICODE_HHCTRL
  910. // ISSUE: We seemed to have a problem with passing WCHAR's to the hhctrl.ocx
  911. // installed on this machine -- it appears to be non-unicode.
  912. lstrcpy( szHelpPath, _T("idh_proppage_local_file_logging2.htm") );
  913. #else
  914. strcpy( (CHAR *) szHelpPath, "idh_proppage_local_file_logging2.htm" );
  915. #endif
  916. return S_OK;
  917. }