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.

1063 lines
19 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. metaback.cpp
  5. Abstract:
  6. Metabase backup and restore dialog
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. --*/
  14. //
  15. // Include Files
  16. //
  17. #include "stdafx.h"
  18. #include "common.h"
  19. #include "InetMgrApp.h"
  20. #include "iisobj.h"
  21. #include "mddefw.h"
  22. #include "metaback.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. //
  29. // CBackupsListBox : a listbox of CBackup objects
  30. //
  31. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  32. //
  33. // Column width relative weights
  34. //
  35. #define WT_LOCATION 8
  36. #define WT_VERSION 2
  37. #define WT_DATE 6
  38. //
  39. // Registry key name for this dialog
  40. //
  41. const TCHAR g_szRegKey[] = _T("MetaBack");
  42. IMPLEMENT_DYNAMIC(CBackupsListBox, CHeaderListBox);
  43. const int CBackupsListBox::nBitmaps = 1;
  44. #define HAS_BACKUP_PASSWORD(x) \
  45. ((x)->QueryMajorVersion() == 5 && (x)->QueryMinorVersion() == 1) || ((x)->QueryMajorVersion() >= 6)
  46. CBackupsListBox::CBackupsListBox()
  47. /*++
  48. Routine Description:
  49. Backups listbox constructor
  50. Arguments:
  51. None
  52. Return Value:
  53. N/A
  54. --*/
  55. : CHeaderListBox(HLS_STRETCH, g_szRegKey)
  56. {
  57. }
  58. void
  59. CBackupsListBox::DrawItemEx(
  60. IN CRMCListBoxDrawStruct & ds
  61. )
  62. /*++
  63. Routine Description:
  64. Draw item in the listbox
  65. Arguments:
  66. CRMCListBoxDrawStruct & ds : Input data structure
  67. Return Value:
  68. N/A
  69. --*/
  70. {
  71. CBackupFile * p = (CBackupFile *)ds.m_ItemData;
  72. ASSERT_READ_PTR(p);
  73. DrawBitmap(ds, 0, 0);
  74. CString strVersion;
  75. strVersion.Format(_T("%ld"), p->QueryVersion());
  76. #define MAXLEN (128)
  77. //
  78. // Convert date and time to local format
  79. //
  80. CTime tm;
  81. p->GetTime(tm);
  82. SYSTEMTIME stm =
  83. {
  84. (WORD)tm.GetYear(),
  85. (WORD)tm.GetMonth(),
  86. (WORD)tm.GetDayOfWeek(),
  87. (WORD)tm.GetDay(),
  88. (WORD)tm.GetHour(),
  89. (WORD)tm.GetMinute(),
  90. (WORD)tm.GetSecond(),
  91. 0 // Milliseconds
  92. };
  93. CString strDate, strTime;
  94. LPTSTR lp = strDate.GetBuffer(MAXLEN);
  95. ::GetDateFormat(
  96. LOCALE_USER_DEFAULT,
  97. DATE_SHORTDATE,
  98. &stm,
  99. NULL,
  100. lp,
  101. MAXLEN
  102. );
  103. strDate.ReleaseBuffer();
  104. lp = strTime.GetBuffer(MAXLEN);
  105. GetTimeFormat(LOCALE_USER_DEFAULT, 0L, &stm, NULL, lp, MAXLEN);
  106. strTime.ReleaseBuffer();
  107. strDate += _T(" ");
  108. strDate += strTime;
  109. ColumnText(ds, 0, TRUE, (LPCTSTR)p->QueryLocation());
  110. ColumnText(ds, 1, FALSE, strVersion);
  111. ColumnText(ds, 2, FALSE, strDate);
  112. }
  113. /* virtual */
  114. BOOL
  115. CBackupsListBox::Initialize()
  116. /*++
  117. Routine Description:
  118. initialize the listbox. Insert the columns
  119. as requested, and lay them out appropriately
  120. Arguments:
  121. None
  122. Return Value:
  123. TRUE if initialized successfully, FALSE otherwise
  124. --*/
  125. {
  126. if (!CHeaderListBox::Initialize())
  127. {
  128. return FALSE;
  129. }
  130. HINSTANCE hInst = AfxGetResourceHandle();
  131. InsertColumn(0, WT_LOCATION, IDS_BACKUP_LOCATION, hInst);
  132. InsertColumn(1, WT_VERSION, IDS_BACKUP_VERSION, hInst);
  133. InsertColumn(2, WT_DATE, IDS_BACKUP_DATE, hInst);
  134. //
  135. // Try to set the widths from the stored registry value,
  136. // otherwise distribute according to column weights specified
  137. //
  138. // if (!SetWidthsFromReg())
  139. // {
  140. DistributeColumns();
  141. // }
  142. return TRUE;
  143. }
  144. //
  145. // Backup file object properties dialog
  146. //
  147. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  148. CBkupPropDlg::CBkupPropDlg(
  149. IN CIISMachine * pMachine,
  150. IN CWnd * pParent OPTIONAL
  151. )
  152. /*++
  153. Routine Description:
  154. Constructor
  155. Arguments:
  156. CIISMachine * pMachine : Machine object
  157. CWnd * pParent : Optional parent window
  158. Return Value:
  159. N/A
  160. --*/
  161. : CDialog(CBkupPropDlg::IDD, pParent),
  162. m_pMachine(pMachine),
  163. m_strName(),
  164. m_strPassword()
  165. {
  166. ASSERT_PTR(m_pMachine);
  167. }
  168. void
  169. CBkupPropDlg::DoDataExchange(
  170. IN CDataExchange * pDX
  171. )
  172. /*++
  173. Routine Description:
  174. Initialise/Store control data
  175. Arguments:
  176. CDataExchange * pDX - DDX/DDV control structure
  177. Return Value:
  178. None
  179. --*/
  180. {
  181. CDialog::DoDataExchange(pDX);
  182. //{{AFX_DATA_MAP(CBkupPropDlg)
  183. DDX_Control(pDX, IDC_EDIT_BACKUP_NAME, m_edit_Name);
  184. DDX_Control(pDX, IDC_BACKUP_PASSWORD, m_edit_Password);
  185. DDX_Control(pDX, IDC_BACKUP_PASSWORD_CONFIRM, m_edit_PasswordConfirm);
  186. DDX_Control(pDX, IDC_USE_PASSWORD, m_button_Password);
  187. DDX_Control(pDX, IDOK, m_button_OK);
  188. DDX_Text(pDX, IDC_EDIT_BACKUP_NAME, m_strName);
  189. DDV_MaxChars(pDX, m_strName, MD_BACKUP_MAX_LEN - 1);
  190. //}}AFX_DATA_MAP
  191. if (m_button_Password.GetCheck())
  192. {
  193. DDX_Text(pDX, IDC_BACKUP_PASSWORD, m_strPassword);
  194. DDV_MinChars(pDX, m_strPassword, MIN_PASSWORD_LENGTH);
  195. DDX_Text(pDX, IDC_BACKUP_PASSWORD_CONFIRM, m_strPasswordConfirm);
  196. DDV_MinChars(pDX, m_strPasswordConfirm, MIN_PASSWORD_LENGTH);
  197. }
  198. }
  199. //
  200. // Message Map
  201. //
  202. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  203. BEGIN_MESSAGE_MAP(CBkupPropDlg, CDialog)
  204. //{{AFX_MSG_MAP(CBkupPropDlg)
  205. ON_EN_CHANGE(IDC_EDIT_BACKUP_NAME, OnChangeEditBackupName)
  206. ON_EN_CHANGE(IDC_BACKUP_PASSWORD, OnChangeEditPassword)
  207. ON_EN_CHANGE(IDC_BACKUP_PASSWORD_CONFIRM, OnChangeEditPassword)
  208. ON_BN_CLICKED(IDC_USE_PASSWORD, OnUsePassword)
  209. //}}AFX_MSG_MAP
  210. END_MESSAGE_MAP()
  211. //
  212. // Message Handlers
  213. //
  214. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  215. void
  216. CBkupPropDlg::OnChangeEditBackupName()
  217. /*++
  218. Routine Description:
  219. Backup name edit change notification handler.
  220. Arguments:
  221. None.
  222. Return Value:
  223. None.
  224. --*/
  225. {
  226. BOOL bEnableOK = m_edit_Name.GetWindowTextLength() > 0;
  227. m_button_OK.EnableWindow(bEnableOK);
  228. if (bEnableOK && m_button_Password.GetCheck())
  229. {
  230. m_button_OK.EnableWindow(
  231. m_edit_Password.GetWindowTextLength() >= MIN_PASSWORD_LENGTH
  232. && m_edit_PasswordConfirm.GetWindowTextLength() >= MIN_PASSWORD_LENGTH);
  233. }
  234. }
  235. BOOL
  236. CBkupPropDlg::OnInitDialog()
  237. /*++
  238. Routine Description:
  239. WM_INITDIALOG handler. Initialize the dialog.
  240. Arguments:
  241. None.
  242. Return Value:
  243. TRUE if no focus is to be set automatically, FALSE if the focus
  244. is already set.
  245. --*/
  246. {
  247. CDialog::OnInitDialog();
  248. m_button_OK.EnableWindow(FALSE);
  249. m_button_Password.EnableWindow(HAS_BACKUP_PASSWORD(m_pMachine));
  250. m_button_Password.SetCheck(FALSE);
  251. m_edit_Password.EnableWindow(FALSE);
  252. m_edit_PasswordConfirm.EnableWindow(FALSE);
  253. return TRUE;
  254. }
  255. void
  256. CBkupPropDlg::OnChangeEditPassword()
  257. {
  258. m_button_OK.EnableWindow(
  259. m_edit_Password.GetWindowTextLength() >= MIN_PASSWORD_LENGTH
  260. && m_edit_PasswordConfirm.GetWindowTextLength() >= MIN_PASSWORD_LENGTH
  261. && m_edit_Name.GetWindowTextLength() > 0);
  262. }
  263. void
  264. CBkupPropDlg::OnUsePassword()
  265. {
  266. BOOL bUseIt = m_button_Password.GetCheck();
  267. m_edit_Password.EnableWindow(bUseIt);
  268. m_edit_PasswordConfirm.EnableWindow(bUseIt);
  269. if (bUseIt)
  270. {
  271. OnChangeEditPassword();
  272. }
  273. else
  274. {
  275. OnChangeEditBackupName();
  276. }
  277. }
  278. void
  279. CBkupPropDlg::OnOK()
  280. /*++
  281. Routine Description:
  282. 'OK' button handler -- create the backup.
  283. Arguments:
  284. None
  285. Return Value:
  286. None
  287. --*/
  288. {
  289. if (UpdateData(TRUE))
  290. {
  291. if (m_button_Password.GetCheck() && m_strPassword.Compare(m_strPasswordConfirm) != 0)
  292. {
  293. AfxMessageBox(IDS_PASSWORDS_DOESNT_MATCH);
  294. return;
  295. }
  296. BeginWaitCursor();
  297. ASSERT_PTR(m_pMachine);
  298. //
  299. // CODEWORK: Verify impersonation settings
  300. //
  301. CMetaBack mb(m_pMachine->QueryAuthInfo());
  302. CError err(mb.QueryResult());
  303. if (err.Succeeded())
  304. {
  305. if (HAS_BACKUP_PASSWORD(m_pMachine))
  306. {
  307. if (m_button_Password.GetCheck())
  308. {
  309. err = mb.BackupWithPassword(m_strName, m_strPassword);
  310. }
  311. else
  312. {
  313. err = mb.BackupWithPassword(m_strName, _T(""));
  314. }
  315. }
  316. else
  317. {
  318. err = mb.Backup(m_strName);
  319. }
  320. }
  321. EndWaitCursor();
  322. if (err.Failed())
  323. {
  324. m_edit_Name.SetSel(0, -1);
  325. //
  326. // Special error message if IISADMIN just didn't
  327. // like the name.
  328. //
  329. if (err.Win32Error() == ERROR_INVALID_PARAMETER)
  330. {
  331. ::AfxMessageBox(IDS_BACKUP_BAD_NAME);
  332. ((CEdit *)GetDlgItem(IDC_EDIT_BACKUP_NAME))->SetSel(0, -1);
  333. }
  334. else
  335. {
  336. err.MessageBox();
  337. }
  338. //
  339. // Don't dismiss the dialog
  340. //
  341. return;
  342. }
  343. EndDialog(IDOK);
  344. }
  345. }
  346. //
  347. // Metabase/Restore dialog
  348. //
  349. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  350. CBackupDlg::CBackupDlg(
  351. IN CIISMachine * pMachine,
  352. IN CWnd * pParent OPTIONAL
  353. )
  354. /*++
  355. Routine Description:
  356. Constructor
  357. Arguments:
  358. CIISMachine * pMachine : Machine object
  359. CWnd * pParent : Optional parent window
  360. Return Value:
  361. N/A
  362. --*/
  363. : m_pMachine(pMachine),
  364. m_list_Backups(),
  365. m_ListBoxRes(IDB_BACKUPS, m_list_Backups.nBitmaps),
  366. m_oblBackups(),
  367. m_fChangedMetabase(FALSE),
  368. CDialog(CBackupDlg::IDD, pParent)
  369. {
  370. //{{AFX_DATA_INIT(CBackupDlg)
  371. //}}AFX_DATA_INIT
  372. ASSERT_PTR(m_pMachine);
  373. m_list_Backups.AttachResources(&m_ListBoxRes);
  374. }
  375. void
  376. CBackupDlg::DoDataExchange(
  377. IN CDataExchange * pDX
  378. )
  379. /*++
  380. Routine Description:
  381. Initialise/Store control data
  382. Arguments:
  383. CDataExchange * pDX - DDX/DDV control structure
  384. Return Value:
  385. None
  386. --*/
  387. {
  388. CDialog::DoDataExchange(pDX);
  389. //{{AFX_DATA_MAP(CBackupDlg)
  390. DDX_Control(pDX, IDC_BUTTON_RESTORE, m_button_Restore);
  391. DDX_Control(pDX, IDC_BUTTON_DELETE, m_button_Delete);
  392. DDX_Control(pDX, IDOK, m_button_Close);
  393. //}}AFX_DATA_MAP
  394. DDX_Control(pDX, IDC_LIST_BACKUPS, m_list_Backups);
  395. }
  396. void
  397. CBackupDlg::SetControlStates()
  398. /*++
  399. Routine Description:
  400. Setting control states depending on the state of the dialog
  401. Arguments:
  402. None
  403. Return Value:
  404. None
  405. --*/
  406. {
  407. m_button_Restore.EnableWindow(m_list_Backups.GetSelCount() == 1);
  408. m_button_Delete.EnableWindow(m_list_Backups.GetSelCount() > 0);
  409. }
  410. HRESULT
  411. CBackupDlg::EnumerateBackups(
  412. LPCTSTR lpszSelect OPTIONAL
  413. )
  414. /*++
  415. Routine Description:
  416. Enumerate all existing backups, and add them to the listbox
  417. Arguments:
  418. LPCTSTR lpszSelect : Optional item to select
  419. Return Value:
  420. HRESULT
  421. Notes:
  422. The highest version number of the given name (if any) will
  423. be selected.
  424. --*/
  425. {
  426. CWaitCursor wait;
  427. m_list_Backups.SetRedraw(FALSE);
  428. m_list_Backups.ResetContent();
  429. m_oblBackups.RemoveAll();
  430. int nSel = LB_ERR;
  431. ASSERT_PTR(m_pMachine);
  432. //
  433. // CODEWORK: Verify impersonation settings
  434. //
  435. CMetaBack mb(m_pMachine->QueryAuthInfo());
  436. CError err(mb.QueryResult());
  437. if (err.Succeeded())
  438. {
  439. DWORD dwVersion;
  440. FILETIME ft;
  441. TCHAR szPath[MAX_PATH + 1] = _T("");
  442. int nItem = 0;
  443. FOREVER
  444. {
  445. *szPath = _T('\0');
  446. err = mb.Next(&dwVersion, szPath, &ft);
  447. if (err.Failed())
  448. {
  449. break;
  450. }
  451. TRACEEOLID(szPath << " v" << dwVersion);
  452. CBackupFile * pItem = new CBackupFile(szPath, dwVersion, &ft);
  453. if (!pItem)
  454. {
  455. TRACEEOLID("EnumerateBackups: OOM");
  456. err = ERROR_NOT_ENOUGH_MEMORY;
  457. break;
  458. }
  459. m_oblBackups.AddTail(pItem);
  460. VERIFY(LB_ERR != m_list_Backups.AddItem(pItem));
  461. if (lpszSelect != NULL && lstrcmpi(lpszSelect, szPath) == 0)
  462. {
  463. //
  464. // Remember selection for later
  465. //
  466. nSel = nItem;
  467. }
  468. ++nItem;
  469. }
  470. if (err.Win32Error() == ERROR_NO_MORE_ITEMS)
  471. {
  472. //
  473. // Finished enumeration successfully
  474. //
  475. err.Reset();
  476. }
  477. }
  478. //
  479. // Select item requested if any
  480. //
  481. m_list_Backups.SetCurSel(nSel);
  482. m_list_Backups.SetRedraw(TRUE);
  483. SetControlStates();
  484. return err;
  485. }
  486. //
  487. // Message Map
  488. //
  489. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  490. BEGIN_MESSAGE_MAP(CBackupDlg, CDialog)
  491. //{{AFX_MSG_MAP(CBackupDlg)
  492. ON_BN_CLICKED(IDC_BUTTON_CREATE, OnButtonCreate)
  493. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  494. ON_BN_CLICKED(IDC_BUTTON_RESTORE, OnButtonRestore)
  495. ON_LBN_DBLCLK(IDC_LIST_BACKUPS, OnDblclkListBackups)
  496. ON_LBN_SELCHANGE(IDC_LIST_BACKUPS, OnSelchangeListBackups)
  497. //}}AFX_MSG_MAP
  498. END_MESSAGE_MAP()
  499. //
  500. // Message Handlers
  501. //
  502. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  503. BOOL
  504. CBackupDlg::OnInitDialog()
  505. /*++
  506. Routine Description:
  507. WM_INITDIALOG handler
  508. Arguments:
  509. None
  510. Return Value:
  511. TRUE if successfully initialized, FALSE otherwise.
  512. --*/
  513. {
  514. CDialog::OnInitDialog();
  515. m_list_Backups.Initialize();
  516. CError err(EnumerateBackups());
  517. if (err.Failed())
  518. {
  519. err.AddOverride(REGDB_E_CLASSNOTREG, IDS_ERR_NO_BACKUP_RESTORE);
  520. m_pMachine->DisplayError(err);
  521. EndDialog(IDCANCEL);
  522. }
  523. return TRUE;
  524. }
  525. void
  526. CBackupDlg::OnButtonCreate()
  527. /*++
  528. Routine Description:
  529. "Create" button handler
  530. Arguments:
  531. None
  532. Return Value:
  533. None
  534. --*/
  535. {
  536. CBkupPropDlg dlg(m_pMachine, this);
  537. if (dlg.DoModal() == IDOK)
  538. {
  539. //
  540. // We can only return OK if the creation worked
  541. // which is done in the properties dialog.
  542. //
  543. EnumerateBackups(dlg.QueryName());
  544. }
  545. }
  546. void
  547. CBackupDlg::OnButtonDelete()
  548. /*++
  549. Routine Description:
  550. "Delete" button handler
  551. Arguments:
  552. None
  553. Return Value:
  554. None
  555. --*/
  556. {
  557. if (!NoYesMessageBox(IDS_CONFIRM_DELETE_ITEMS))
  558. {
  559. //
  560. // Changed his mind
  561. //
  562. return;
  563. }
  564. m_list_Backups.SetRedraw(FALSE);
  565. CWaitCursor wait;
  566. ASSERT_PTR(m_pMachine);
  567. //
  568. // CODEWORK: Verify metabase settings
  569. //
  570. CMetaBack mb(m_pMachine->QueryAuthInfo());
  571. CError err(mb.QueryResult());
  572. if (err.Failed())
  573. {
  574. m_pMachine->DisplayError(err);
  575. return;
  576. }
  577. int nSel = 0;
  578. CBackupFile * pItem;
  579. while ((pItem = m_list_Backups.GetNextSelectedItem(&nSel)) != NULL)
  580. {
  581. TRACEEOLID("Deleting backup "
  582. << pItem->QueryLocation()
  583. << " v"
  584. << pItem->QueryVersion()
  585. );
  586. err = mb.Delete(
  587. pItem->QueryLocation(),
  588. pItem->QueryVersion()
  589. );
  590. if (err.Failed())
  591. {
  592. m_pMachine->DisplayError(err);
  593. break;
  594. }
  595. m_list_Backups.DeleteString(nSel);
  596. //
  597. // Don't advance counter to account for shift
  598. //
  599. }
  600. m_list_Backups.SetRedraw(TRUE);
  601. SetControlStates();
  602. //
  603. // Ensure focus is not on a disabled button.
  604. //
  605. m_button_Close.SetFocus();
  606. }
  607. void
  608. CBackupDlg::OnButtonRestore()
  609. /*++
  610. Routine Description:
  611. 'Restore' button handler
  612. Arguments:
  613. None
  614. Return Value:
  615. None
  616. --*/
  617. {
  618. CBackupFile * pItem = GetSelectedListItem();
  619. ASSERT_READ_PTR(pItem);
  620. if (pItem != NULL)
  621. {
  622. if (NoYesMessageBox(IDS_RESTORE_CONFIRM))
  623. {
  624. ASSERT_PTR(m_pMachine);
  625. //
  626. // CODEWORK: Verify impersonation settings
  627. //
  628. CMetaBack mb(m_pMachine->QueryAuthInfo());
  629. CError err(mb.QueryResult());
  630. if (err.Succeeded())
  631. {
  632. //
  633. // the WAM stuff takes a while
  634. //
  635. CWaitCursor wait;
  636. //
  637. // Restore method will take care of WAM save/recover
  638. //
  639. if (HAS_BACKUP_PASSWORD(m_pMachine))
  640. {
  641. err = mb.RestoreWithPassword(pItem->QueryLocation(), pItem->QueryVersion(), _T(""));
  642. }
  643. else
  644. {
  645. err = mb.Restore(pItem->QueryLocation(), pItem->QueryVersion());
  646. }
  647. }
  648. if (err.Win32Error() == ERROR_WRONG_PASSWORD)
  649. {
  650. CBackupPassword dlg(this);
  651. if (dlg.DoModal() == IDOK)
  652. {
  653. CWaitCursor wait;
  654. err = mb.RestoreWithPassword(pItem->QueryLocation(), pItem->QueryVersion(), dlg.m_password);
  655. if (err.Win32Error() == ERROR_WRONG_PASSWORD)
  656. {
  657. ::AfxMessageBox(
  658. IDS_WRONG_PASSWORD,
  659. MB_OK | MB_ICONEXCLAMATION
  660. );
  661. return;
  662. }
  663. else if (err.Failed())
  664. {
  665. ::AfxMessageBox(
  666. IDS_ERR_CANNOT_RESTORE,
  667. MB_OK | MB_ICONEXCLAMATION
  668. );
  669. return;
  670. }
  671. else
  672. {
  673. ::AfxMessageBox(IDS_SUCCESS, MB_OK | MB_ICONINFORMATION);
  674. m_button_Close.SetFocus();
  675. m_fChangedMetabase = TRUE;
  676. }
  677. }
  678. else
  679. {
  680. return;
  681. }
  682. }
  683. else if (err.Succeeded())
  684. {
  685. ::AfxMessageBox(IDS_SUCCESS, MB_OK | MB_ICONINFORMATION);
  686. m_button_Close.SetFocus();
  687. m_fChangedMetabase = TRUE;
  688. }
  689. else
  690. {
  691. err.MessageBox();
  692. }
  693. }
  694. }
  695. }
  696. void
  697. CBackupDlg::OnDblclkListBackups()
  698. /*++
  699. Routine Description:
  700. Backup list "double click" notification handler
  701. Arguments:
  702. None
  703. Return Value:
  704. None
  705. --*/
  706. {
  707. //
  708. // Nothing presents itself as an obvious action here
  709. //
  710. }
  711. void
  712. CBackupDlg::OnSelchangeListBackups()
  713. /*++
  714. Routine Description:
  715. Backup list "selection change" notification handler
  716. Arguments:
  717. None
  718. Return Value:
  719. None
  720. --*/
  721. {
  722. SetControlStates();
  723. }
  724. CBackupPassword::CBackupPassword(CWnd * pParent) :
  725. CDialog(CBackupPassword::IDD, pParent)
  726. {
  727. }
  728. BEGIN_MESSAGE_MAP(CBackupPassword, CDialog)
  729. //{{AFX_MSG_MAP(CBackupPassword)
  730. ON_EN_CHANGE(IDC_BACKUP_PASSWORD, OnChangedPassword)
  731. //}}AFX_MSG_MAP
  732. END_MESSAGE_MAP()
  733. void
  734. CBackupPassword::DoDataExchange(
  735. IN CDataExchange * pDX
  736. )
  737. {
  738. CDialog::DoDataExchange(pDX);
  739. //{{AFX_DATA_MAP(CBackupPassword)
  740. DDX_Control(pDX, IDC_BACKUP_PASSWORD, m_edit);
  741. DDX_Control(pDX, IDOK, m_button_OK);
  742. DDX_Text(pDX, IDC_BACKUP_PASSWORD, m_password);
  743. //}}AFX_DATA_MAP
  744. }
  745. BOOL
  746. CBackupPassword::OnInitDialog()
  747. {
  748. CDialog::OnInitDialog();
  749. m_button_OK.EnableWindow(FALSE);
  750. // ::SetFocus(GetDlgItem(IDC_BACKUP_PASSWORD)->m_hWnd);
  751. return FALSE;
  752. }
  753. void
  754. CBackupPassword::OnChangedPassword()
  755. {
  756. m_button_OK.EnableWindow(
  757. m_edit.GetWindowTextLength() > 0);
  758. }