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.

1046 lines
18 KiB

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