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.

779 lines
27 KiB

  1. /**MOD+**********************************************************************/
  2. /* Module: property.cpp */
  3. /* */
  4. /* Purpose: Class implementaion for the property sheet. */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1998 */
  7. /* */
  8. /****************************************************************************/
  9. #include "stdafx.h"
  10. #include <property.h>
  11. #include <prsht.h>
  12. #include "defaults.h"
  13. #include "validate.h"
  14. #include "browsedlg.h"
  15. #include "resource.h"
  16. #include "shlwapi.h"
  17. #define MSG_BUF_SIZE 512
  18. //
  19. // Format message helpers
  20. //
  21. LPTSTR FormatMessageVAList(LPCTSTR pcszFormat, va_list *argList)
  22. {
  23. LPTSTR pszOutput;
  24. if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
  25. pcszFormat,
  26. 0, 0,
  27. reinterpret_cast<LPTSTR>(&pszOutput), 0,
  28. argList) == 0)
  29. {
  30. pszOutput = NULL;
  31. }
  32. return(pszOutput);
  33. }
  34. LPTSTR FormatMessageVArgs(LPCTSTR pcszFormat, ...)
  35. {
  36. LPTSTR pszOutput;
  37. va_list argList;
  38. va_start(argList, pcszFormat);
  39. pszOutput = FormatMessageVAList(pcszFormat, &argList);
  40. va_end(argList);
  41. return(pszOutput);
  42. }
  43. CProperty* CProperty::m_pthis = NULL;
  44. CProperty::CProperty(HWND hwndOwner, HINSTANCE hInst)
  45. {
  46. m_pthis = this;
  47. m_hWnd = hwndOwner;
  48. m_hInst = hInst;
  49. lstrcpy(m_szDescription, _T(""));
  50. lstrcpy(m_szServer, _T(""));
  51. lstrcpy(m_szUserName, _T(""));
  52. lstrcpy(m_szPassword, _T(""));
  53. lstrcpy(m_szDomain, _T(""));
  54. m_bChangePassword = FALSE;
  55. m_resType = SCREEN_RES_FROM_DROPDOWN;
  56. m_Width = DEFAULT_RES_WIDTH;
  57. m_Height = DEFAULT_RES_HEIGHT;
  58. m_bSavePassword = FALSE;
  59. m_bConnectToConsole = FALSE;
  60. m_bRedirectDrives = TRUE;
  61. m_pDisplayHelp = NULL;
  62. m_bStartProgram = FALSE;
  63. lstrcpy(m_szProgramPath, _T(""));
  64. lstrcpy(m_szProgramStartIn, _T(""));
  65. }
  66. CProperty::~CProperty()
  67. {
  68. if (m_pDisplayHelp) {
  69. m_pDisplayHelp->Release();
  70. m_pDisplayHelp = NULL;
  71. }
  72. }
  73. BOOL CProperty::CreateModalPropPage()
  74. {
  75. // Fill the structures with info for the pages.
  76. PROPSHEETPAGE psp [3];
  77. PROPSHEETHEADER psh;
  78. psp[0].dwSize = sizeof (PROPSHEETPAGE);
  79. psp[0].dwFlags = PSP_USETITLE | PSP_HASHELP;
  80. psp[0].hInstance = m_hInst;
  81. psp[0].pszTemplate = MAKEINTRESOURCE (IDD_PROPPAGE1);
  82. psp[0].pszIcon = NULL;
  83. psp[0].pfnDlgProc = StaticPage1Proc;
  84. TCHAR szBuf1[MAX_PATH] = _T("");
  85. if (!LoadString(m_hInst, IDS_NETCON, szBuf1, MAX_PATH))
  86. {
  87. return FALSE;
  88. }
  89. psp[0].pszTitle = szBuf1;
  90. psp[0].lParam = 0;
  91. psp[1].dwSize = sizeof (PROPSHEETPAGE);
  92. psp[1].dwFlags = PSP_USETITLE | PSP_HASHELP;
  93. psp[1].hInstance = m_hInst;
  94. psp[1].pszTemplate = MAKEINTRESOURCE (IDD_PROPPAGE2);
  95. psp[1].pszIcon = NULL;
  96. psp[1].pfnDlgProc = StaticPage2Proc;
  97. TCHAR szBuf2[MAX_PATH] = _T("");
  98. if (!LoadString(m_hInst, IDS_CONNOPT, szBuf2, MAX_PATH))
  99. {
  100. return FALSE;
  101. }
  102. psp[1].pszTitle = szBuf2;
  103. psp[1].lParam = 0;
  104. psp[2].dwSize = sizeof (PROPSHEETPAGE);
  105. psp[2].dwFlags = PSP_USETITLE | PSP_HASHELP;
  106. psp[2].hInstance = m_hInst;
  107. psp[2].pszTemplate = MAKEINTRESOURCE (IDD_PROPPAGE3);
  108. psp[2].pszIcon = NULL;
  109. psp[2].pfnDlgProc = StaticPage3Proc;
  110. TCHAR szBuf3[MAX_PATH] = _T("");
  111. if (!LoadString(m_hInst, IDS_OTHERTAB, szBuf3, MAX_PATH))
  112. {
  113. return FALSE;
  114. }
  115. psp[2].pszTitle = szBuf3;
  116. psp[2].lParam = 0;
  117. psh.dwSize = sizeof(PROPSHEETHEADER);
  118. psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
  119. psh.hwndParent = m_hWnd;
  120. psh.hInstance = m_hInst;
  121. psh.nStartPage = 0;
  122. TCHAR szProperties[MSG_BUF_SIZE];
  123. if (!LoadString(m_hInst, IDS_PROPERTIES_CAPTION, szProperties, MAX_PATH))
  124. {
  125. return FALSE;
  126. }
  127. //Splice in the node name: e.g 'MyServer' to make a caption like
  128. //'MyServer Properties'
  129. wsprintf(m_szCaption, szProperties, m_szDescription);
  130. psh.pszCaption = m_szCaption;
  131. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  132. psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  133. return (BOOL)PropertySheet(&psh);
  134. }
  135. //
  136. // Disable resolutions the system does not support
  137. //
  138. void CProperty::ProcessResolution(HWND hDlg)
  139. {
  140. int x[] = {640, 800, 1024, 1280, 1600};
  141. int y[] = {480, 600, 768, 1024, 1200};
  142. int xRes = GetSystemMetrics(SM_CXSCREEN);
  143. int yRes = GetSystemMetrics(SM_CYSCREEN);
  144. TCHAR buf[32];
  145. HWND hwndListBox = GetDlgItem(hDlg, IDC_COMBO_RESOLUTIONS);
  146. LRESULT lr;
  147. for (int i = 0; i <= (NUM_RESOLUTIONS -1); i++)
  148. {
  149. if ( (xRes >= x[i]) && (yRes >= y[i]))
  150. {
  151. wsprintf(buf, L"%d x %d", x[i], y[i]);
  152. lr = SendMessage(hwndListBox, CB_ADDSTRING, 0,(LPARAM)(LPCTSTR) buf);
  153. }
  154. }
  155. return;
  156. }
  157. INT_PTR APIENTRY CProperty::StaticPage1Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  158. {
  159. return m_pthis->Page1Proc( hDlg, message, wParam, lParam);
  160. }
  161. INT_PTR APIENTRY CProperty::StaticPage2Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  162. {
  163. return m_pthis->Page2Proc( hDlg, message, wParam, lParam);
  164. }
  165. INT_PTR APIENTRY CProperty::StaticPage3Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  166. {
  167. return m_pthis->Page3Proc( hDlg, message, wParam, lParam);
  168. }
  169. INT_PTR APIENTRY CProperty::Page1Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  170. {
  171. switch (message)
  172. {
  173. case WM_INITDIALOG:
  174. {
  175. //Limit length of these edit boxes
  176. SendMessage(GetDlgItem(hDlg, IDC_DESCRIPTION), EM_LIMITTEXT, CL_MAX_DESC_LENGTH, 0);
  177. SendMessage(GetDlgItem(hDlg, IDC_SERVER), EM_LIMITTEXT, CL_MAX_DOMAIN_LENGTH, 0);
  178. SendMessage(GetDlgItem(hDlg, IDC_USERNAME), EM_LIMITTEXT, CL_MAX_USERNAME_LENGTH, 0);
  179. SendMessage(GetDlgItem(hDlg, IDC_PASSWORD), EM_LIMITTEXT, CL_MAX_PASSWORD_EDIT, 0);
  180. SendMessage(GetDlgItem(hDlg, IDC_DOMAIN), EM_LIMITTEXT, CL_MAX_DOMAIN_LENGTH, 0);
  181. //Save password settings
  182. SendMessage(GetDlgItem(hDlg, IDC_SAVE_PASSWORD), BM_SETCHECK,
  183. m_bSavePassword ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0);
  184. //Connect to console
  185. SendMessage(GetDlgItem(hDlg, IDC_CONNECT_TO_CONSOLE), BM_SETCHECK,
  186. m_bConnectToConsole ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0);
  187. //
  188. // Password edit box is disabled until the user
  189. // clicks on the change password button
  190. //
  191. EnableWindow(GetDlgItem(hDlg, IDC_PASSWORD), FALSE);
  192. //
  193. // Set from defaults
  194. //
  195. SetWindowText(GetDlgItem(hDlg, IDC_DESCRIPTION), m_szDescription);
  196. SetWindowText(GetDlgItem(hDlg, IDC_SERVER), m_szServer);
  197. SetWindowText(GetDlgItem(hDlg, IDC_USERNAME), m_szUserName);
  198. SetWindowText(GetDlgItem(hDlg, IDC_DOMAIN), m_szDomain);
  199. SetFocus(GetDlgItem(hDlg, IDC_SERVER));
  200. return TRUE;
  201. }
  202. break;
  203. case WM_COMMAND:
  204. {
  205. if (BN_CLICKED == HIWORD(wParam))
  206. {
  207. switch (LOWORD(wParam))
  208. {
  209. case IDC_BROWSE_SERVERS:
  210. {
  211. INT_PTR nResult = IDCANCEL;
  212. CBrowseDlg dlg( hDlg, m_hInst);
  213. nResult = dlg.DoModal();
  214. if (-1 == nResult)
  215. {
  216. ODS(L"DialogBox failed newcondlg.cpp\n");
  217. }
  218. if (IDOK == nResult)
  219. {
  220. SetDlgItemText(hDlg, IDC_SERVER, dlg.GetServer());
  221. //
  222. // set connection name as well if necessary
  223. //
  224. TCHAR szDesc[CL_MAX_DESC_LENGTH];
  225. GetDlgItemText(hDlg, IDC_DESCRIPTION, szDesc, CL_MAX_DESC_LENGTH);
  226. if (!lstrcmp(szDesc, L""))
  227. {
  228. SetDlgItemText(hDlg, IDC_DESCRIPTION, dlg.GetServer());
  229. }
  230. }
  231. SetFocus(hDlg);
  232. }
  233. break;
  234. case IDC_CHANGEPASSWORD:
  235. {
  236. //
  237. // Enable and reset the password edit field
  238. //
  239. EnableWindow(GetDlgItem(hDlg, IDC_PASSWORD), TRUE);
  240. m_bChangePassword = TRUE;
  241. SetDlgItemText(hDlg, IDC_PASSWORD, _T(""));
  242. }
  243. break;
  244. }
  245. }
  246. else if (EN_KILLFOCUS == HIWORD(wParam))
  247. {
  248. if (IDC_SERVER == LOWORD(wParam))
  249. {
  250. //
  251. // set connection name to server name if conn name is blank
  252. //
  253. TCHAR szDesc[CL_MAX_DESC_LENGTH];
  254. TCHAR szServer[CL_MAX_DESC_LENGTH];
  255. GetDlgItemText(hDlg, IDC_DESCRIPTION, szDesc, CL_MAX_DESC_LENGTH);
  256. if (!lstrcmp(szDesc, L""))
  257. {
  258. GetDlgItemText(hDlg, IDC_SERVER, szServer, CL_MAX_DOMAIN_LENGTH);
  259. SetDlgItemText(hDlg, IDC_DESCRIPTION, szServer);
  260. }
  261. }
  262. }
  263. else if (EN_CHANGE == HIWORD(wParam))
  264. {
  265. if ((LOWORD(wParam) == IDC_USERNAME))
  266. {
  267. //Handle UPN style user names
  268. //by disabling the domain field if there
  269. //is an @ in the username
  270. TCHAR szUserName[CL_MAX_USERNAME_LENGTH];
  271. BOOL fDisableDomain = FALSE;
  272. GetDlgItemText( hDlg, IDC_USERNAME,
  273. szUserName, SIZEOF_TCHARBUFFER(szUserName));
  274. if(!_tcsstr(szUserName, TEXT("@")))
  275. {
  276. fDisableDomain = TRUE;
  277. }
  278. EnableWindow(GetDlgItem(hDlg, IDC_DOMAIN),
  279. fDisableDomain);
  280. }
  281. }
  282. return TRUE;
  283. break; // WM_COMMAND
  284. }
  285. break;
  286. case WM_NOTIFY:
  287. {
  288. switch (((NMHDR FAR *)lParam)->code)
  289. {
  290. case PSN_APPLY:
  291. case PSN_KILLACTIVE:
  292. {
  293. //
  294. // Validate
  295. //
  296. if (!CValidate::Validate(hDlg, m_hInst))
  297. {
  298. //
  299. // Prevent page from losing activation
  300. //
  301. return TRUE;
  302. }
  303. //Retrieve the data to be stored.
  304. GetDlgItemText(hDlg, IDC_DESCRIPTION, m_szDescription, MAX_PATH);
  305. GetDlgItemText(hDlg, IDC_SERVER, m_szServer, MAX_PATH);
  306. if (!lstrcmp( m_szDescription, L""))
  307. {
  308. //if no description is specified. Default to the server name
  309. lstrcpy(m_szDescription, m_szServer);
  310. }
  311. //
  312. // Get user/pass/domain
  313. //
  314. GetDlgItemText(hDlg, IDC_USERNAME, m_szUserName, CL_MAX_USERNAME_LENGTH - 1);
  315. GetDlgItemText(hDlg, IDC_PASSWORD, m_szPassword,
  316. CL_MAX_PASSWORD_LENGTH_BYTES * sizeof(TCHAR) - 1);
  317. GetDlgItemText(hDlg, IDC_DOMAIN, m_szDomain, CL_MAX_DOMAIN_LENGTH - 1);
  318. if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_SAVE_PASSWORD))
  319. {
  320. m_bSavePassword = TRUE;
  321. }
  322. else
  323. {
  324. m_bSavePassword = FALSE;
  325. }
  326. m_bConnectToConsole = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_CONNECT_TO_CONSOLE));
  327. return FALSE;
  328. }
  329. break;
  330. case PSN_HELP:
  331. {
  332. DisplayHelp();
  333. }
  334. break; //PSN_HELP
  335. }
  336. }
  337. break;
  338. }
  339. return FALSE;
  340. }
  341. INT_PTR APIENTRY CProperty::Page2Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  342. {
  343. static PROPSHEETPAGE *ps;
  344. int x[] = {640, 800, 1024, 1280, 1600};
  345. int y[] = {480, 600, 768, 1024, 1200};
  346. switch (message)
  347. {
  348. case WM_INITDIALOG:
  349. {
  350. //Get the machine resolution and disable options higher than that.
  351. ProcessResolution(hDlg);
  352. CheckRadioButton( hDlg, IDC_RADIO_CHOOSE_SIZE,IDC_COMBO_RESOLUTIONS,
  353. IDC_RADIO_CHOOSE_SIZE + m_resType -1);
  354. if (SCREEN_RES_FROM_DROPDOWN==m_resType)
  355. {
  356. for (int i=0;i<NUM_RESOLUTIONS-1;i++)
  357. if (m_Width == x[i])
  358. break;
  359. SendDlgItemMessage(hDlg, IDC_COMBO_RESOLUTIONS, CB_SETCURSEL, (WPARAM)i,(LPARAM) 0);
  360. SendMessage(hDlg, WM_COMMAND, MAKELONG(IDC_RADIO_CHOOSE_SIZE,BN_CLICKED), 0L);
  361. }
  362. else if (SCREEN_RES_CUSTOM == m_resType)
  363. {
  364. SendDlgItemMessage(hDlg, IDC_COMBO_RESOLUTIONS, CB_SETCURSEL, (WPARAM)0,(LPARAM) 0);
  365. SetDlgItemInt(hDlg, IDC_EDIT_WIDTH, m_Width, FALSE);
  366. SetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, m_Height, FALSE);
  367. SendMessage(hDlg, WM_COMMAND, MAKELONG(IDC_RADIO_CUSTOM_SIZE,BN_CLICKED), 0L);
  368. }
  369. else if (SCREEN_RES_FILL_MMC == m_resType)
  370. {
  371. SendDlgItemMessage(hDlg, IDC_COMBO_RESOLUTIONS, CB_SETCURSEL, (WPARAM)0,(LPARAM) 0);
  372. SendMessage(hDlg, WM_COMMAND, MAKELONG(IDC_RADIO_SIZE_FILL_MMC,BN_CLICKED), 0L);
  373. }
  374. return TRUE;
  375. break; //WM_INITDIALOG
  376. }
  377. case WM_NOTIFY:
  378. {
  379. switch (((NMHDR FAR *)lParam)->code)
  380. {
  381. case PSN_APPLY:
  382. case PSN_KILLACTIVE:
  383. {
  384. if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_RADIO_CHOOSE_SIZE))
  385. {
  386. m_resType = SCREEN_RES_FROM_DROPDOWN;
  387. LRESULT i = SendDlgItemMessage(hDlg, IDC_COMBO_RESOLUTIONS,
  388. CB_GETCURSEL, 0L, 0L);
  389. if (CB_ERR != i)
  390. {
  391. m_Width = x[i];
  392. m_Height = y[i];
  393. }
  394. return FALSE;
  395. }
  396. else if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_RADIO_CUSTOM_SIZE))
  397. {
  398. BOOL bSuccess = FALSE;
  399. int num;
  400. m_resType = SCREEN_RES_CUSTOM;
  401. num = GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, &bSuccess, FALSE);
  402. if (!bSuccess || num < MIN_CLIENT_SIZE || num > MAX_CLIENT_WIDTH)
  403. {
  404. goto INVALID_DESKTOP_SIZE;
  405. }
  406. //
  407. // Client has restriction that width has to be multiple of 4
  408. //
  409. if (num % 4)
  410. {
  411. TCHAR szErrorBuf[MSG_BUF_SIZE];
  412. TCHAR szTitle[MAX_PATH];
  413. if (!LoadString(m_hInst, IDS_MAINWINDOWTITLE, szTitle, sizeof(szTitle)/sizeof(TCHAR)))
  414. {
  415. return FALSE;
  416. }
  417. if (!LoadString(m_hInst, IDS_WIDTH_NOT_VALID, szErrorBuf, sizeof(szErrorBuf)/sizeof(TCHAR)))
  418. {
  419. return FALSE;
  420. }
  421. MessageBox(hDlg, szErrorBuf, szTitle, MB_OK|MB_ICONSTOP);
  422. //
  423. // prevent the page from losing focus
  424. //
  425. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  426. return TRUE;
  427. }
  428. m_Width = num;
  429. num = GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, &bSuccess, FALSE);
  430. if (!bSuccess || num < MIN_CLIENT_SIZE || num > MAX_CLIENT_HEIGHT)
  431. {
  432. goto INVALID_DESKTOP_SIZE;
  433. }
  434. m_Height = num;
  435. return FALSE;
  436. INVALID_DESKTOP_SIZE:
  437. TCHAR szErrorBuf[MSG_BUF_SIZE];
  438. LPTSTR szFormattedErrorBuf = NULL;
  439. TCHAR szTitle[MAX_PATH];
  440. if (!LoadString(m_hInst, IDS_MAINWINDOWTITLE, szTitle, sizeof(szTitle)/sizeof(TCHAR)))
  441. {
  442. return FALSE;
  443. }
  444. if (!LoadString(m_hInst, IDS_INVALID_WIDTH_HEIGHT, szErrorBuf, sizeof(szErrorBuf)/sizeof(TCHAR)))
  445. {
  446. return FALSE;
  447. }
  448. int res[] = {
  449. MIN_CLIENT_SIZE,
  450. MIN_CLIENT_SIZE,
  451. MAX_CLIENT_WIDTH,
  452. MAX_CLIENT_HEIGHT};
  453. szFormattedErrorBuf = FormatMessageVArgs(szErrorBuf,
  454. MIN_CLIENT_SIZE,
  455. MIN_CLIENT_SIZE,
  456. MAX_CLIENT_WIDTH,
  457. MAX_CLIENT_HEIGHT);
  458. if (szFormattedErrorBuf)
  459. {
  460. MessageBox(hDlg, szFormattedErrorBuf, szTitle, MB_OK|MB_ICONSTOP);
  461. LocalFree(szFormattedErrorBuf);
  462. szFormattedErrorBuf = NULL;
  463. }
  464. //
  465. // prevent the page from losing focus
  466. //
  467. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  468. return TRUE;
  469. }
  470. else
  471. {
  472. m_resType = SCREEN_RES_FILL_MMC;
  473. m_Width = 0;
  474. m_Height = 0;
  475. return FALSE;
  476. }
  477. }
  478. break;
  479. case PSN_HELP:
  480. {
  481. DisplayHelp();
  482. }
  483. break;
  484. }
  485. break; // WM_NOTIFY
  486. }
  487. case WM_COMMAND:
  488. {
  489. if (BN_CLICKED == HIWORD(wParam))
  490. {
  491. if (IDC_RADIO_CHOOSE_SIZE == (int) LOWORD(wParam))
  492. {
  493. if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_RADIO_CHOOSE_SIZE))
  494. {
  495. EnableWindow(GetDlgItem(hDlg, IDC_COMBO_RESOLUTIONS), TRUE);
  496. SetFocus(GetDlgItem(hDlg, IDC_COMBO_RESOLUTIONS));
  497. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_WIDTH), FALSE);
  498. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HEIGHT), FALSE);
  499. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_WIDTH), FALSE);
  500. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_HEIGHT), FALSE);
  501. }
  502. }
  503. else if (IDC_RADIO_CUSTOM_SIZE == (int) LOWORD(wParam))
  504. {
  505. if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_RADIO_CUSTOM_SIZE))
  506. {
  507. EnableWindow(GetDlgItem(hDlg, IDC_COMBO_RESOLUTIONS), FALSE);
  508. SetFocus(GetDlgItem(hDlg, IDC_EDIT_WIDTH));
  509. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_WIDTH), TRUE);
  510. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HEIGHT), TRUE);
  511. //
  512. // Initialize defaults for widht/height
  513. //
  514. BOOL bSuccess = FALSE;
  515. GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, &bSuccess, FALSE);
  516. if (!bSuccess)
  517. {
  518. SetDlgItemInt(hDlg, IDC_EDIT_WIDTH, DEFAULT_RES_WIDTH ,FALSE);
  519. }
  520. bSuccess = FALSE;
  521. GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, &bSuccess, FALSE);
  522. if (!bSuccess)
  523. {
  524. SetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, DEFAULT_RES_HEIGHT ,FALSE);
  525. }
  526. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_WIDTH), TRUE);
  527. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_HEIGHT), TRUE);
  528. }
  529. }
  530. else if (IDC_RADIO_SIZE_FILL_MMC == (int) LOWORD(wParam))
  531. {
  532. if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_RADIO_SIZE_FILL_MMC))
  533. {
  534. EnableWindow(GetDlgItem(hDlg, IDC_COMBO_RESOLUTIONS), FALSE);
  535. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_WIDTH), FALSE);
  536. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HEIGHT), FALSE);
  537. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_WIDTH), FALSE);
  538. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_HEIGHT), FALSE);
  539. }
  540. }
  541. }
  542. break; //WM_COMMAND
  543. }
  544. }
  545. return FALSE;
  546. }
  547. INT_PTR APIENTRY CProperty::Page3Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  548. {
  549. static PROPSHEETPAGE *ps;
  550. switch (message)
  551. {
  552. case WM_INITDIALOG:
  553. {
  554. SendMessage(GetDlgItem(hDlg, IDC_APP), EM_LIMITTEXT, MAX_PATH, 0);
  555. SendMessage(GetDlgItem(hDlg, IDC_WORKDIR), EM_LIMITTEXT, MAX_PATH, 0);
  556. SetDlgItemText(hDlg, IDC_APP, m_szProgramPath);
  557. SetDlgItemText(hDlg, IDC_WORKDIR, m_szProgramStartIn);
  558. EnableWindow(GetDlgItem(hDlg, IDC_APP), m_bStartProgram);
  559. EnableWindow(GetDlgItem(hDlg, IDC_WORKDIR), m_bStartProgram);
  560. EnableWindow(GetDlgItem(hDlg, IDC_SPECIFY_APP_TEXT), m_bStartProgram);
  561. EnableWindow(GetDlgItem(hDlg, IDC_WORKDIR_STATIC), m_bStartProgram);
  562. SendMessage(GetDlgItem(hDlg, IDC_SPECIFY_APP), BM_SETCHECK,
  563. m_bStartProgram ?
  564. (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0);
  565. SendMessage(GetDlgItem(hDlg, IDC_REDIRECT_DRIVES), BM_SETCHECK,
  566. m_bRedirectDrives ?
  567. (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0);
  568. return TRUE;
  569. break; //WM_INITDIALOG
  570. }
  571. case WM_HELP:
  572. {
  573. //PopContextHelp(lParam);
  574. return TRUE;
  575. break;
  576. }
  577. case WM_COMMAND:
  578. {
  579. if (BN_CLICKED == HIWORD(wParam))
  580. {
  581. if (IDC_SPECIFY_APP == (int) LOWORD(wParam))
  582. {
  583. BOOL fChecked = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_SPECIFY_APP));
  584. EnableWindow(GetDlgItem(hDlg, IDC_APP), fChecked);
  585. EnableWindow(GetDlgItem(hDlg, IDC_WORKDIR), fChecked);
  586. EnableWindow(GetDlgItem(hDlg, IDC_SPECIFY_APP_TEXT), fChecked);
  587. EnableWindow(GetDlgItem(hDlg, IDC_WORKDIR_STATIC), fChecked);
  588. if (fChecked)
  589. {
  590. SetFocus(GetDlgItem(hDlg, IDC_APP));
  591. SendMessage(GetDlgItem(hDlg, IDC_APP),
  592. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  593. }
  594. else
  595. {
  596. SetDlgItemText(hDlg, IDC_APP, TEXT(""));
  597. SetDlgItemText(hDlg, IDC_WORKDIR, TEXT(""));
  598. }
  599. }
  600. }
  601. break; //WM_COMMAND
  602. }
  603. case WM_NOTIFY:
  604. {
  605. switch (((NMHDR FAR *)lParam)->code)
  606. {
  607. case PSN_KILLACTIVE:
  608. {
  609. if (BST_CHECKED != IsDlgButtonChecked(hDlg, IDC_SPECIFY_APP))
  610. {
  611. lstrcpy(m_szProgramPath, _T(""));
  612. lstrcpy(m_szProgramStartIn, _T(""));
  613. m_bStartProgram = FALSE;
  614. }
  615. else
  616. {
  617. GetDlgItemText(hDlg, IDC_APP, m_szProgramPath, MAX_PATH - 1);
  618. GetDlgItemText(hDlg, IDC_WORKDIR, m_szProgramStartIn, MAX_PATH - 1);
  619. m_bStartProgram = TRUE;
  620. }
  621. m_bRedirectDrives = (BST_CHECKED ==
  622. IsDlgButtonChecked(hDlg, IDC_REDIRECT_DRIVES));
  623. }
  624. break; //PSN_KILLACTIVE
  625. case PSN_HELP:
  626. {
  627. DisplayHelp();
  628. }
  629. break; //PSN_HELP
  630. }
  631. }
  632. break; //WM_NOTIFY
  633. } // switch(message)
  634. return FALSE;
  635. }
  636. void CProperty::SetDisplayHelp(LPDISPLAYHELP lpHelp)
  637. {
  638. if (lpHelp)
  639. {
  640. if (m_pDisplayHelp) {
  641. m_pDisplayHelp->Release();
  642. m_pDisplayHelp = NULL;
  643. }
  644. m_pDisplayHelp = lpHelp;
  645. lpHelp->AddRef();
  646. }
  647. }
  648. HRESULT CProperty::DisplayHelp()
  649. {
  650. TCHAR tchTopic[ 80 ];
  651. HRESULT hr = E_FAIL;
  652. if ( m_pDisplayHelp == NULL )
  653. {
  654. return hr;
  655. }
  656. if (LoadString(_Module.GetResourceInstance(),
  657. IDS_TSCMMCHELP_PROPS,
  658. tchTopic,
  659. SIZE_OF_BUFFER( tchTopic )))
  660. {
  661. hr = m_pDisplayHelp->ShowTopic( tchTopic );
  662. }
  663. return( SUCCEEDED( hr ) ? TRUE : FALSE );
  664. }
  665. BOOL CProperty::GetPasswordSpecified()
  666. {
  667. BOOL fPasswordSpecified = FALSE;
  668. if (_tcslen(m_szPassword) != 0)
  669. {
  670. fPasswordSpecified = TRUE;
  671. }
  672. return fPasswordSpecified;
  673. }