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.

289 lines
6.8 KiB

  1. // NewObject.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "viewex.h"
  5. #include "newobj.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CNewObject dialog
  13. /***********************************************************
  14. Function:
  15. Arguments:
  16. Return:
  17. Purpose:
  18. Author(s):
  19. Revision:
  20. Date:
  21. ***********************************************************/
  22. CNewObject::CNewObject(CWnd* pParent /*=NULL*/)
  23. : CDialog(CNewObject::IDD, pParent)
  24. {
  25. //{{AFX_DATA_INIT(CNewObject)
  26. //}}AFX_DATA_INIT
  27. }
  28. /***********************************************************
  29. Function:
  30. Arguments:
  31. Return:
  32. Purpose:
  33. Author(s):
  34. Revision:
  35. Date:
  36. ***********************************************************/
  37. void CNewObject::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CNewObject)
  41. DDX_Control(pDX, IDC_USEEXTENDEDSYNTAX, m_UseExtendedSyntax);
  42. DDX_Control(pDX, IDC_OPENAS, m_OpenAs);
  43. DDX_Control(pDX, IDC_OLEDSPATH, m_OleDsPath);
  44. DDX_Control(pDX, IDC_SECUREAUTHENTICATION, m_Secure);
  45. DDX_Control(pDX, IDC_ENCRYPTION, m_Encryption);
  46. DDX_Control(pDX, IDC_USEOPEN, m_UseOpen);
  47. DDX_Control(pDX, IDC_PASSWORD, m_Password);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CNewObject, CDialog)
  51. //{{AFX_MSG_MAP(CNewObject)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CNewObject message handlers
  56. /***********************************************************
  57. Function:
  58. Arguments:
  59. Return:
  60. Purpose:
  61. Author(s):
  62. Revision:
  63. Date:
  64. ***********************************************************/
  65. void CNewObject::OnOK()
  66. {
  67. CString strVal;
  68. // TODO: Add extra validation here
  69. m_OleDsPath.GetWindowText( m_strPath );
  70. SaveLRUList( IDC_OLEDSPATH, _T("Open_ADsPath"), 100 );
  71. m_OpenAs.GetWindowText( m_strOpenAs );
  72. SaveLRUList( IDC_OPENAS, _T("Open_OpenAs"), 100 );
  73. m_Password.GetWindowText( m_strPassword );
  74. //SetLastProfileString( _T("LastPassword"), m_strPassword );
  75. //*******************
  76. m_bUseOpen = m_UseOpen.GetCheck( );
  77. strVal = m_bUseOpen ? _T("Yes") : _T("No");
  78. SetLastProfileString( _T("UseOpen"), strVal );
  79. //*******************
  80. m_bSecure = m_Secure.GetCheck( );
  81. strVal = m_bSecure ? _T("Yes") : _T("No");
  82. SetLastProfileString( _T("Secure"), strVal );
  83. //*******************
  84. m_bEncryption = m_Encryption.GetCheck( );
  85. strVal = m_bEncryption ? _T("Yes") : _T("No");
  86. SetLastProfileString( _T("Encryption"), strVal );
  87. //*******************
  88. m_bUseExtendedSyntax = m_UseExtendedSyntax.GetCheck( );
  89. strVal = m_bUseExtendedSyntax ? _T("Yes") : _T("No");
  90. SetLastProfileString( _T("UseExtendedSyntax"), strVal );
  91. CDialog::OnOK();
  92. }
  93. /***********************************************************
  94. Function:
  95. Arguments:
  96. Return:
  97. Purpose:
  98. Author(s):
  99. Revision:
  100. Date:
  101. ***********************************************************/
  102. CString& CNewObject::GetObjectPath()
  103. {
  104. return m_strPath;
  105. }
  106. /***********************************************************
  107. Function:
  108. Arguments:
  109. Return:
  110. Purpose:
  111. Author(s):
  112. Revision:
  113. Date:
  114. ***********************************************************/
  115. void CNewObject::SaveLRUList( int idCBox, TCHAR* pszSection, int nMax )
  116. {
  117. CComboBox* pCombo;
  118. TCHAR szEntry[ MAX_PATH ];
  119. TCHAR szIndex[ 8 ];
  120. CString strText, strItem;
  121. int nVal, nIdx, nItems;
  122. pCombo = (CComboBox*)GetDlgItem( idCBox );
  123. pCombo->GetWindowText( strText );
  124. _tcscpy( szEntry, _T("Value_1") );
  125. if( strText.GetLength( ) )
  126. {
  127. WritePrivateProfileString( pszSection, szEntry, (LPCTSTR)strText, ADSVW_INI_FILE );
  128. }
  129. nItems = pCombo->GetCount( );
  130. nVal = 2;
  131. for( nIdx = 0; nItems != CB_ERR && nIdx < nItems && nIdx < nMax ; nIdx ++ )
  132. {
  133. pCombo->GetLBText( nIdx, strItem );
  134. if( strItem.CompareNoCase( strText ) )
  135. {
  136. _itot( nVal++, szIndex, 10 );
  137. _tcscpy( szEntry, _T("Value_") );
  138. _tcscat( szEntry, szIndex );
  139. WritePrivateProfileString( pszSection, szEntry, (LPCTSTR)strItem, ADSVW_INI_FILE );
  140. }
  141. }
  142. }
  143. /***********************************************************
  144. Function:
  145. Arguments:
  146. Return:
  147. Purpose:
  148. Author(s):
  149. Revision:
  150. Date:
  151. ***********************************************************/
  152. void CNewObject::GetLRUList( int idCBox, TCHAR* pszSection )
  153. {
  154. CComboBox* pCombo;
  155. int nIter;
  156. TCHAR szEntry[ MAX_PATH ];
  157. TCHAR szIndex[ 8 ];
  158. TCHAR szValue[ 1024 ];
  159. pCombo = (CComboBox*)GetDlgItem( idCBox );
  160. for( nIter = 0; nIter < 100 ; nIter++ )
  161. {
  162. _itot( nIter + 1, szIndex, 10 );
  163. _tcscpy( szEntry, _T("Value_") );
  164. _tcscat( szEntry, szIndex );
  165. GetPrivateProfileString( pszSection, szEntry,
  166. _T(""), szValue, 1023, ADSVW_INI_FILE );
  167. if( _tcslen( szValue ) )
  168. {
  169. pCombo->AddString( szValue );
  170. }
  171. }
  172. pCombo->SetCurSel( 0 );
  173. }
  174. /***********************************************************
  175. Function:
  176. Arguments:
  177. Return:
  178. Purpose:
  179. Author(s):
  180. Revision:
  181. Date:
  182. ***********************************************************/
  183. BOOL CNewObject::OnInitDialog()
  184. {
  185. CString strLastValue;
  186. CDialog::OnInitDialog();
  187. // TODO: Add extra initialization here
  188. //*******************
  189. GetLRUList( IDC_OLEDSPATH, _T("Open_ADsPath") );
  190. GetLRUList( IDC_OPENAS, _T("Open_OpenAs") );
  191. //*******************
  192. strLastValue = _T("");
  193. SetLastProfileString( _T("LastPassword"), strLastValue );
  194. //GetLastProfileString( _T("LastPassword"), strLastValue );
  195. if( !strLastValue.GetLength( ) )
  196. {
  197. strLastValue = _T("");
  198. }
  199. m_Password.SetWindowText( strLastValue );
  200. //*******************
  201. GetLastProfileString( _T("UseOpen"), strLastValue );
  202. if( !strLastValue.CompareNoCase( _T("No") ) )
  203. {
  204. m_UseOpen.SetCheck( 0 );
  205. }
  206. else
  207. {
  208. m_UseOpen.SetCheck( 1 );
  209. }
  210. //*******************
  211. GetLastProfileString( _T("Secure"), strLastValue );
  212. if( !strLastValue.CompareNoCase( _T("No") ) )
  213. {
  214. m_Secure.SetCheck( 0 );
  215. }
  216. else
  217. {
  218. m_Secure.SetCheck( 1 );
  219. }
  220. //*******************
  221. GetLastProfileString( _T("Encryption"), strLastValue );
  222. if( !strLastValue.CompareNoCase( _T("No") ) )
  223. {
  224. m_Encryption.SetCheck( 0 );
  225. }
  226. else
  227. {
  228. m_Encryption.SetCheck( 1 );
  229. }
  230. //*******************
  231. GetLastProfileString( _T("UseExtendedSyntax"), strLastValue );
  232. if( !strLastValue.CompareNoCase( _T("Yes") ) )
  233. {
  234. m_UseExtendedSyntax.SetCheck( 1 );
  235. }
  236. else
  237. {
  238. m_UseExtendedSyntax.SetCheck( 0 );
  239. }
  240. return FALSE; // return TRUE unless you set the focus to a control
  241. // EXCEPTION: OCX Property Pages should return FALSE
  242. }
  243.