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.

177 lines
4.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. dlgprof.cpp
  7. Implementation of CDlgNewProfile, dialog to create a new profile
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "resource.h"
  12. #include "rasdial.h"
  13. #include "helper.h"
  14. #include "DlgProf.h"
  15. #include "profsht.h"
  16. #include "hlptable.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CDlgNewProfile dialog
  24. #ifdef __OLD_OLD_CODE
  25. CDlgNewProfile::CDlgNewProfile(CWnd* pParent, CStrArray& NameList)
  26. : CDialog(CDlgNewProfile::IDD, pParent), m_NameList(NameList)
  27. {
  28. //{{AFX_DATA_INIT(CDlgNewProfile)
  29. m_sBaseProfile = _T("");
  30. m_sProfileName = _T("");
  31. //}}AFX_DATA_INIT
  32. m_pBox = NULL;
  33. }
  34. CDlgNewProfile::~CDlgNewProfile()
  35. {
  36. delete m_pBox;
  37. }
  38. void CDlgNewProfile::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CDlgNewProfile)
  42. DDX_CBString(pDX, IDC_COMBOBASEPROFILE, m_sBaseProfile);
  43. DDX_Text(pDX, IDC_EDITPROFILENAME, m_sProfileName);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CDlgNewProfile, CDialog)
  47. //{{AFX_MSG_MAP(CDlgNewProfile)
  48. ON_BN_CLICKED(IDC_BUTTONEDIT, OnButtonEdit)
  49. ON_EN_CHANGE(IDC_EDITPROFILENAME, OnChangeEditprofilename)
  50. ON_WM_HELPINFO()
  51. ON_WM_CONTEXTMENU()
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDlgNewProfile message handlers
  56. void CDlgNewProfile::OnButtonEdit()
  57. {
  58. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  59. USES_CONVERSION;
  60. UpdateData(TRUE);
  61. // load the profile using based profile, if not loaded
  62. if(!m_Profile.IsCurrent((LPCTSTR)m_sBaseProfile))
  63. {
  64. m_Profile.Load(T2W((LPTSTR)(LPCTSTR)m_sBaseProfile));
  65. }
  66. if(m_Profile.IsValid())
  67. {
  68. // not to save on OK / apply -- pass in false as second parameter
  69. CProfileSheet sh(m_Profile, false, IDS_EDITDIALINPROFILE);
  70. sh.DoModal();
  71. if(sh.IsApplied())
  72. {
  73. // disable the based on profile combo box
  74. GetDlgItem(IDC_COMBOBASEPROFILE)->EnableWindow(FALSE);
  75. }
  76. }
  77. }
  78. void CDlgNewProfile::OnOK()
  79. {
  80. USES_CONVERSION;
  81. CDialog::OnOK();
  82. // load the profile using base profile, if not loaded
  83. if (!m_Profile.IsValid())
  84. m_Profile.Load(T2W((LPTSTR)(LPCTSTR)m_sBaseProfile));
  85. // save the profile
  86. if(m_Profile.IsValid())
  87. m_Profile.Save(T2W((LPTSTR)(LPCTSTR)m_sProfileName));
  88. }
  89. BOOL CDlgNewProfile::OnInitDialog()
  90. {
  91. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  92. CDialog::OnInitDialog();
  93. try{
  94. m_pBox = new CStrBox<CComboBox>(this, IDC_COMBOBASEPROFILE, m_NameList);
  95. }catch(CMemoryException&)
  96. {
  97. delete m_pBox; m_pBox = NULL;
  98. throw;
  99. }
  100. if(m_pBox)
  101. {
  102. m_pBox->Fill();
  103. m_pBox->Select(0);
  104. }
  105. GetDlgItem(IDOK)->EnableWindow(FALSE);
  106. GetDlgItem(IDC_BUTTONEDIT)->EnableWindow(FALSE);
  107. return TRUE; // return TRUE unless you set the focus to a control
  108. // EXCEPTION: OCX Property Pages should return FALSE
  109. }
  110. void CDlgNewProfile::OnChangeEditprofilename()
  111. {
  112. // TODO: If this is a RICHEDIT control, the control will not
  113. // send this notification unless you override the CDialog::OnInitDialog()
  114. // function to send the EM_SETEVENTMASK message to the control
  115. // with the ENM_CHANGE flag ORed into the lParam mask.
  116. // TODO: Add your control notification handler code here
  117. CEdit *pEdit = (CEdit*)GetDlgItem(IDC_EDITPROFILENAME);
  118. CString str;
  119. pEdit->GetWindowText(str);
  120. BOOL bEnable = (str.GetLength() && (m_NameList.Find(str) == -1));
  121. GetDlgItem(IDOK)->EnableWindow(bEnable);
  122. GetDlgItem(IDC_BUTTONEDIT)->EnableWindow(bEnable);
  123. }
  124. BOOL CDlgNewProfile::OnHelpInfo(HELPINFO* pHelpInfo)
  125. {
  126. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  127. AfxGetApp()->m_pszHelpFilePath,
  128. HELP_WM_HELP,
  129. (DWORD_PTR)(LPVOID)IDD_NEWDIALINPROFILE_HelpTable);
  130. return CDialog::OnHelpInfo(pHelpInfo);
  131. }
  132. void CDlgNewProfile::OnContextMenu(CWnd* pWnd, CPoint point)
  133. {
  134. ::WinHelp (pWnd->m_hWnd, AfxGetApp()->m_pszHelpFilePath,
  135. HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID)IDD_NEWDIALINPROFILE_HelpTable);
  136. }
  137. #endif __OLD_OLD_CODE