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.

877 lines
24 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. WzMnVlLs.cpp
  5. Abstract:
  6. Managed Volume wizard.
  7. Author:
  8. Rohde Wakefield [rohde] 08-Aug-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "ManVolLs.h"
  13. #include "WzMnVlLs.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CWizManVolLst
  16. CWizManVolLst::CWizManVolLst( )
  17. {
  18. m_TitleId = IDS_WIZ_MANVOLLST_TITLE;
  19. m_HeaderId = IDB_MANAGE_HEADER;
  20. m_WatermarkId = IDB_MANAGE_WATERMARK;
  21. }
  22. STDMETHODIMP
  23. CWizManVolLst::AddWizardPages(
  24. IN RS_PCREATE_HANDLE Handle,
  25. IN IUnknown* pCallback,
  26. IN ISakSnapAsk* pSakSnapAsk
  27. )
  28. {
  29. WsbTraceIn( L"CWizManVolLst::AddWizardPages", L"" );
  30. HRESULT hr = S_OK;
  31. try {
  32. //
  33. // Initialize the Sheet
  34. //
  35. WsbAffirmHr( InitSheet( Handle, pCallback, 0, pSakSnapAsk, 0, 0 ) );
  36. //
  37. // Load pages
  38. //
  39. WsbAffirmHr( AddPage( &m_PageIntro ) );
  40. WsbAffirmHr( AddPage( &m_PageSelect ) );
  41. WsbAffirmHr( AddPage( &m_PageSelectX ) );
  42. WsbAffirmHr( AddPage( &m_PageLevels ) );
  43. WsbAffirmHr( AddPage( &m_PageFinish ) );
  44. } WsbCatch( hr );
  45. WsbTraceOut( L"CWizManVolLst::AddWizardPages", L"" );
  46. return( hr );
  47. }
  48. CWizManVolLst::~CWizManVolLst()
  49. {
  50. WsbTraceIn( L"CWizManVolLst::~CWizManVolLst", L"" );
  51. WsbTraceOut( L"CWizManVolLst::~CWizManVolLst", L"" );
  52. }
  53. HRESULT CWizManVolLst::OnFinish( )
  54. {
  55. WsbTraceIn( L"CWizManVolLst::OnFinish", L"" );
  56. BOOL doAll = FALSE;
  57. //
  58. // The sheet really owns the process as a whole,
  59. // so it will do the final assembly
  60. //
  61. HRESULT hr = S_OK;
  62. try {
  63. //
  64. // Get the HSM service interface for creating local objects
  65. //
  66. CComPtr<IWsbCreateLocalObject> pCreateLocal;
  67. CComPtr<IWsbIndexedCollection> pCollection;
  68. CComPtr<IHsmManagedResource> pHsmResource;
  69. CComPtr<IHsmServer> pHsmServer;
  70. WsbAffirmHrOk( m_pSakSnapAsk->GetHsmServer( &pHsmServer ) );
  71. WsbAffirmHr( pHsmServer.QueryInterface( &pCreateLocal ) );
  72. WsbAffirmHr( pHsmServer->GetManagedResources( &pCollection ) );
  73. //
  74. // Pull out the default levels for all resources to be managed
  75. //
  76. ULONG defaultFreeSpace = (m_PageLevels.GetHsmLevel() * FSA_HSMLEVEL_1);
  77. LONGLONG defaultMinSize = ( (LONGLONG)m_PageLevels.GetFileSize()) * ((LONGLONG)1024);
  78. FILETIME defaultAccess = WsbLLtoFT ((LONGLONG)m_PageLevels.GetAccessDays() * (LONGLONG)WSB_FT_TICKS_PER_DAY );
  79. // Is the "all" radio button selected?
  80. if( !m_PageSelect.m_radioSelect.GetCheck() ) {
  81. doAll = TRUE;
  82. }
  83. //
  84. // Make sure FSA has most up-to-date status on resources
  85. //
  86. CComPtr<IFsaServer> pFsaServer;
  87. WsbAffirmHrOk( m_pSakSnapAsk->GetFsaServer( &pFsaServer ) );
  88. WsbAffirmHr( pFsaServer->ScanForResources( ) );
  89. //
  90. // Go through the listbox and pull out the checked resources.
  91. // Create HSM managed volumes for them.
  92. //
  93. // Note that we wrap the management in a try/catch so that if an error
  94. // occurs (like a volume not available) that we still do the rest
  95. // of the volumes. We will throw the error after attempting all volumes.
  96. //
  97. HRESULT hrLoop = S_OK;
  98. CSakVolList *pListBox = &(m_PageSelect.m_listBox);
  99. INT index;
  100. for( index = 0; index < pListBox->GetItemCount( ); index++ ) {
  101. if( ( pListBox->GetCheck( index ) ) || ( doAll ) ) {
  102. try {
  103. CResourceInfo* pResInfo = (CResourceInfo*)pListBox->GetItemData( index );
  104. //
  105. // Create Local to server since it will eventually own it.
  106. //
  107. WsbAffirmHr( pCreateLocal->CreateInstance(
  108. CLSID_CHsmManagedResource,
  109. IID_IHsmManagedResource,
  110. (void**)&pHsmResource ) );
  111. //
  112. // Initialize Fsa object to its initial values.
  113. //
  114. WsbAffirmHr( (pResInfo->m_pResource)->SetHsmLevel( defaultFreeSpace ) );
  115. WsbAffirmHr( (pResInfo->m_pResource)->SetManageableItemLogicalSize( defaultMinSize ) );
  116. WsbAffirmHr( (pResInfo->m_pResource)->SetManageableItemAccessTime( TRUE, defaultAccess ) );
  117. //
  118. // Associate HSM Managed Resource with the FSA resource
  119. // (also adds to HSM collection)
  120. //
  121. WsbAffirmHr( pHsmResource->InitFromFsaResource( pResInfo->m_pResource ) );
  122. WsbAffirmHr( pCollection->Add( pHsmResource ) );
  123. } WsbCatch( hrLoop );
  124. pHsmResource.Release( );
  125. }
  126. }
  127. //
  128. // Force a persistant save of the hsm man vol list
  129. //
  130. WsbAffirmHr( RsServerSaveAll( pHsmServer ) );
  131. WsbAffirmHr( RsServerSaveAll( pFsaServer ) );
  132. //
  133. // And check to see if there were any problems doing the manage
  134. //
  135. WsbAffirmHr( hrLoop );
  136. } WsbCatchAndDo( hr,
  137. CString errString;
  138. AfxFormatString1( errString, IDS_ERR_MANVOLWIZ_FINISH, WsbHrAsString( hr ) );
  139. AfxMessageBox( errString, RS_MB_ERROR );
  140. );
  141. m_HrFinish = S_OK;
  142. WsbTraceOut( L"CWizManVolLst::OnFinish", L"hr = <%ls>", WsbHrAsString( m_HrFinish ) );
  143. return(m_HrFinish);
  144. }
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CWizManVolLstLevels property page
  147. CWizManVolLstLevels::CWizManVolLstLevels()
  148. : CSakWizardPage_InitBaseInt( WIZ_MANVOLLST_LEVELS )
  149. {
  150. //{{AFX_DATA_INIT(CWizManVolLstLevels)
  151. m_HsmLevel = 0;
  152. m_AccessDays = 0;
  153. m_FileSize = 0;
  154. //}}AFX_DATA_INIT
  155. }
  156. CWizManVolLstLevels::~CWizManVolLstLevels()
  157. {
  158. WsbTraceIn( L"CWizManVolLst::~CWizManVolLstLevels", L"" );
  159. WsbTraceOut( L"CWizManVolLst::~CWizManVolLstLevels", L"" );
  160. }
  161. void CWizManVolLstLevels::DoDataExchange(CDataExchange* pDX)
  162. {
  163. CSakWizardPage::DoDataExchange(pDX);
  164. //{{AFX_DATA_MAP(CWizManVolLstLevels)
  165. DDX_Control(pDX, IDC_WIZ_MANVOLLST_SPIN_SIZE, m_SpinSize);
  166. DDX_Control(pDX, IDC_WIZ_MANVOLLST_SPIN_LEVEL, m_SpinLevel);
  167. DDX_Control(pDX, IDC_WIZ_MANVOLLST_SPIN_DAYS, m_SpinDays);
  168. DDX_Control(pDX, IDC_WIZ_MANVOLLST_EDIT_SIZE, m_EditSize);
  169. DDX_Control(pDX, IDC_WIZ_MANVOLLST_EDIT_LEVEL, m_EditLevel);
  170. DDX_Control(pDX, IDC_WIZ_MANVOLLST_EDIT_DAYS, m_EditDays);
  171. DDX_Text(pDX, IDC_WIZ_MANVOLLST_EDIT_LEVEL, m_HsmLevel);
  172. DDX_Text(pDX, IDC_WIZ_MANVOLLST_EDIT_DAYS, m_AccessDays);
  173. DDX_Text(pDX, IDC_WIZ_MANVOLLST_EDIT_SIZE, m_FileSize);
  174. //}}AFX_DATA_MAP
  175. }
  176. BEGIN_MESSAGE_MAP(CWizManVolLstLevels, CSakWizardPage)
  177. //{{AFX_MSG_MAP(CWizManVolLstLevels)
  178. //}}AFX_MSG_MAP
  179. END_MESSAGE_MAP()
  180. /////////////////////////////////////////////////////////////////////////////
  181. // CWizManVolLstLevels message handlers
  182. /////////////////////////////////////////////////////////////////////////////
  183. // CWizManVolLstIntro property page
  184. CWizManVolLstIntro::CWizManVolLstIntro()
  185. : CSakWizardPage_InitBaseExt( WIZ_MANVOLLST_INTRO )
  186. {
  187. //{{AFX_DATA_INIT(CWizManVolLstIntro)
  188. // NOTE: the ClassWizard will add member initialization here
  189. //}}AFX_DATA_INIT
  190. }
  191. CWizManVolLstIntro::~CWizManVolLstIntro()
  192. {
  193. WsbTraceIn( L"CWizManVolLst::~CWizManVolLstIntro", L"" );
  194. WsbTraceOut( L"CWizManVolLst::~CWizManVolLstIntro", L"" );
  195. }
  196. void CWizManVolLstIntro::DoDataExchange(CDataExchange* pDX)
  197. {
  198. CSakWizardPage::DoDataExchange(pDX);
  199. //{{AFX_DATA_MAP(CWizManVolLstIntro)
  200. // NOTE: the ClassWizard will add DDX and DDV calls here
  201. //}}AFX_DATA_MAP
  202. }
  203. BEGIN_MESSAGE_MAP(CWizManVolLstIntro, CSakWizardPage)
  204. //{{AFX_MSG_MAP(CWizManVolLstIntro)
  205. //}}AFX_MSG_MAP
  206. END_MESSAGE_MAP()
  207. /////////////////////////////////////////////////////////////////////////////
  208. // CWizManVolLstIntro message handlers
  209. /////////////////////////////////////////////////////////////////////////////
  210. // CWizManVolLstFinish property page
  211. CWizManVolLstFinish::CWizManVolLstFinish()
  212. : CSakWizardPage_InitBaseExt( WIZ_MANVOLLST_FINISH )
  213. {
  214. //{{AFX_DATA_INIT(CWizManVolLstFinish)
  215. // NOTE: the ClassWizard will add member initialization here
  216. //}}AFX_DATA_INIT
  217. }
  218. CWizManVolLstFinish::~CWizManVolLstFinish()
  219. {
  220. WsbTraceIn( L"CWizManVolLst::~CWizManVolLstFinish", L"" );
  221. WsbTraceOut( L"CWizManVolLst::~CWizManVolLstFinish", L"" );
  222. }
  223. void CWizManVolLstFinish::DoDataExchange(CDataExchange* pDX)
  224. {
  225. CSakWizardPage::DoDataExchange(pDX);
  226. //{{AFX_DATA_MAP(CWizManVolLstFinish)
  227. // NOTE: the ClassWizard will add DDX and DDV calls here
  228. //}}AFX_DATA_MAP
  229. }
  230. BEGIN_MESSAGE_MAP(CWizManVolLstFinish, CSakWizardPage)
  231. //{{AFX_MSG_MAP(CWizManVolLstFinish)
  232. ON_EN_SETFOCUS(IDC_WIZ_FINAL_TEXT, OnSetfocusWizManvollstFinalEdit)
  233. //}}AFX_MSG_MAP
  234. END_MESSAGE_MAP()
  235. /////////////////////////////////////////////////////////////////////////////
  236. // CWizManVolLstFinish message handlers
  237. /////////////////////////////////////////////////////////////////////////////
  238. // CWizManVolLstSelect property page
  239. CWizManVolLstSelect::CWizManVolLstSelect()
  240. : CSakWizardPage_InitBaseInt( WIZ_MANVOLLST_SELECT )
  241. {
  242. //{{AFX_DATA_INIT(CWizManVolLstSelect)
  243. // NOTE: the ClassWizard will add member initialization here
  244. //}}AFX_DATA_INIT
  245. }
  246. CWizManVolLstSelect::~CWizManVolLstSelect()
  247. {
  248. WsbTraceIn( L"CWizManVolLst::~CWizManVolLstSelect", L"" );
  249. WsbTraceOut( L"CWizManVolLst::~CWizManVolLstSelect", L"" );
  250. }
  251. void CWizManVolLstSelect::DoDataExchange(CDataExchange* pDX)
  252. {
  253. CSakWizardPage::DoDataExchange(pDX);
  254. //{{AFX_DATA_MAP(CWizManVolLstSelect)
  255. DDX_Control(pDX, IDC_RADIO_SELECT, m_radioSelect);
  256. DDX_Control(pDX, IDC_MANVOLLST_FSARESLBOX, m_listBox);
  257. //}}AFX_DATA_MAP
  258. }
  259. BEGIN_MESSAGE_MAP(CWizManVolLstSelect, CSakWizardPage)
  260. //{{AFX_MSG_MAP(CWizManVolLstSelect)
  261. ON_BN_CLICKED(IDC_RADIO_SELECT, OnRadioSelect)
  262. ON_BN_CLICKED(IDC_RADIO_MANAGE_ALL, OnRadioManageAll)
  263. ON_WM_DESTROY()
  264. ON_NOTIFY(LVN_ITEMCHANGED, IDC_MANVOLLST_FSARESLBOX, OnItemchangedManVollstFsareslbox)
  265. //}}AFX_MSG_MAP
  266. END_MESSAGE_MAP()
  267. BOOL CWizManVolLstIntro::OnInitDialog()
  268. {
  269. CSakWizardPage::OnInitDialog();
  270. return TRUE;
  271. }
  272. BOOL CWizManVolLstLevels::OnInitDialog()
  273. {
  274. CSakWizardPage::OnInitDialog();
  275. CString titleText;
  276. // Set the default initial values for management
  277. // levels
  278. m_SpinLevel.SetRange( HSMADMIN_MIN_FREESPACE, HSMADMIN_MAX_FREESPACE );
  279. m_SpinSize.SetRange( HSMADMIN_MIN_MINSIZE, HSMADMIN_MAX_MINSIZE );
  280. m_SpinDays.SetRange( HSMADMIN_MIN_INACTIVITY, HSMADMIN_MAX_INACTIVITY );
  281. m_SpinLevel.SetPos( HSMADMIN_DEFAULT_FREESPACE );
  282. m_SpinSize.SetPos( HSMADMIN_DEFAULT_MINSIZE );
  283. m_SpinDays.SetPos( HSMADMIN_DEFAULT_INACTIVITY );
  284. m_EditLevel.SetLimitText( 2 );
  285. m_EditSize.SetLimitText( 5 );
  286. m_EditDays.SetLimitText( 3 );
  287. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  288. return( TRUE );
  289. }
  290. void CWizManVolLstLevels::SetWizardFinish()
  291. {
  292. }
  293. BOOL CWizManVolLstSelect::OnInitDialog()
  294. {
  295. WsbTraceIn( L"CWizManVolLstSelect::OnInitDialog", L"" );
  296. CSakWizardPage::OnInitDialog();
  297. HRESULT hr = S_OK;
  298. try {
  299. CComPtr<IFsaServer> pFsaServer;
  300. WsbAffirmHr( m_pSheet->GetFsaServer( &pFsaServer ) );
  301. WsbAffirmHr( FillListBoxSelect( pFsaServer, &m_listBox ) );
  302. // Check the "Select" radio button
  303. CheckRadioButton( IDC_RADIO_MANAGE_ALL, IDC_RADIO_SELECT,
  304. IDC_RADIO_SELECT );
  305. } WsbCatch (hr);
  306. WsbTraceOut( L"CWizManVolLstSelect::OnInitDialog", L"hr = <%ls>", WsbHrAsString( hr ) );
  307. return TRUE;
  308. }
  309. //-----------------------------------------------------------------------------
  310. //
  311. // FillListBoxSelect
  312. //
  313. // Fill the selection list box with non-configured managed resources
  314. //
  315. //
  316. HRESULT CWizManVolLstSelect::FillListBoxSelect (IFsaServer *pFsaServer, CSakVolList *pListBox)
  317. {
  318. WsbTraceIn( L"CWizManVolLstSelect::FillListBoxSelect", L"" );
  319. BOOL gotOne = FALSE;
  320. HRESULT hr = S_OK;
  321. CResourceInfo* pResInfo = 0;
  322. try {
  323. //
  324. // Connect to the FSA for this machine
  325. //
  326. WsbAffirmPointer( pFsaServer );
  327. CComPtr<IWsbEnum> pEnum;
  328. WsbAffirmHr(pFsaServer->EnumResources( &pEnum ) );
  329. HRESULT hrEnum;
  330. CComPtr<IFsaResource> pResource;
  331. hrEnum = pEnum->First( IID_IFsaResource, (void**)&pResource );
  332. WsbAffirm( SUCCEEDED( hrEnum ) || ( WSB_E_NOTFOUND == hrEnum ), hrEnum );
  333. INT index = 0;
  334. while( SUCCEEDED( hrEnum ) ) {
  335. //
  336. // Is the volume managed?
  337. //
  338. if( pResource->IsManaged() != S_OK ) {
  339. //
  340. // If path is blank, do not show this volume
  341. //
  342. if( S_OK == RsIsVolumeAvailable( pResource ) ) {
  343. gotOne = TRUE;
  344. pResInfo = new CResourceInfo( pResource );
  345. WsbAffirmAlloc( pResInfo );
  346. WsbAffirmHr( pResInfo->m_HrConstruct );
  347. //
  348. // Set Name, Capacity and Free Space columns.
  349. //
  350. LONGLONG totalSpace = 0;
  351. LONGLONG freeSpace = 0;
  352. LONGLONG premigrated = 0;
  353. LONGLONG truncated = 0;
  354. WsbAffirmHr( pResource->GetSizes( &totalSpace, &freeSpace, &premigrated, &truncated ) );
  355. CString totalString, freeString;
  356. RsGuiFormatLongLong4Char( totalSpace, totalString );
  357. RsGuiFormatLongLong4Char( freeSpace, freeString );
  358. WsbAffirm( pListBox->AppendItem( pResInfo->m_DisplayName, totalString, freeString, &index ), E_FAIL );
  359. WsbAffirm( -1 != index, E_FAIL );
  360. //
  361. // Store struct pointer in listbox
  362. //
  363. WsbAffirm( pListBox->SetItemData( index, (DWORD_PTR)pResInfo ), E_FAIL );
  364. pResInfo = 0;
  365. //
  366. // Initialize selected array
  367. //
  368. m_listBoxSelected[ index ] = FALSE;
  369. }
  370. }
  371. //
  372. // Prepare for next iteration
  373. //
  374. pResource.Release( );
  375. hrEnum = pEnum->Next( IID_IFsaResource, (void**)&pResource );
  376. }
  377. m_listBox.SortItems( CResourceInfo::Compare, 0 );
  378. //
  379. // Set the button AFTER we fill the box
  380. //
  381. CheckRadioButton( IDC_RADIO_MANAGE_ALL, IDC_RADIO_SELECT, IDC_RADIO_SELECT );
  382. } WsbCatch( hr );
  383. if( pResInfo ) delete pResInfo;
  384. WsbTraceOut( L"CWizManVolLstSelect::FillListBoxSelect", L"hr = <%ls>", WsbHrAsString( hr ) );
  385. return( hr );
  386. }
  387. BOOL CWizManVolLstIntro::OnSetActive()
  388. {
  389. WsbTraceIn( L"CWizManVolLstIntro::OnSetActive", L"" );
  390. m_pSheet->SetWizardButtons( PSWIZB_NEXT );
  391. BOOL retval = CSakWizardPage::OnSetActive();
  392. WsbTraceOut( L"CWizManVolLstIntro::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  393. return( retval );
  394. }
  395. BOOL CWizManVolLstLevels::OnSetActive()
  396. {
  397. WsbTraceIn( L"CWizManVolLstLevels::OnSetActive", L"" );
  398. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  399. BOOL retval = CSakWizardPage::OnSetActive();
  400. WsbTraceOut( L"CWizManVolLstLevels::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  401. return( retval );
  402. }
  403. BOOL CWizManVolLstLevels::OnKillActive()
  404. {
  405. WsbTraceIn( L"CWizManVolLstLevels::OnKillActive", L"" );
  406. BOOL retval = FALSE;
  407. //
  408. // Need to handle strange case where a user can enter a value within
  409. // the parameters of the number of digits allowed, but the value can
  410. // be out of range. This is detected by the spin box which will
  411. // return an error if its buddy control is out of range.
  412. //
  413. if( HIWORD( m_SpinSize.GetPos( ) ) > 0 ) {
  414. // Control reports on error...
  415. retval = FALSE;
  416. CString message;
  417. AfxFormatString2( message, IDS_ERR_MINSIZE_RANGE,
  418. CString( WsbLongAsString( (LONG)HSMADMIN_MIN_MINSIZE ) ),
  419. CString( WsbLongAsString( (LONG)HSMADMIN_MAX_MINSIZE ) ) );
  420. AfxMessageBox( message, MB_OK | MB_ICONWARNING );
  421. } else {
  422. retval = CSakWizardPage::OnKillActive();
  423. }
  424. WsbTraceOut( L"CWizManVolLstLevels::OnKillActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  425. return( retval );
  426. }
  427. BOOL CWizManVolLstSelect::OnSetActive()
  428. {
  429. WsbTraceIn( L"CWizManVolLstSelect::OnSetActive", L"" );
  430. BOOL retval = CSakWizardPage::OnSetActive( );
  431. if( m_listBox.GetItemCount( ) <= 0 ) {
  432. retval = FALSE;
  433. }
  434. SetBtnStates( );
  435. WsbTraceOut( L"CWizManVolLstSelect::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  436. return( retval );
  437. }
  438. BOOL CWizManVolLstFinish::OnSetActive()
  439. {
  440. BOOL doAll = FALSE;
  441. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  442. //
  443. // Fill in text of configuration
  444. //
  445. CString formattedString, buildString, tempString, indentString;
  446. indentString.LoadString( IDS_QSTART_FINISH_INDENT );
  447. #define FORMAT_TEXT( cid, arg ) \
  448. AfxFormatString1( formattedString, cid, arg ); \
  449. buildString += formattedString;
  450. //
  451. // Add Resources
  452. //
  453. FORMAT_TEXT( IDS_QSTART_MANRES_TEXT, 0 );
  454. buildString += L"\r\n";
  455. CWizManVolLst* pSheet = (CWizManVolLst*) m_pSheet;
  456. CSakVolList *pListBox = &(pSheet->m_PageSelect.m_listBox);
  457. INT index, managedCount = 0;
  458. for( index = 0; index < pListBox->GetItemCount( ); index++ ) {
  459. if( pListBox->GetCheck( index ) ) {
  460. buildString += indentString;
  461. tempString = pListBox->GetItemText( index, 0);
  462. buildString += tempString;
  463. buildString += L"\r\n";
  464. managedCount++;
  465. }
  466. }
  467. if( 0 == managedCount ) {
  468. FORMAT_TEXT( IDS_QSTART_MANAGE_NO_VOLUMES, 0 );
  469. buildString += L"\r\n\r\n";
  470. } else {
  471. buildString += L"\r\n";
  472. //
  473. // The levels
  474. //
  475. FORMAT_TEXT( IDS_QSTART_FREESPACE_TEXT, WsbLongAsString( pSheet->m_PageLevels.m_SpinLevel.GetPos( ) ) );
  476. buildString += L"\r\n\r\n";
  477. AfxFormatString2( formattedString, IDS_QSTART_CRITERIA_TEXT,
  478. CString( WsbLongAsString( pSheet->m_PageLevels.m_SpinSize.GetPos( ) ) ),
  479. CString( WsbLongAsString( pSheet->m_PageLevels.m_SpinDays.GetPos( ) ) ) );
  480. buildString += formattedString;
  481. }
  482. CEdit * pEdit = (CEdit*)GetDlgItem( IDC_WIZ_FINAL_TEXT );
  483. pEdit->SetWindowText( buildString );
  484. //
  485. // Now check to see if we should add a scroll bar
  486. //
  487. pEdit->SetMargins( 4, 4 );
  488. //
  489. // It seems the only way to know that an edit control needs a scrollbar
  490. // is to force it to scroll to the bottom and see if the first
  491. // visible line is the first actual line
  492. //
  493. pEdit->LineScroll( MAXSHORT );
  494. if( pEdit->GetFirstVisibleLine( ) > 0 ) {
  495. //
  496. // Add the scroll styles
  497. //
  498. pEdit->ModifyStyle( 0, WS_VSCROLL | ES_AUTOVSCROLL, SWP_DRAWFRAME );
  499. } else {
  500. //
  501. // Remove the scrollbar (set range to 0)
  502. //
  503. pEdit->SetScrollRange( SB_VERT, 0, 0, TRUE );
  504. }
  505. // Scroll to the top
  506. pEdit->PostMessage( EM_SETSEL, 0, 0 );
  507. pEdit->PostMessage( EM_SCROLLCARET, 0, 0 );
  508. pEdit->PostMessage( EM_SETSEL, -1, 0 );
  509. BOOL fRet = CSakWizardPage::OnSetActive();
  510. return fRet;
  511. }
  512. void CWizManVolLstFinish::OnSetfocusWizManvollstFinalEdit()
  513. {
  514. // Deselect the text
  515. CEdit *pEdit = (CEdit *) GetDlgItem( IDC_WIZ_FINAL_TEXT );
  516. pEdit->SetSel( -1, 0, FALSE );
  517. }
  518. ULONG CWizManVolLstLevels::GetFileSize()
  519. {
  520. return( m_SpinSize.GetPos( ) );
  521. }
  522. INT CWizManVolLstLevels::GetHsmLevel()
  523. {
  524. return( m_SpinLevel.GetPos( ) );
  525. }
  526. INT CWizManVolLstLevels::GetAccessDays()
  527. {
  528. return( m_SpinDays.GetPos( ) );
  529. }
  530. void CWizManVolLstSelect::OnItemchangedManVollstFsareslbox(NMHDR* pNMHDR, LRESULT* pResult)
  531. {
  532. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  533. SetBtnStates();
  534. *pResult = 0;
  535. }
  536. void CWizManVolLstSelect::SetBtnStates()
  537. {
  538. BOOL fChecked = FALSE;
  539. INT count;
  540. // Is the "all" radio checked?
  541. if( !( m_radioSelect.GetCheck() == 1 ) ) {
  542. fChecked = TRUE;
  543. } else {
  544. // If one or more selected in the list box, set next button
  545. count = m_listBox.GetItemCount();
  546. for( INT index = 0; index < count; index++ ) {
  547. if( m_listBox.GetCheck( index ) == 1 ) {
  548. fChecked = TRUE;
  549. }
  550. }
  551. }
  552. if( fChecked ) {
  553. m_pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  554. } else {
  555. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  556. }
  557. }
  558. void CWizManVolLstSelect::OnRadioSelect()
  559. {
  560. INT i;
  561. //
  562. // Get saved selection from itemdata array
  563. //
  564. for( i = 0; i < m_listBox.GetItemCount(); i++ ) {
  565. m_listBox.SetCheck( i, m_listBoxSelected[ i ] );
  566. }
  567. m_listBox.EnableWindow( TRUE );
  568. SetBtnStates();
  569. }
  570. void CWizManVolLstSelect::OnRadioManageAll()
  571. {
  572. INT i;
  573. //
  574. // Save the current selection in the itemData array
  575. // Check all the boxes for display purposes only
  576. //
  577. for( i = 0; i < m_listBox.GetItemCount(); i++ ) {
  578. m_listBoxSelected[ i ] = m_listBox.GetCheck( i );
  579. m_listBox.SetCheck( i, TRUE );
  580. }
  581. m_listBox.EnableWindow( FALSE );
  582. SetBtnStates();
  583. }
  584. void CWizManVolLstSelect::OnDestroy()
  585. {
  586. WsbTraceIn( L"CWizManVolLstSelect::OnDestroy", L"" );
  587. CSakWizardPage::OnDestroy();
  588. //
  589. // Need to free info held by list box
  590. //
  591. INT index;
  592. for( index = 0; index < m_listBox.GetItemCount( ); index++ ) {
  593. CResourceInfo* pResInfo = (CResourceInfo*)m_listBox.GetItemData( index );
  594. delete pResInfo;
  595. }
  596. WsbTraceOut( L"CWizManVolLstSelect::OnDestroy", L"" );
  597. }
  598. /////////////////////////////////////////////////////////////////////////////
  599. // CWizManVolLstSelectX property page
  600. CWizManVolLstSelectX::CWizManVolLstSelectX()
  601. : CSakWizardPage_InitBaseInt( WIZ_MANVOLLST_SELECTX )
  602. {
  603. //{{AFX_DATA_INIT(CWizManVolLstSelectX)
  604. // NOTE: the ClassWizard will add member initialization here
  605. //}}AFX_DATA_INIT
  606. }
  607. CWizManVolLstSelectX::~CWizManVolLstSelectX()
  608. {
  609. WsbTraceIn( L"CWizManVolLst::~CWizManVolLstSelectX", L"" );
  610. WsbTraceOut( L"CWizManVolLst::~CWizManVolLstSelectX", L"" );
  611. }
  612. void CWizManVolLstSelectX::DoDataExchange(CDataExchange* pDX)
  613. {
  614. CSakWizardPage::DoDataExchange(pDX);
  615. //{{AFX_DATA_MAP(CWizManVolLstSelectX)
  616. //}}AFX_DATA_MAP
  617. }
  618. BEGIN_MESSAGE_MAP(CWizManVolLstSelectX, CSakWizardPage)
  619. //{{AFX_MSG_MAP(CWizManVolLstSelectX)
  620. //}}AFX_MSG_MAP
  621. END_MESSAGE_MAP()
  622. BOOL CWizManVolLstSelectX::OnSetActive()
  623. {
  624. WsbTraceIn( L"CWizManVolLstSelectX::OnSetActive", L"" );
  625. BOOL retval = CSakWizardPage::OnSetActive( );
  626. CWizManVolLst* pSheet = (CWizManVolLst*) m_pSheet;
  627. if( pSheet->m_PageSelect.m_listBox.GetItemCount( ) > 0 ) {
  628. retval = FALSE;
  629. }
  630. m_pSheet->SetWizardButtons( PSWIZB_BACK );
  631. WsbTraceOut( L"CWizManVolLstSelectX::OnSetActive", L"retval = <%ls>", WsbBoolAsString( retval ) );
  632. return( retval );
  633. }