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.

231 lines
5.6 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: ToolDefs.cpp
  7. //
  8. // Contents: tool-wide default settings property page
  9. //
  10. // Classes: CToolDefs
  11. //
  12. // History: 03-14-1998 stevebl Commented
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.hxx"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CToolDefs dialog
  23. CToolDefs::CToolDefs(CWnd* pParent /*=NULL*/)
  24. : CPropertyPage(CToolDefs::IDD)
  25. {
  26. //{{AFX_DATA_INIT(CToolDefs)
  27. m_szStartPath = _T("");
  28. m_iUI = -1;
  29. m_iDeployment = -1;
  30. //}}AFX_DATA_INIT
  31. }
  32. CToolDefs::~CToolDefs()
  33. {
  34. *m_ppThis = NULL;
  35. }
  36. void CToolDefs::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CToolDefs)
  40. DDX_Text(pDX, IDC_EDIT1, m_szStartPath);
  41. DDX_Radio(pDX, IDC_RADIO8, m_iUI);
  42. DDX_Radio(pDX, IDC_RADIO2, m_iDeployment);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CToolDefs, CDialog)
  46. //{{AFX_MSG_MAP(CToolDefs)
  47. ON_BN_CLICKED(IDC_BUTTON1, OnBrowse)
  48. ON_BN_CLICKED(IDC_RADIO1, OnChanged)
  49. ON_BN_CLICKED(IDC_RADIO2, OnChanged)
  50. ON_BN_CLICKED(IDC_RADIO4, OnChanged)
  51. ON_BN_CLICKED(IDC_RADIO5, OnChanged)
  52. ON_BN_CLICKED(IDC_RADIO6, OnChanged)
  53. ON_BN_CLICKED(IDC_RADIO8, OnChanged)
  54. ON_BN_CLICKED(IDC_RADIO7, OnChanged)
  55. ON_EN_CHANGE(IDC_EDIT1, OnChanged)
  56. ON_WM_CONTEXTMENU()
  57. //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CToolDefs message handlers
  61. BOOL CToolDefs::OnInitDialog()
  62. {
  63. GetDlgItem(IDC_RADIO4)->EnableWindow(FALSE==m_fMachine);
  64. m_szStartPath = m_pToolDefaults->szStartPath;
  65. if (m_pToolDefaults->fUseWizard)
  66. {
  67. m_iDeployment = 0;
  68. }
  69. else
  70. {
  71. if (m_pToolDefaults->fCustomDeployment)
  72. {
  73. m_iDeployment = 3;
  74. }
  75. else
  76. {
  77. switch (m_pToolDefaults->NPBehavior)
  78. {
  79. default:
  80. case NP_PUBLISHED:
  81. m_iDeployment = 1;
  82. if (m_fMachine)
  83. {
  84. m_iDeployment = 0;
  85. }
  86. break;
  87. case NP_ASSIGNED:
  88. m_iDeployment = 2;
  89. break;
  90. case NP_DISABLED:
  91. m_iDeployment = 4;
  92. break;
  93. }
  94. }
  95. }
  96. switch (m_pToolDefaults->UILevel)
  97. {
  98. case INSTALLUILEVEL_FULL:
  99. m_iUI = 1;
  100. break;
  101. case INSTALLUILEVEL_BASIC:
  102. default:
  103. m_iUI = 0;
  104. break;
  105. }
  106. CPropertyPage::OnInitDialog();
  107. return TRUE; // return TRUE unless you set the focus to a control
  108. // EXCEPTION: OCX Property Pages should return FALSE
  109. }
  110. #include <shlobj.h>
  111. void CToolDefs::OnBrowse()
  112. {
  113. IMalloc * pmalloc;
  114. if (SUCCEEDED(SHGetMalloc(&pmalloc)))
  115. {
  116. LPITEMIDLIST pidlNetwork;
  117. if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_NETWORK, &pidlNetwork)))
  118. {
  119. BROWSEINFO bi;
  120. memset(&bi, 0, sizeof(bi));
  121. OLECHAR szDisplayName[MAX_PATH];
  122. bi.pszDisplayName = szDisplayName;
  123. CString sz;
  124. sz.LoadString(IDS_BROWSEFOLDERS);
  125. bi.lpszTitle = sz;
  126. bi.pidlRoot = pidlNetwork;
  127. bi.ulFlags = BIF_RETURNONLYFSDIRS;
  128. LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
  129. if (NULL != pidl)
  130. {
  131. OLECHAR szPath[MAX_PATH];
  132. if (SHGetPathFromIDList(pidl, szPath))
  133. {
  134. m_szStartPath = szPath;
  135. UpdateData(FALSE);
  136. SetModified();
  137. }
  138. pmalloc->Free(pidl);
  139. }
  140. }
  141. pmalloc->Release();
  142. }
  143. }
  144. BOOL CToolDefs::OnApply()
  145. {
  146. m_pToolDefaults->fUseWizard = FALSE;
  147. m_pToolDefaults->fCustomDeployment = FALSE;
  148. m_pToolDefaults->szStartPath = m_szStartPath;
  149. switch (m_iDeployment)
  150. {
  151. default:
  152. case 0: // display dialog
  153. m_pToolDefaults->fUseWizard = TRUE;
  154. m_pToolDefaults->NPBehavior = NP_PUBLISHED;
  155. break;
  156. case 1: // published
  157. m_pToolDefaults->NPBehavior = NP_PUBLISHED;
  158. break;
  159. case 2: // assigned
  160. m_pToolDefaults->NPBehavior = NP_ASSIGNED;
  161. break;
  162. case 3: // configure
  163. m_pToolDefaults->NPBehavior = NP_PUBLISHED;
  164. m_pToolDefaults->fCustomDeployment = TRUE;
  165. break;
  166. case 4: // disabled
  167. m_pToolDefaults->NPBehavior = NP_DISABLED;
  168. break;
  169. }
  170. switch (m_iUI)
  171. {
  172. case 1:
  173. m_pToolDefaults->UILevel = INSTALLUILEVEL_FULL;
  174. break;
  175. case 0:
  176. default:
  177. m_pToolDefaults->UILevel = INSTALLUILEVEL_BASIC;
  178. }
  179. MMCPropertyChangeNotify(m_hConsoleHandle, m_cookie);
  180. return CPropertyPage::OnApply();
  181. }
  182. void CToolDefs::OnChanged()
  183. {
  184. SetModified();
  185. }
  186. LRESULT CToolDefs::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  187. {
  188. switch (message)
  189. {
  190. case WM_HELP:
  191. StandardHelp((HWND)((LPHELPINFO) lParam)->hItemHandle, IDD);
  192. return 0;
  193. case WM_USER_REFRESH:
  194. // UNDONE
  195. return 0;
  196. case WM_USER_CLOSE:
  197. return GetOwner()->SendMessage(WM_CLOSE);
  198. default:
  199. return CPropertyPage::WindowProc(message, wParam, lParam);
  200. }
  201. }
  202. void CToolDefs::OnContextMenu(CWnd* pWnd, CPoint point)
  203. {
  204. StandardContextMenu(pWnd->m_hWnd, IDD_TOOL_DEFAULTS);
  205. }