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.

1104 lines
18 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. docum.cpp
  5. Abstract:
  6. WWW Documents Page
  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 "w3scfg.h"
  18. #include "docum.h"
  19. #include <lmcons.h>
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. //
  26. // CAddDefDocDlg dialog
  27. //
  28. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  29. CAddDefDocDlg::CAddDefDocDlg(
  30. IN CWnd * pParent OPTIONAL
  31. )
  32. /*++
  33. Routine Description:
  34. Add default document dialog constructor
  35. Arguments:
  36. None
  37. Return Value:
  38. N/A
  39. --*/
  40. : CDialog(CAddDefDocDlg::IDD, pParent)
  41. {
  42. //{{AFX_DATA_INIT(CAddDefDocDlg)
  43. m_strDefDocument = _T("");
  44. //}}AFX_DATA_INIT
  45. }
  46. void
  47. CAddDefDocDlg::DoDataExchange(
  48. IN CDataExchange * pDX
  49. )
  50. /*++
  51. Routine Description:
  52. Initialise/Store control data
  53. Arguments:
  54. CDataExchange * pDX - DDX/DDV control structure
  55. Return Value:
  56. None
  57. --*/
  58. {
  59. CDialog::DoDataExchange(pDX);
  60. //{{AFX_DATA_MAP(CAddDefDocDlg)
  61. DDX_Control(pDX, IDOK, m_button_Ok);
  62. DDX_Control(pDX, IDC_EDIT_DEF_DOCUMENT, m_edit_DefDocument);
  63. DDX_Text(pDX, IDC_EDIT_DEF_DOCUMENT, m_strDefDocument);
  64. DDV_MaxChars(pDX, m_strDefDocument, MAX_PATH);
  65. //}}AFX_DATA_MAP
  66. if (pDX->m_bSaveAndValidate)
  67. {
  68. if (m_strDefDocument.Find(_T(':')) != -1
  69. || m_strDefDocument.Find(_T('\\')) != -1)
  70. {
  71. ::AfxMessageBox(IDS_ERR_NO_COMPLETE_PATH);
  72. pDX->Fail();
  73. }
  74. }
  75. }
  76. //
  77. // Message Map
  78. //
  79. BEGIN_MESSAGE_MAP(CAddDefDocDlg, CDialog)
  80. //{{AFX_MSG_MAP(CAddDefDocDlg)
  81. ON_EN_CHANGE(IDC_EDIT_DEF_DOCUMENT, OnChangeEditDefDocument)
  82. //}}AFX_MSG_MAP
  83. END_MESSAGE_MAP()
  84. //
  85. // Message Handlers
  86. //
  87. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  88. void
  89. CAddDefDocDlg::OnChangeEditDefDocument()
  90. /*++
  91. Routine Description:
  92. Respond to a change in the default document edit box
  93. Arguments:
  94. None./
  95. --*/
  96. {
  97. m_button_Ok.EnableWindow(m_edit_DefDocument.GetWindowTextLength() > 0);
  98. }
  99. //
  100. // WWW Documents Property Page
  101. //
  102. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  103. IMPLEMENT_DYNCREATE(CW3DocumentsPage, CInetPropertyPage)
  104. //
  105. // Static Initialization
  106. //
  107. const LPCTSTR CW3DocumentsPage::s_lpstrSep = _T(",");
  108. const LPCTSTR CW3DocumentsPage::s_lpstrFILE = _T("FILE:");
  109. const LPCTSTR CW3DocumentsPage::s_lpstrSTRING = _T("STRING:");
  110. const LPCTSTR CW3DocumentsPage::s_lpstrURL = _T("URL:");
  111. CW3DocumentsPage::CW3DocumentsPage(
  112. IN CInetPropertySheet * pSheet
  113. )
  114. /*++
  115. Routine Description:
  116. Documents page constructor
  117. Arguments:
  118. CInetPropertySheet * pSheet : Sheet object
  119. BOOL fLocal : TRUE if admining the local server
  120. Return Value:
  121. N/A
  122. --*/
  123. : CInetPropertyPage(CW3DocumentsPage::IDD, pSheet),
  124. m_dwBitRangeDirBrowsing(MD_DIRBROW_LOADDEFAULT)
  125. {
  126. #if 0 // Keep Class-wizard happy
  127. //{{AFX_DATA_INIT(CW3DocumentsPage)
  128. m_strFooter = _T("");
  129. m_fEnableDefaultDocument = FALSE;
  130. m_fEnableFooter = FALSE;
  131. //}}AFX_DATA_INIT
  132. #endif // 0
  133. }
  134. CW3DocumentsPage::~CW3DocumentsPage()
  135. /*++
  136. Routine Description:
  137. Destructor
  138. Arguments:
  139. N/A
  140. Return Value:
  141. N/A
  142. --*/
  143. {
  144. }
  145. void
  146. CW3DocumentsPage::MakeFooterCommand(
  147. IN OUT CString & strFooter
  148. )
  149. /*++
  150. Routine Description:
  151. Convert the footer document to a full footer string.
  152. Arguments:
  153. CString & strFooter : On input this is the footer document,
  154. at output this will be a full footer command
  155. Return Value:
  156. None.
  157. Notes:
  158. Only support FILE: for now
  159. --*/
  160. {
  161. strFooter.TrimLeft();
  162. strFooter.TrimRight();
  163. ASSERT(::IsFullyQualifiedPath(strFooter));
  164. strFooter = s_lpstrFILE + strFooter;
  165. }
  166. void
  167. CW3DocumentsPage::ParseFooterCommand(
  168. IN OUT CString & strFooter
  169. )
  170. /*++
  171. Routine Description:
  172. Trim the command from the rest of this command
  173. Arguments:
  174. CString & strFooter : On input this is a footer command
  175. at output this will be just the footer document
  176. Return Value:
  177. None.
  178. --*/
  179. {
  180. LPCTSTR lp = strFooter.GetBuffer(0);
  181. if (!_tcsnccmp(lp, s_lpstrFILE, 5))
  182. {
  183. lp += lstrlen(s_lpstrFILE);
  184. }
  185. else if (!_tcsnccmp(lp, s_lpstrSTRING, 7))
  186. {
  187. lp += lstrlen(s_lpstrSTRING);
  188. }
  189. else if (!::_tcsnccmp(lp, s_lpstrURL, 4))
  190. {
  191. lp += lstrlen(s_lpstrURL);
  192. }
  193. if (lp != strFooter.GetBuffer(0))
  194. {
  195. strFooter = lp;
  196. }
  197. strFooter.TrimLeft();
  198. }
  199. void
  200. CW3DocumentsPage::StringToListBox()
  201. /*++
  202. Routine Description:
  203. Parse the default document string, and add each doc
  204. to the listbox
  205. Arguments:
  206. None
  207. Return Value:
  208. None
  209. --*/
  210. {
  211. CString strSrc(m_strDefaultDocument);
  212. LPTSTR lp = strSrc.GetBuffer(0);
  213. lp = StringTok(lp, s_lpstrSep);
  214. while (lp)
  215. {
  216. CString str(lp);
  217. str.TrimLeft();
  218. str.TrimRight();
  219. m_list_DefDocuments.AddString(str);
  220. lp = StringTok(NULL, s_lpstrSep);
  221. }
  222. }
  223. BOOL
  224. CW3DocumentsPage::StringFromListBox()
  225. /*++
  226. Routine Description:
  227. Build up list of default documents from the contents of
  228. the listbox.
  229. Arguments:
  230. None
  231. Return Value:
  232. TRUE if at least one document was added.
  233. --*/
  234. {
  235. m_strDefaultDocument.Empty();
  236. int i;
  237. for (i = 0; i < m_list_DefDocuments.GetCount(); ++i)
  238. {
  239. CString str;
  240. m_list_DefDocuments.GetText(i, str);
  241. if (i)
  242. {
  243. m_strDefaultDocument += s_lpstrSep;
  244. }
  245. m_strDefaultDocument += str;
  246. }
  247. return i > 0;
  248. }
  249. void
  250. CW3DocumentsPage::DoDataExchange(
  251. IN CDataExchange * pDX
  252. )
  253. /*++
  254. Routine Description:
  255. Initialise/Store control data
  256. Arguments:
  257. CDataExchange * pDX - DDX/DDV control structure
  258. Return Value:
  259. None
  260. --*/
  261. {
  262. CInetPropertyPage::DoDataExchange(pDX);
  263. //{{AFX_DATA_MAP(CW3DocumentsPage)
  264. DDX_Check(pDX, IDC_CHECK_ENABLE_DEFAULT_DOCUMENT, m_fEnableDefaultDocument);
  265. DDX_Check(pDX, IDC_CHECK_ENABLE_DOCUMENT_FOOTER, m_fEnableFooter);
  266. DDX_Control(pDX, IDC_LIST_DEFAULT_DOCUMENT, m_list_DefDocuments);
  267. DDX_Control(pDX, IDC_EDIT_DOCUMENT_FOOTER, m_edit_Footer);
  268. DDX_Control(pDX, IDC_CHECK_ENABLE_DOCUMENT_FOOTER, m_check_EnableFooter);
  269. DDX_Control(pDX, IDC_BUTTON_ADD, m_button_Add);
  270. DDX_Control(pDX, IDC_BUTTON_REMOVE, m_button_Remove);
  271. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  272. DDX_Control(pDX, IDC_BUTTON_UP, m_button_Up);
  273. DDX_Control(pDX, IDC_BUTTON_DOWN, m_button_Down);
  274. //}}AFX_DATA_MAP
  275. if (pDX->m_bSaveAndValidate)
  276. {
  277. if (m_fEnableDefaultDocument)
  278. {
  279. if (!StringFromListBox())
  280. {
  281. ::AfxMessageBox(IDS_ERR_DOCUMENTS);
  282. pDX->Fail();
  283. }
  284. }
  285. if (m_fEnableFooter)
  286. {
  287. BeginWaitCursor();
  288. DDX_Text(pDX, IDC_EDIT_DOCUMENT_FOOTER, m_strFooter);
  289. DDV_MinMaxChars(pDX, m_strFooter, 1, MAX_PATH);
  290. if (!IsFullyQualifiedPath(m_strFooter))
  291. {
  292. //
  293. // Footer doc must be a complete path
  294. //
  295. ::AfxMessageBox(IDS_ERR_COMPLETE_PATH);
  296. pDX->Fail();
  297. }
  298. else if (IsLocal() && IsNetworkPath(m_strFooter))
  299. {
  300. //
  301. // Footer doc must be on local machine.
  302. //
  303. ::AfxMessageBox(IDS_NOT_LOCAL_FOOTER);
  304. pDX->Fail();
  305. }
  306. else if (IsLocal() &&
  307. (::GetFileAttributes(m_strFooter) & FILE_ATTRIBUTE_DIRECTORY))
  308. {
  309. //
  310. // And lastly, but not leastly, the footer document should exist
  311. //
  312. ::AfxMessageBox(IDS_ERR_FILE_NOT_FOUND);
  313. pDX->Fail();
  314. }
  315. else
  316. {
  317. MakeFooterCommand(m_strFooter);
  318. }
  319. EndWaitCursor();
  320. }
  321. else
  322. {
  323. m_strFooter.Empty();
  324. }
  325. }
  326. else
  327. {
  328. ParseFooterCommand(m_strFooter);
  329. DDX_Text(pDX, IDC_EDIT_DOCUMENT_FOOTER, m_strFooter);
  330. DDV_MinMaxChars(pDX, m_strFooter, 1, MAX_PATH);
  331. }
  332. }
  333. //
  334. // Message Map
  335. //
  336. BEGIN_MESSAGE_MAP(CW3DocumentsPage, CInetPropertyPage)
  337. //{{AFX_MSG_MAP(CW3DocumentsPage)
  338. ON_BN_CLICKED(IDC_CHECK_ENABLE_DEFAULT_DOCUMENT, OnCheckEnableDefaultDocument)
  339. ON_BN_CLICKED(IDC_CHECK_ENABLE_DOCUMENT_FOOTER, OnCheckEnableDocumentFooter)
  340. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  341. ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  342. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  343. ON_BN_CLICKED(IDC_BUTTON_UP, OnButtonUp)
  344. ON_BN_CLICKED(IDC_BUTTON_DOWN, OnButtonDown)
  345. ON_LBN_SELCHANGE(IDC_LIST_DEFAULT_DOCUMENT, OnSelchangeListDefaultDocument)
  346. //}}AFX_MSG_MAP
  347. ON_EN_CHANGE(IDC_EDIT_DEFAULT_DOCUMENT, OnItemChanged)
  348. ON_EN_CHANGE(IDC_EDIT_DOCUMENT_FOOTER, OnItemChanged)
  349. END_MESSAGE_MAP()
  350. void
  351. CW3DocumentsPage::SetUpDownStates()
  352. /*++
  353. Routine Description:
  354. Set up and down button enable status
  355. Arguments:
  356. None
  357. Return Value:
  358. None
  359. --*/
  360. {
  361. int nLast = m_list_DefDocuments.GetCount() - 1;
  362. int nSel = m_list_DefDocuments.GetCurSel();
  363. m_button_Up.EnableWindow(nSel > 0);
  364. m_button_Down.EnableWindow(nSel >= 0 && nSel < nLast);
  365. }
  366. BOOL
  367. CW3DocumentsPage::SetRemoveState()
  368. /*++
  369. Routine Description:
  370. Set the enabled state of the remove button state depending
  371. on the state of the selection in the def doc listbox
  372. Arguments:
  373. None
  374. Return Value:
  375. TRUE if the remove button is enabled, FALSE otherwise
  376. --*/
  377. {
  378. BOOL fEnabled = m_fEnableDefaultDocument
  379. && (m_list_DefDocuments.GetCurSel() != LB_ERR);
  380. m_button_Remove.EnableWindow(fEnabled);
  381. return fEnabled;
  382. }
  383. BOOL
  384. CW3DocumentsPage::SetDefDocumentState(
  385. IN BOOL fEnabled
  386. )
  387. /*++
  388. Routine Description:
  389. Set the enabled states of the Default Documents state
  390. Arguments:
  391. BOOL fEnabled : TRUE if default document is on
  392. Return Value:
  393. TRUE if default document is on
  394. --*/
  395. {
  396. m_button_Add.EnableWindow(fEnabled);
  397. m_button_Up.EnableWindow(fEnabled);
  398. m_button_Down.EnableWindow(fEnabled);
  399. m_list_DefDocuments.EnableWindow(fEnabled);
  400. SetRemoveState();
  401. return fEnabled;
  402. }
  403. BOOL
  404. CW3DocumentsPage::SetDocFooterState(
  405. IN BOOL fEnabled
  406. )
  407. /*++
  408. Routine Description:
  409. Set the enabled state of the footer documents
  410. Arguments:
  411. BOOL fEnabled : TRUE if footers are on
  412. Return Value:
  413. TRUE if footers are on
  414. --*/
  415. {
  416. m_edit_Footer.EnableWindow(fEnabled);
  417. m_button_Browse.EnableWindow(IsLocal() && fEnabled);
  418. return fEnabled;
  419. }
  420. //
  421. // Message Handlers
  422. //
  423. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  424. void
  425. CW3DocumentsPage::OnItemChanged()
  426. /*++
  427. Routine Description:
  428. Handle change in the value of the control data
  429. Arguments:
  430. None
  431. Return Value:
  432. None
  433. --*/
  434. {
  435. SetModified(TRUE);
  436. }
  437. void
  438. CW3DocumentsPage::OnCheckEnableDefaultDocument()
  439. /*++
  440. Routine Description:
  441. Handle 'enable default document' checkbox toggle
  442. Arguments:
  443. None
  444. Return Value:
  445. None
  446. --*/
  447. {
  448. m_fEnableDefaultDocument = !m_fEnableDefaultDocument;
  449. SetDefDocumentState(m_fEnableDefaultDocument);
  450. OnItemChanged();
  451. }
  452. void
  453. CW3DocumentsPage::OnCheckEnableDocumentFooter()
  454. /*++
  455. Routine Description:
  456. Handle 'enable document footer' checkbox toggle
  457. Arguments:
  458. None
  459. Return Value:
  460. None
  461. --*/
  462. {
  463. m_fEnableFooter = !m_fEnableFooter;
  464. if (SetDocFooterState(m_fEnableFooter))
  465. {
  466. m_edit_Footer.SetSel(0,-1);
  467. m_edit_Footer.SetFocus();
  468. }
  469. OnItemChanged();
  470. }
  471. BOOL
  472. CW3DocumentsPage::OnInitDialog()
  473. /*++
  474. Routine Description:
  475. WM_INITDIALOG handler. Initialize the dialog.
  476. Arguments:
  477. None.
  478. Return Value:
  479. TRUE if no focus is to be set automatically, FALSE if the focus
  480. is already set.
  481. --*/
  482. {
  483. CInetPropertyPage::OnInitDialog();
  484. //
  485. // Make sure the up/down buttons show up correctly
  486. //
  487. m_button_Up.SizeToContent();
  488. m_button_Down.SizeToContent();
  489. StringToListBox();
  490. SetDefDocumentState(m_fEnableDefaultDocument);
  491. SetDocFooterState(m_fEnableFooter);
  492. SetUpDownStates();
  493. SetRemoveState();
  494. return TRUE;
  495. }
  496. /* virtual */
  497. HRESULT
  498. CW3DocumentsPage::FetchLoadedValues()
  499. /*++
  500. Routine Description:
  501. Move configuration data from sheet to dialog controls
  502. Arguments:
  503. None
  504. Return Value:
  505. HRESULT
  506. --*/
  507. {
  508. CError err;
  509. BEGIN_META_DIR_READ(CW3Sheet)
  510. FETCH_DIR_DATA_FROM_SHEET(m_dwDirBrowsing);
  511. FETCH_DIR_DATA_FROM_SHEET(m_strDefaultDocument);
  512. FETCH_DIR_DATA_FROM_SHEET(m_fEnableFooter);
  513. FETCH_DIR_DATA_FROM_SHEET(m_strFooter);
  514. m_fEnableDefaultDocument = IS_FLAG_SET(
  515. m_dwDirBrowsing,
  516. MD_DIRBROW_LOADDEFAULT
  517. );
  518. END_META_DIR_READ(err)
  519. return err;
  520. }
  521. HRESULT
  522. CW3DocumentsPage::SaveInfo()
  523. /*++
  524. Routine Description:
  525. Save the information on this property page
  526. Arguments:
  527. None
  528. Return Value:
  529. Error return code
  530. --*/
  531. {
  532. ASSERT(IsDirty());
  533. TRACEEOLID("Saving W3 documents page now...");
  534. CError err;
  535. SET_FLAG_IF(m_fEnableDefaultDocument, m_dwDirBrowsing, MD_DIRBROW_LOADDEFAULT);
  536. BeginWaitCursor();
  537. BEGIN_META_DIR_WRITE(CW3Sheet)
  538. INIT_DIR_DATA_MASK(m_dwDirBrowsing, m_dwBitRangeDirBrowsing)
  539. STORE_DIR_DATA_ON_SHEET(m_strDefaultDocument)
  540. //STORE_DIR_DATA_ON_SHEET_MASK(m_dwDirBrowsing, m_dwBitRangeDirBrowsing)
  541. STORE_DIR_DATA_ON_SHEET(m_dwDirBrowsing)
  542. STORE_DIR_DATA_ON_SHEET(m_fEnableFooter)
  543. STORE_DIR_DATA_ON_SHEET(m_strFooter)
  544. END_META_DIR_WRITE(err)
  545. EndWaitCursor();
  546. return err;
  547. }
  548. int
  549. CW3DocumentsPage::DocExistsInList(
  550. IN LPCTSTR lpDoc
  551. )
  552. /*++
  553. Routine Description:
  554. Check to see if the given document exists in the list
  555. Arguments:
  556. LPCTSTR lpDoc : Document to check
  557. Return Value:
  558. The index where the item exists or LB_ERR if it doesn't exist.
  559. --*/
  560. {
  561. CString str;
  562. for (int n = 0; n < m_list_DefDocuments.GetCount(); ++n)
  563. {
  564. m_list_DefDocuments.GetText(n, str);
  565. if (!str.CompareNoCase(lpDoc))
  566. {
  567. return n;
  568. }
  569. }
  570. return LB_ERR;
  571. }
  572. void
  573. CW3DocumentsPage::OnButtonAdd()
  574. /*++
  575. Routine Description:
  576. Add new default document to the list
  577. Arguments:
  578. None
  579. Return Value:
  580. None
  581. --*/
  582. {
  583. CAddDefDocDlg dlg;
  584. if (dlg.DoModal() == IDOK)
  585. {
  586. //
  587. // Check to see if it existed already
  588. //
  589. try
  590. {
  591. int nSel;
  592. CString strNewDoc(dlg.GetDefDocument());
  593. if ((nSel = DocExistsInList(strNewDoc)) != LB_ERR)
  594. {
  595. m_list_DefDocuments.SetCurSel(nSel);
  596. ::AfxMessageBox(IDS_DUPLICATE_DOC);
  597. return;
  598. }
  599. nSel = m_list_DefDocuments.AddString(strNewDoc);
  600. if (nSel >= 0)
  601. {
  602. m_list_DefDocuments.SetCurSel(nSel);
  603. SetUpDownStates();
  604. SetRemoveState();
  605. OnItemChanged();
  606. }
  607. }
  608. catch(CMemoryException * e)
  609. {
  610. e->ReportError();
  611. e->Delete();
  612. }
  613. }
  614. }
  615. void
  616. CW3DocumentsPage::OnButtonRemove()
  617. /*++
  618. Routine Description:
  619. Remove currently selected def document in the list
  620. Arguments:
  621. None
  622. Return Value:
  623. None
  624. --*/
  625. {
  626. int nSel = m_list_DefDocuments.GetCurSel();
  627. if (nSel >= 0)
  628. {
  629. m_list_DefDocuments.DeleteString(nSel);
  630. if (nSel >= m_list_DefDocuments.GetCount())
  631. {
  632. --nSel;
  633. }
  634. m_list_DefDocuments.SetCurSel(nSel);
  635. SetUpDownStates();
  636. OnItemChanged();
  637. if (!SetRemoveState())
  638. {
  639. //
  640. // Make sure we don't focus on a disabled button
  641. //
  642. m_button_Add.SetFocus();
  643. }
  644. }
  645. }
  646. void
  647. CW3DocumentsPage::OnButtonBrowse()
  648. /*++
  649. Routine Description:
  650. Browse for an html footer document
  651. Arguments:
  652. None.
  653. Return Value:
  654. None.
  655. --*/
  656. {
  657. ASSERT(IsLocal());
  658. //
  659. // Pop up the file dialog and let the user select the footer htm file.
  660. //
  661. CString str;
  662. str.LoadString(IDS_HTML_MASK);
  663. CFileDialog dlgBrowse(TRUE, NULL, NULL, OFN_HIDEREADONLY, str, this);
  664. //
  665. // If the new style of file-open dialog is requested, comment
  666. // out the DoModal, and remove the other two comments.
  667. //
  668. //dlgBrowse.m_ofn.Flags &= ~(OFN_ENABLEHOOK);
  669. if (dlgBrowse.DoModal() == IDOK)
  670. //if (GetOpenFileName(&dlgBrowse.m_ofn))
  671. {
  672. m_edit_Footer.SetWindowText(dlgBrowse.GetPathName());
  673. }
  674. }
  675. void
  676. CW3DocumentsPage::ExchangeDocuments(
  677. IN int nLow,
  678. IN int nHigh
  679. )
  680. /*++
  681. Routine Description:
  682. Exchange two documents in the listbox
  683. Arguments:
  684. int nLow : Low item
  685. int nHigh : High item
  686. Return Value:
  687. None.
  688. --*/
  689. {
  690. ASSERT(nLow < nHigh);
  691. CString str;
  692. m_list_DefDocuments.GetText(nLow, str);
  693. m_list_DefDocuments.DeleteString(nLow);
  694. m_list_DefDocuments.InsertString(nHigh, str);
  695. OnItemChanged();
  696. }
  697. void
  698. CW3DocumentsPage::OnButtonUp()
  699. /*++
  700. Routine Description:
  701. Move the currently selected doc up
  702. Arguments:
  703. None.
  704. Return Value:
  705. None.
  706. --*/
  707. {
  708. int nCurSel = m_list_DefDocuments.GetCurSel();
  709. ExchangeDocuments(nCurSel - 1, nCurSel);
  710. m_list_DefDocuments.SetCurSel(nCurSel - 1);
  711. m_list_DefDocuments.SetFocus();
  712. SetUpDownStates();
  713. }
  714. void
  715. CW3DocumentsPage::OnButtonDown()
  716. /*++
  717. Routine Description:
  718. Move the currently selected doc down
  719. Arguments:
  720. None.
  721. Return Value:
  722. None.
  723. --*/
  724. {
  725. int nCurSel = m_list_DefDocuments.GetCurSel();
  726. ExchangeDocuments(nCurSel, nCurSel + 1);
  727. m_list_DefDocuments.SetCurSel(nCurSel + 1);
  728. m_list_DefDocuments.SetFocus();
  729. SetUpDownStates();
  730. }
  731. void
  732. CW3DocumentsPage::OnSelchangeListDefaultDocument()
  733. /*++
  734. Routine Description:
  735. Respond to change in listbox selection
  736. Arguments:
  737. None.
  738. Return Value:
  739. None.
  740. --*/
  741. {
  742. SetUpDownStates();
  743. SetRemoveState();
  744. }