Leaked source code of windows server 2003
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.

636 lines
18 KiB

  1. // WizClnt.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "WizClnt.h"
  5. #include "icanon.h"
  6. #include <macfile.h>
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. #define SHARE_NAME_LIMIT NNLEN
  13. #define SFM_SHARE_NAME_LIMIT AFP_VOLNAME_LEN
  14. #define SHARE_DESCRIPTION_LIMIT MAXCOMMENTSZ
  15. #define UNC_NAME_LIMIT MAX_PATH
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CWizClient0 property page
  18. IMPLEMENT_DYNCREATE(CWizClient0, CPropertyPageEx)
  19. CWizClient0::CWizClient0() : CPropertyPageEx(CWizClient0::IDD, 0, IDS_HEADERTITLE_CLIENT, IDS_HEADERSUBTITLE_CLIENT)
  20. {
  21. //{{AFX_DATA_INIT(CWizClient0)
  22. // NOTE: the ClassWizard will add member initialization here
  23. //}}AFX_DATA_INIT
  24. m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  25. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  26. m_bCSC = pApp->m_bCSC;
  27. pApp->m_bSMB = TRUE;
  28. pApp->m_bSFM = FALSE;
  29. }
  30. CWizClient0::~CWizClient0()
  31. {
  32. }
  33. void CWizClient0::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CPropertyPageEx::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CWizClient0)
  37. // NOTE: the ClassWizard will add DDX and DDV calls here
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CWizClient0, CPropertyPageEx)
  41. //{{AFX_MSG_MAP(CWizClient0)
  42. ON_EN_CHANGE(IDC_SHARENAME, OnChangeSharename)
  43. ON_BN_CLICKED(IDC_CSC_CHANGE, OnCSCChange)
  44. //}}AFX_MSG_MAP
  45. ON_MESSAGE(WM_SETPAGEFOCUS, OnSetPageFocus)
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CWizClient0 message handlers
  49. BOOL CWizClient0::OnInitDialog()
  50. {
  51. CPropertyPageEx::OnInitDialog();
  52. GetDlgItem(IDC_SHARENAME)->SendMessage(EM_LIMITTEXT, SHARE_NAME_LIMIT, 0);
  53. GetDlgItem(IDC_UNC)->SendMessage(EM_LIMITTEXT, UNC_NAME_LIMIT, 0);
  54. GetDlgItem(IDC_SHAREDESCRIPTION)->SendMessage(EM_LIMITTEXT, SHARE_DESCRIPTION_LIMIT, 0);
  55. if (!m_bCSC)
  56. {
  57. GetDlgItem(IDC_CSC_LABEL)->EnableWindow(FALSE);
  58. SetDlgItemText(IDC_CSC, _T(""));
  59. GetDlgItem(IDC_CSC)->EnableWindow(FALSE);
  60. GetDlgItem(IDC_CSC_CHANGE)->EnableWindow(FALSE);
  61. }
  62. return TRUE; // return TRUE unless you set the focus to a control
  63. // EXCEPTION: OCX Property Pages should return FALSE
  64. }
  65. void CWizClient0::UpdateCSCString()
  66. {
  67. if (m_bCSC)
  68. {
  69. CString cstrCSC;
  70. switch (m_dwCSCFlag & CSC_MASK)
  71. {
  72. case CSC_CACHE_MANUAL_REINT:
  73. cstrCSC.LoadString(IDS_CSC_MANUAL);
  74. break;
  75. case CSC_CACHE_AUTO_REINT:
  76. case CSC_CACHE_VDO:
  77. cstrCSC.LoadString(IDS_CSC_AUTOMATIC);
  78. break;
  79. case CSC_CACHE_NONE:
  80. cstrCSC.LoadString(IDS_CSC_NOCACHING);
  81. break;
  82. default:
  83. break;
  84. }
  85. SetDlgItemText(IDC_CSC, cstrCSC);
  86. }
  87. }
  88. typedef HRESULT (*PfnCacheSettingsDlg)(HWND hwndParent, DWORD & dwFlags);
  89. void CWizClient0::OnCSCChange()
  90. {
  91. HINSTANCE hInstance = ::LoadLibrary (_T("FileMgmt.dll"));
  92. if ( hInstance )
  93. {
  94. PfnCacheSettingsDlg pfn = (PfnCacheSettingsDlg)::GetProcAddress(hInstance, "CacheSettingsDlg");
  95. if (pfn)
  96. {
  97. pfn(m_hWnd, m_dwCSCFlag);
  98. }
  99. ::FreeLibrary(hInstance);
  100. }
  101. UpdateCSCString();
  102. }
  103. LRESULT CWizClient0::OnWizardNext()
  104. {
  105. CWaitCursor wait;
  106. Reset(); // init all related place holders
  107. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  108. CString cstrShareName;
  109. GetDlgItemText(IDC_SHARENAME, cstrShareName);
  110. cstrShareName.TrimLeft();
  111. cstrShareName.TrimRight();
  112. if (cstrShareName.IsEmpty())
  113. {
  114. CString cstrField;
  115. cstrField.LoadString(IDS_SHARENAME_LABEL);
  116. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_TEXT_REQUIRED, cstrField);
  117. GetDlgItem(IDC_SHARENAME)->SetFocus();
  118. return -1;
  119. }
  120. DWORD dwStatus = I_NetNameValidate(
  121. (pApp->m_bIsLocal ? NULL : const_cast<LPTSTR>(static_cast<LPCTSTR>(pApp->m_cstrTargetComputer))),
  122. const_cast<LPTSTR>(static_cast<LPCTSTR>(cstrShareName)),
  123. NAMETYPE_SHARE,
  124. 0);
  125. if (dwStatus)
  126. {
  127. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_INVALID_SHARENAME, cstrShareName);
  128. GetDlgItem(IDC_SHARENAME)->SetFocus();
  129. return -1;
  130. }
  131. if (ShareNameExists(cstrShareName))
  132. {
  133. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_DUPLICATE_SHARENAME, cstrShareName);
  134. GetDlgItem(IDC_SHARENAME)->SetFocus();
  135. return -1;
  136. }
  137. pApp->m_cstrShareName = cstrShareName;
  138. CString cstrShareDescription;
  139. GetDlgItemText(IDC_SHAREDESCRIPTION, cstrShareDescription);
  140. cstrShareDescription.TrimLeft();
  141. cstrShareDescription.TrimRight();
  142. pApp->m_cstrShareDescription = cstrShareDescription;
  143. pApp->m_dwCSCFlag = m_dwCSCFlag;
  144. return CPropertyPageEx::OnWizardNext();
  145. }
  146. void CWizClient0::OnChangeSharename()
  147. {
  148. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  149. CString cstrShareName;
  150. GetDlgItemText(IDC_SHARENAME, cstrShareName);
  151. CString cstrUNC = pApp->m_cstrUNCPrefix;
  152. cstrUNC += cstrShareName;
  153. SetDlgItemText(IDC_UNC, cstrUNC.Left(UNC_NAME_LIMIT));
  154. }
  155. BOOL CWizClient0::OnSetActive()
  156. {
  157. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  158. GetParent()->SetDlgItemText(ID_WIZNEXT, pApp->m_cstrNextButtonText);
  159. if (!pApp->m_bShareNamePageInitialized)
  160. {
  161. // SMB share description
  162. SetDlgItemText(IDC_SHAREDESCRIPTION, pApp->m_cstrShareDescription);
  163. // SMB CSC settings
  164. m_dwCSCFlag = pApp->m_dwCSCFlag;
  165. UpdateCSCString();
  166. // SMB share name
  167. SetDlgItemText(IDC_SHARENAME, pApp->m_cstrShareName);
  168. CString cstrStart = pApp->m_cstrFolder.Mid(3);
  169. int index = cstrStart.ReverseFind(_T('\\'));
  170. CString cstrDefaultShareName;
  171. if (0 == index)
  172. cstrDefaultShareName = cstrStart;
  173. else
  174. cstrDefaultShareName = cstrStart.Mid(index+1);
  175. if (cstrDefaultShareName.GetLength() <= SHARE_NAME_LIMIT)
  176. {
  177. if (!ShareNameExists(cstrDefaultShareName))
  178. SetDlgItemText(IDC_SHARENAME, cstrDefaultShareName);
  179. }
  180. OnChangeSharename();
  181. pApp->m_bShareNamePageInitialized = TRUE;
  182. }
  183. BOOL fRet = CPropertyPageEx::OnSetActive();
  184. PostMessage(WM_SETPAGEFOCUS, 0, 0L);
  185. return fRet;
  186. }
  187. BOOL CWizClient0::ShareNameExists(IN LPCTSTR lpszShareName)
  188. {
  189. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  190. return SMBShareNameExists(pApp->m_cstrTargetComputer, lpszShareName);
  191. }
  192. //
  193. // Q148388 How to Change Default Control Focus on CPropertyPageEx
  194. //
  195. LRESULT CWizClient0::OnSetPageFocus(WPARAM wParam, LPARAM lParam)
  196. {
  197. GetDlgItem(IDC_SHARENAME)->SetFocus();
  198. return 0;
  199. }
  200. void CWizClient0::Reset()
  201. {
  202. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  203. pApp->m_cstrShareName.Empty();
  204. pApp->m_cstrShareDescription.Empty();
  205. pApp->m_dwCSCFlag = CSC_CACHE_MANUAL_REINT;
  206. }
  207. /////////////////////////////////////////////////////////////////////////////
  208. // CWizClient property page
  209. IMPLEMENT_DYNCREATE(CWizClient, CPropertyPageEx)
  210. CWizClient::CWizClient() : CPropertyPageEx(CWizClient::IDD, 0, IDS_HEADERTITLE_CLIENT, IDS_HEADERSUBTITLE_CLIENT)
  211. {
  212. //{{AFX_DATA_INIT(CWizClient)
  213. // NOTE: the ClassWizard will add member initialization here
  214. //}}AFX_DATA_INIT
  215. m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  216. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  217. m_bCSC = pApp->m_bCSC;
  218. }
  219. CWizClient::~CWizClient()
  220. {
  221. }
  222. void CWizClient::DoDataExchange(CDataExchange* pDX)
  223. {
  224. CPropertyPageEx::DoDataExchange(pDX);
  225. //{{AFX_DATA_MAP(CWizClient)
  226. // NOTE: the ClassWizard will add DDX and DDV calls here
  227. //}}AFX_DATA_MAP
  228. }
  229. BEGIN_MESSAGE_MAP(CWizClient, CPropertyPageEx)
  230. //{{AFX_MSG_MAP(CWizClient)
  231. ON_BN_CLICKED(IDC_CHECK_MAC, OnCheckMac)
  232. ON_BN_CLICKED(IDC_CHECK_MS, OnCheckMs)
  233. ON_EN_CHANGE(IDC_SHARENAME, OnChangeSharename)
  234. ON_BN_CLICKED(IDC_CSC_CHANGE, OnCSCChange)
  235. //}}AFX_MSG_MAP
  236. ON_MESSAGE(WM_SETPAGEFOCUS, OnSetPageFocus)
  237. END_MESSAGE_MAP()
  238. /////////////////////////////////////////////////////////////////////////////
  239. // CWizClient message handlers
  240. BOOL CWizClient::OnInitDialog()
  241. {
  242. CPropertyPageEx::OnInitDialog();
  243. GetDlgItem(IDC_SHARENAME)->SendMessage(EM_LIMITTEXT, SHARE_NAME_LIMIT, 0);
  244. GetDlgItem(IDC_UNC)->SendMessage(EM_LIMITTEXT, UNC_NAME_LIMIT, 0);
  245. GetDlgItem(IDC_SHAREDESCRIPTION)->SendMessage(EM_LIMITTEXT, SHARE_DESCRIPTION_LIMIT, 0);
  246. GetDlgItem(IDC_MACSHARENAME)->SendMessage(EM_LIMITTEXT, SFM_SHARE_NAME_LIMIT, 0);
  247. if (!m_bCSC)
  248. {
  249. GetDlgItem(IDC_CSC_LABEL)->EnableWindow(FALSE);
  250. SetDlgItemText(IDC_CSC, _T(""));
  251. GetDlgItem(IDC_CSC)->EnableWindow(FALSE);
  252. GetDlgItem(IDC_CSC_CHANGE)->EnableWindow(FALSE);
  253. }
  254. return TRUE; // return TRUE unless you set the focus to a control
  255. // EXCEPTION: OCX Property Pages should return FALSE
  256. }
  257. void CWizClient::UpdateCSCString()
  258. {
  259. if (m_bCSC)
  260. {
  261. CString cstrCSC;
  262. switch (m_dwCSCFlag & CSC_MASK)
  263. {
  264. case CSC_CACHE_MANUAL_REINT:
  265. cstrCSC.LoadString(IDS_CSC_MANUAL);
  266. break;
  267. case CSC_CACHE_AUTO_REINT:
  268. case CSC_CACHE_VDO:
  269. cstrCSC.LoadString(IDS_CSC_AUTOMATIC);
  270. break;
  271. case CSC_CACHE_NONE:
  272. cstrCSC.LoadString(IDS_CSC_NOCACHING);
  273. break;
  274. default:
  275. break;
  276. }
  277. SetDlgItemText(IDC_CSC, cstrCSC);
  278. }
  279. }
  280. void CWizClient::OnCSCChange()
  281. {
  282. HINSTANCE hInstance = ::LoadLibrary (_T("FileMgmt.dll"));
  283. if ( hInstance )
  284. {
  285. PfnCacheSettingsDlg pfn = (PfnCacheSettingsDlg)::GetProcAddress(hInstance, "CacheSettingsDlg");
  286. if (pfn)
  287. {
  288. pfn(m_hWnd, m_dwCSCFlag);
  289. }
  290. ::FreeLibrary(hInstance);
  291. }
  292. UpdateCSCString();
  293. }
  294. LRESULT CWizClient::OnWizardNext()
  295. {
  296. CWaitCursor wait;
  297. Reset(); // init all related place holders
  298. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  299. pApp->m_bSMB = (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MS))->GetCheck());
  300. pApp->m_bSFM = (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MAC))->GetCheck());
  301. if (!pApp->m_bSMB && !pApp->m_bSFM)
  302. {
  303. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_CLIENT_REQUIRED);
  304. GetDlgItem(IDC_CHECK_MS)->SetFocus();
  305. return -1;
  306. }
  307. DWORD dwStatus = 0;
  308. if (pApp->m_bSMB)
  309. {
  310. CString cstrShareName;
  311. GetDlgItemText(IDC_SHARENAME, cstrShareName);
  312. cstrShareName.TrimLeft();
  313. cstrShareName.TrimRight();
  314. if (cstrShareName.IsEmpty())
  315. {
  316. CString cstrField;
  317. cstrField.LoadString(IDS_SHARENAME_LABEL);
  318. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_TEXT_REQUIRED, cstrField);
  319. GetDlgItem(IDC_SHARENAME)->SetFocus();
  320. return -1;
  321. }
  322. dwStatus = I_NetNameValidate(
  323. (pApp->m_bIsLocal ? NULL : const_cast<LPTSTR>(static_cast<LPCTSTR>(pApp->m_cstrTargetComputer))),
  324. const_cast<LPTSTR>(static_cast<LPCTSTR>(cstrShareName)),
  325. NAMETYPE_SHARE,
  326. 0);
  327. if (dwStatus)
  328. {
  329. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_INVALID_SHARENAME, cstrShareName);
  330. GetDlgItem(IDC_SHARENAME)->SetFocus();
  331. return -1;
  332. }
  333. if (ShareNameExists(cstrShareName, CLIENT_TYPE_SMB))
  334. {
  335. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_DUPLICATE_SMB_SHARENAME, cstrShareName);
  336. GetDlgItem(IDC_SHARENAME)->SetFocus();
  337. return -1;
  338. }
  339. pApp->m_cstrShareName = cstrShareName;
  340. }
  341. if (pApp->m_bSMB)
  342. {
  343. CString cstrShareDescription;
  344. GetDlgItemText(IDC_SHAREDESCRIPTION, cstrShareDescription);
  345. cstrShareDescription.TrimLeft();
  346. cstrShareDescription.TrimRight();
  347. pApp->m_cstrShareDescription = cstrShareDescription;
  348. pApp->m_dwCSCFlag = m_dwCSCFlag;
  349. }
  350. if (pApp->m_bSFM)
  351. {
  352. CString cstrMACShareName;
  353. GetDlgItemText(IDC_MACSHARENAME, cstrMACShareName);
  354. cstrMACShareName.TrimLeft();
  355. cstrMACShareName.TrimRight();
  356. if (cstrMACShareName.IsEmpty())
  357. {
  358. CString cstrField;
  359. cstrField.LoadString(IDS_MACSHARENAME_LABEL);
  360. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_TEXT_REQUIRED, cstrField);
  361. GetDlgItem(IDC_MACSHARENAME)->SetFocus();
  362. return -1;
  363. } else
  364. {
  365. dwStatus = I_NetNameValidate(
  366. (pApp->m_bIsLocal ? NULL : const_cast<LPTSTR>(static_cast<LPCTSTR>(pApp->m_cstrTargetComputer))),
  367. const_cast<LPTSTR>(static_cast<LPCTSTR>(cstrMACShareName)),
  368. NAMETYPE_SHARE,
  369. 0);
  370. if (dwStatus)
  371. {
  372. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_INVALID_SHARENAME, cstrMACShareName);
  373. GetDlgItem(IDC_MACSHARENAME)->SetFocus();
  374. return -1;
  375. }
  376. }
  377. if (ShareNameExists(cstrMACShareName, CLIENT_TYPE_SFM))
  378. {
  379. DisplayMessageBox(::GetActiveWindow(), MB_OK|MB_ICONERROR, 0, IDS_DUPLICATE_SFM_SHARENAME, cstrMACShareName);
  380. GetDlgItem(IDC_MACSHARENAME)->SetFocus();
  381. return -1;
  382. }
  383. pApp->m_cstrMACShareName = cstrMACShareName;
  384. }
  385. return CPropertyPageEx::OnWizardNext();
  386. }
  387. void CWizClient::OnCheckClient()
  388. {
  389. BOOL bSMB = (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MS))->GetCheck());
  390. BOOL bSFM = (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MAC))->GetCheck());
  391. GetDlgItem(IDC_SHARENAME)->EnableWindow(bSMB);
  392. GetDlgItem(IDC_UNC)->EnableWindow(bSMB);
  393. GetDlgItem(IDC_SHAREDESCRIPTION)->EnableWindow(bSMB);
  394. if (m_bCSC)
  395. {
  396. GetDlgItem(IDC_CSC)->EnableWindow(bSMB);
  397. GetDlgItem(IDC_CSC_CHANGE)->EnableWindow(bSMB);
  398. }
  399. GetDlgItem(IDC_MACSHARENAME)->EnableWindow(bSFM);
  400. }
  401. void CWizClient::OnCheckMac()
  402. {
  403. OnCheckClient();
  404. if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MAC))->GetCheck())
  405. {
  406. CString cstrShareName;
  407. GetDlgItemText(IDC_MACSHARENAME, cstrShareName);
  408. if (cstrShareName.IsEmpty() &&
  409. (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MS))->GetCheck()))
  410. {
  411. GetDlgItemText(IDC_SHARENAME, cstrShareName);
  412. SetDlgItemText(IDC_MACSHARENAME, cstrShareName.Left(SFM_SHARE_NAME_LIMIT));
  413. }
  414. }
  415. }
  416. void CWizClient::OnCheckMs()
  417. {
  418. OnCheckClient();
  419. }
  420. void CWizClient::OnChangeSharename()
  421. {
  422. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  423. CString cstrShareName;
  424. GetDlgItemText(IDC_SHARENAME, cstrShareName);
  425. CString cstrUNC = pApp->m_cstrUNCPrefix;
  426. cstrUNC += cstrShareName;
  427. SetDlgItemText(IDC_UNC, cstrUNC.Left(UNC_NAME_LIMIT));
  428. BOOL bSFM = (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MAC))->GetCheck());
  429. if (bSFM)
  430. {
  431. SetDlgItemText(IDC_MACSHARENAME, cstrShareName.Left(SFM_SHARE_NAME_LIMIT));
  432. }
  433. }
  434. BOOL CWizClient::OnSetActive()
  435. {
  436. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  437. GetParent()->SetDlgItemText(ID_WIZNEXT, pApp->m_cstrNextButtonText);
  438. if (!pApp->m_bShareNamePageInitialized)
  439. {
  440. CheckDlgButton(IDC_CHECK_MS, pApp->m_bSMB);
  441. CheckDlgButton(IDC_CHECK_MAC, pApp->m_bSFM);
  442. OnCheckMs();
  443. // SMB share description
  444. SetDlgItemText(IDC_SHAREDESCRIPTION, pApp->m_cstrShareDescription);
  445. // SMB CSC settings
  446. m_dwCSCFlag = pApp->m_dwCSCFlag;
  447. UpdateCSCString();
  448. // MAC share name
  449. SetDlgItemText(IDC_MACSHARENAME, pApp->m_cstrMACShareName);
  450. // SMB share name
  451. SetDlgItemText(IDC_SHARENAME, pApp->m_cstrShareName);
  452. CString cstrStart = pApp->m_cstrFolder.Mid(3);
  453. int index = cstrStart.ReverseFind(_T('\\'));
  454. CString cstrDefaultShareName;
  455. if (0 == index)
  456. cstrDefaultShareName = cstrStart;
  457. else
  458. cstrDefaultShareName = cstrStart.Mid(index+1);
  459. if (cstrDefaultShareName.GetLength() <= SHARE_NAME_LIMIT)
  460. {
  461. if (!ShareNameExists(cstrDefaultShareName, CLIENT_TYPE_SMB))
  462. SetDlgItemText(IDC_SHARENAME, cstrDefaultShareName);
  463. }
  464. OnChangeSharename();
  465. pApp->m_bShareNamePageInitialized = TRUE;
  466. }
  467. BOOL fRet = CPropertyPageEx::OnSetActive();
  468. PostMessage(WM_SETPAGEFOCUS, 0, 0L);
  469. return fRet;
  470. }
  471. BOOL CWizClient::ShareNameExists(IN LPCTSTR lpszShareName, IN CLIENT_TYPE iType)
  472. {
  473. BOOL bReturn = FALSE;
  474. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  475. switch (iType)
  476. {
  477. case CLIENT_TYPE_SMB:
  478. {
  479. bReturn = SMBShareNameExists(pApp->m_cstrTargetComputer, lpszShareName);
  480. break;
  481. }
  482. case CLIENT_TYPE_SFM:
  483. {
  484. ASSERT(pApp->m_hLibSFM);
  485. bReturn = SFMShareNameExists(pApp->m_cstrTargetComputer, lpszShareName, pApp->m_hLibSFM);
  486. break;
  487. }
  488. default:
  489. break;
  490. }
  491. return bReturn;
  492. }
  493. //
  494. // Q148388 How to Change Default Control Focus on CPropertyPageEx
  495. //
  496. LRESULT CWizClient::OnSetPageFocus(WPARAM wParam, LPARAM lParam)
  497. {
  498. if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MS))->GetCheck())
  499. {
  500. GetDlgItem(IDC_SHARENAME)->SetFocus();
  501. } else if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_CHECK_MAC))->GetCheck())
  502. {
  503. GetDlgItem(IDC_MACSHARENAME)->SetFocus();
  504. } else
  505. {
  506. GetDlgItem(IDC_CHECK_MS)->SetFocus();
  507. }
  508. return 0;
  509. }
  510. void CWizClient::Reset()
  511. {
  512. CShrwizApp *pApp = (CShrwizApp *)AfxGetApp();
  513. pApp->m_cstrShareName.Empty();
  514. pApp->m_cstrShareDescription.Empty();
  515. pApp->m_cstrMACShareName.Empty();
  516. pApp->m_dwCSCFlag = CSC_CACHE_MANUAL_REINT;
  517. pApp->m_bSMB = TRUE;
  518. pApp->m_bSFM = FALSE;
  519. }