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.

1843 lines
57 KiB

  1. //
  2. // lnkcon.c link console property pages implementation
  3. //
  4. //---------------------------------------------------------------------------
  5. #include "shellprv.h"
  6. #pragma hdrstop
  7. #include "lnkcon.h"
  8. LRESULT PreviewWndProc( HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam );
  9. BOOL_PTR CALLBACK _FontDlgProc( HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam );
  10. LRESULT _FontPreviewWndProc( HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam );
  11. extern TCHAR g_szPreviewText[];
  12. // Context-sensitive help ids
  13. const static DWORD rgdwHelpColor[] = {
  14. IDC_CNSL_COLOR_SCREEN_TEXT, IDH_CONSOLE_COLOR_SCR_TEXT,
  15. IDC_CNSL_COLOR_SCREEN_BKGND, IDH_CONSOLE_COLOR_SCR_BACK,
  16. IDC_CNSL_COLOR_POPUP_TEXT, IDH_CONSOLE_COLOR_POPUP_TEXT,
  17. IDC_CNSL_COLOR_POPUP_BKGND, IDH_CONSOLE_COLOR_POPUP_BACK,
  18. IDC_CNSL_COLOR_RED_LBL, IDH_CONSOLE_COLOR_RED,
  19. IDC_CNSL_COLOR_RED, IDH_CONSOLE_COLOR_RED,
  20. IDC_CNSL_COLOR_GREEN_LBL, IDH_CONSOLE_COLOR_RED,
  21. IDC_CNSL_COLOR_GREEN, IDH_CONSOLE_COLOR_RED,
  22. IDC_CNSL_COLOR_BLUE_LBL, IDH_CONSOLE_COLOR_RED,
  23. IDC_CNSL_COLOR_BLUE, IDH_CONSOLE_COLOR_RED,
  24. IDC_CNSL_COLOR_SCREEN_COLORS, IDH_CONSOLE_COLOR_SCR_COLORS,
  25. IDC_CNSL_COLOR_SCREEN_COLORS_LBL, IDH_CONSOLE_COLOR_SCR_COLORS,
  26. IDC_CNSL_COLOR_POPUP_COLORS, IDH_CONSOLE_COLOR_WIN_COLORS,
  27. IDC_CNSL_COLOR_POPUP_COLORS_LBL, IDH_CONSOLE_COLOR_WIN_COLORS,
  28. IDC_CNSL_COLOR_1, IDH_CONSOLE_COLOR_COLOR_BAR,
  29. IDC_CNSL_COLOR_2, IDH_CONSOLE_COLOR_COLOR_BAR,
  30. IDC_CNSL_COLOR_3, IDH_CONSOLE_COLOR_COLOR_BAR,
  31. IDC_CNSL_COLOR_4, IDH_CONSOLE_COLOR_COLOR_BAR,
  32. IDC_CNSL_COLOR_5, IDH_CONSOLE_COLOR_COLOR_BAR,
  33. IDC_CNSL_COLOR_6, IDH_CONSOLE_COLOR_COLOR_BAR,
  34. IDC_CNSL_COLOR_7, IDH_CONSOLE_COLOR_COLOR_BAR,
  35. IDC_CNSL_COLOR_8, IDH_CONSOLE_COLOR_COLOR_BAR,
  36. IDC_CNSL_COLOR_9, IDH_CONSOLE_COLOR_COLOR_BAR,
  37. IDC_CNSL_COLOR_10, IDH_CONSOLE_COLOR_COLOR_BAR,
  38. IDC_CNSL_COLOR_11, IDH_CONSOLE_COLOR_COLOR_BAR,
  39. IDC_CNSL_COLOR_12, IDH_CONSOLE_COLOR_COLOR_BAR,
  40. IDC_CNSL_COLOR_13, IDH_CONSOLE_COLOR_COLOR_BAR,
  41. IDC_CNSL_COLOR_14, IDH_CONSOLE_COLOR_COLOR_BAR,
  42. IDC_CNSL_COLOR_15, IDH_CONSOLE_COLOR_COLOR_BAR,
  43. IDC_CNSL_COLOR_16, IDH_CONSOLE_COLOR_COLOR_BAR,
  44. IDC_CNSL_GROUP0, -1,
  45. IDC_CNSL_GROUP1, -1,
  46. IDC_CNSL_GROUP2, -1,
  47. 0, 0
  48. };
  49. const static DWORD rgdwHelpSettings[] = {
  50. IDC_CNSL_HISTORY_NUM_LBL, IDH_CONSOLE_OPTIONS_BUFF_NUM,
  51. IDC_CNSL_HISTORY_NUM, IDH_CONSOLE_OPTIONS_BUFF_NUM,
  52. IDC_CNSL_HISTORY_SIZE_LBL, IDH_CONSOLE_OPTIONS_BUFF_SIZE,
  53. IDC_CNSL_HISTORY_SIZE, IDH_CONSOLE_OPTIONS_BUFF_SIZE,
  54. IDC_CNSL_CURSOR_SMALL, IDH_CONSOLE_OPTIONS_CURSOR,
  55. IDC_CNSL_CURSOR_LARGE, IDH_CONSOLE_OPTIONS_CURSOR,
  56. IDC_CNSL_CURSOR_MEDIUM, IDH_CONSOLE_OPTIONS_CURSOR,
  57. IDC_CNSL_HISTORY_NODUP, IDH_CONSOLE_OPTIONS_DISCARD_DUPS,
  58. IDC_CNSL_INSERT, IDH_CONSOLE_OPTIONS_INSERT,
  59. IDC_CNSL_QUICKEDIT, IDH_CONSOLE_OPTIONS_QUICK_EDIT,
  60. IDC_CNSL_LANGUAGELIST, IDH_CONSOLE_OPTIONS_LANGUAGE,
  61. IDC_CNSL_FULLSCREEN, IDH_DOS_SCREEN_USAGE_FULL,
  62. IDC_CNSL_WINDOWED, IDH_DOS_SCREEN_USAGE_WINDOW,
  63. IDC_CNSL_GROUP0, -1,
  64. IDC_CNSL_GROUP1, -1,
  65. IDC_CNSL_GROUP2, -1,
  66. 0, 0
  67. };
  68. const static DWORD rgdwHelpSize[] = {
  69. IDC_CNSL_SCRBUF_WIDTH_LBL, IDH_CONSOLE_SIZE_BUFF_WIDTH,
  70. IDC_CNSL_SCRBUF_WIDTH, IDH_CONSOLE_SIZE_BUFF_WIDTH,
  71. IDC_CNSL_SCRBUF_HEIGHT_LBL, IDH_CONSOLE_SIZE_BUFF_HEIGHT,
  72. IDC_CNSL_SCRBUF_HEIGHT, IDH_CONSOLE_SIZE_BUFF_HEIGHT,
  73. IDC_CNSL_WINDOW_WIDTH_LBL, IDH_CONSOLE_SIZE_WIN_WIDTH,
  74. IDC_CNSL_WINDOW_WIDTH, IDH_CONSOLE_SIZE_WIN_WIDTH,
  75. IDC_CNSL_WINDOW_HEIGHT_LBL, IDH_CONSOLE_SIZE_WIN_HEIGHT,
  76. IDC_CNSL_WINDOW_HEIGHT, IDH_CONSOLE_SIZE_WIN_HEIGHT,
  77. IDC_CNSL_WINDOW_POSX_LBL, IDH_CONSOLE_SIZE_POS_LEFT,
  78. IDC_CNSL_WINDOW_POSX, IDH_CONSOLE_SIZE_POS_LEFT,
  79. IDC_CNSL_WINDOW_POSY_LBL, IDH_CONSOLE_SIZE_POS_TOP,
  80. IDC_CNSL_WINDOW_POSY, IDH_CONSOLE_SIZE_POS_TOP,
  81. IDC_CNSL_AUTO_POSITION, IDH_CONSOLE_SIZE_LET_SYS,
  82. IDC_CNSL_PREVIEWLABEL, IDH_DOS_FONT_WINDOW_PREVIEW,
  83. IDC_CNSL_PREVIEWWINDOW, IDH_DOS_FONT_WINDOW_PREVIEW,
  84. IDC_CNSL_GROUP0, -1,
  85. IDC_CNSL_GROUP1, -1,
  86. IDC_CNSL_GROUP2, -1,
  87. 0, 0
  88. };
  89. #ifdef ADVANCED_PAGE
  90. VOID
  91. _AddEnvVariable(
  92. HWND hwndLV,
  93. INT iItem,
  94. LPTSTR pszVar
  95. )
  96. {
  97. TCHAR szTemp[ 1024 ];
  98. LV_ITEM lvi;
  99. LPTSTR p;
  100. for( p = szTemp; *pszVar!=TEXT('='); *p++ = *pszVar++ );
  101. *p = TEXT('\0');
  102. pszVar++;
  103. lvi.mask = LVIF_TEXT;
  104. lvi.iItem = iItem;
  105. lvi.iSubItem = 0;
  106. lvi.pszText = szTemp;
  107. SendMessage( hwndLV, LVM_SETITEM, 0, (LPARAM)&lvi );
  108. for( p=szTemp; *pszVar!=TEXT('\0'); *p++ = *pszVar++ );
  109. *p = TEXT('\0');
  110. lvi.mask = LVIF_TEXT;
  111. lvi.iItem = iItem;
  112. lvi.iSubItem = 1;
  113. lvi.pszText = szTemp;
  114. SendMessage( hwndLV, LVM_SETITEM, 0, (LPARAM)&lvi );
  115. }
  116. BOOL_PTR
  117. CALLBACK
  118. _AdvancedDlgProc(
  119. HWND hDlg,
  120. UINT wMsg,
  121. WPARAM wParam,
  122. LPARAM lParam
  123. )
  124. /*++
  125. Dialog proc for the settings dialog box.
  126. --*/
  127. {
  128. UINT Item;
  129. HWND hWnd;
  130. RECT r;
  131. LV_COLUMN lvc;
  132. HWND hwndLV;
  133. LPTSTR pszEnv, pszSave;
  134. LV_ITEM lvi;
  135. INT i;
  136. LINKDATA *pld = (LINKDATA *)GetWindowLongPtr(hDlg, DWLP_USER);
  137. switch (wMsg) {
  138. case WM_INITDIALOG:
  139. pld = (LINKDATA *)((PROPSHEETPAGE *)lParam)->lParam;
  140. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)pld);
  141. // Initialize Columns in listview
  142. hwndLV = GetDlgItem( hDlg, IDC_CNSL_ADVANCED_LISTVIEW );
  143. GetClientRect( hwndLV, &r );
  144. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  145. lvc.fmt = LVCFMT_LEFT;
  146. lvc.cx = (((r.right - r.left) - GetSystemMetrics(SM_CXVSCROLL)) * 7) / 20;
  147. lvc.pszText = TEXT("Variable Name");
  148. ListView_InsertColumn( hwndLV, 0, &lvc );
  149. lvc.cx = (((r.right - r.left) - GetSystemMetrics(SM_CXVSCROLL)) * 13) / 20;
  150. lvc.pszText = TEXT("Value");
  151. ListView_InsertColumn( hwndLV, 1, &lvc );
  152. ZeroMemory( &lvi, sizeof(lvi) );
  153. pszSave = pszEnv = GetEnvironmentStrings();
  154. while (pszEnv && *pszEnv)
  155. {
  156. i = SendMessage( hwndLV, LVM_INSERTITEM, 0, (LPARAM)&lvi );
  157. _AddEnvVariable( hwndLV, i, pszEnv );
  158. for( ; *pszEnv; pszEnv++ )
  159. {
  160. // do nothing
  161. }
  162. pszEnv++;
  163. }
  164. FreeEnvironmentStrings( pszSave );
  165. return TRUE;
  166. case WM_DESTROY:
  167. EndDialog( hDlg, TRUE );
  168. break;
  169. case WM_COMMAND:
  170. Item = LOWORD(wParam);
  171. switch (Item)
  172. {
  173. default:
  174. break;
  175. }
  176. break;
  177. case WM_NOTIFY:
  178. switch (((LPNMHDR)lParam)->code) {
  179. case PSN_APPLY:
  180. /*
  181. * Write out the state values and exit.
  182. */
  183. if (FAILED(SaveLink(pld)))
  184. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  185. break;
  186. case PSN_KILLACTIVE:
  187. /*
  188. * Fake the dialog proc into thinking the edit control just
  189. * lost focus so it'll update properly
  190. */
  191. if (Item = GetDlgCtrlID(GetFocus())) {
  192. SendMessage(hDlg, WM_COMMAND, MAKELONG(Item, EN_KILLFOCUS), 0);
  193. }
  194. return TRUE;
  195. }
  196. break;
  197. default:
  198. break;
  199. }
  200. return FALSE;
  201. }
  202. #endif // ADVANCED_PAGE
  203. LRESULT
  204. ColorControlProc(
  205. HWND hColor,
  206. UINT wMsg,
  207. WPARAM wParam,
  208. LPARAM lParam
  209. )
  210. /*++
  211. Window proc for the color buttons
  212. --*/
  213. {
  214. PAINTSTRUCT ps;
  215. int ColorId;
  216. RECT rColor;
  217. RECT rTemp;
  218. HBRUSH hbr;
  219. HDC hdc;
  220. HWND hWnd;
  221. HWND hDlg;
  222. COLORREF rgbBrush;
  223. CONSOLEPROP_DATA * pcpd = (CONSOLEPROP_DATA *)GetWindowLongPtr( hColor, 0 );
  224. ColorId = GetWindowLong(hColor, GWL_ID);
  225. hDlg = GetParent(hColor);
  226. switch (wMsg) {
  227. case CM_COLOR_INIT:
  228. SetWindowLongPtr( hColor, 0, lParam );
  229. break;
  230. case WM_GETDLGCODE:
  231. return DLGC_WANTARROWS | DLGC_WANTTAB;
  232. break;
  233. case WM_SETFOCUS:
  234. if (pcpd->ColorArray[pcpd->Index] != (BYTE)(ColorId - IDC_CNSL_COLOR_1)) {
  235. hWnd = GetDlgItem(hDlg, pcpd->ColorArray[pcpd->Index]+IDC_CNSL_COLOR_1);
  236. SetFocus(hWnd);
  237. }
  238. // Fall through
  239. case WM_KILLFOCUS:
  240. hdc = GetDC(hDlg);
  241. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_1);
  242. GetWindowRect(hWnd, &rColor);
  243. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_16);
  244. GetWindowRect(hWnd, &rTemp);
  245. rColor.right = rTemp.right;
  246. ScreenToClient(hDlg, (LPPOINT)&rColor.left);
  247. ScreenToClient(hDlg, (LPPOINT)&rColor.right);
  248. InflateRect(&rColor, 2, 2);
  249. DrawFocusRect(hdc, &rColor);
  250. ReleaseDC(hDlg, hdc);
  251. break;
  252. case WM_KEYDOWN:
  253. switch (wParam) {
  254. case VK_UP:
  255. case VK_LEFT:
  256. if (ColorId > IDC_CNSL_COLOR_1) {
  257. SendMessage(hDlg, CM_SETCOLOR,
  258. ColorId - 1 - IDC_CNSL_COLOR_1, (LPARAM)hColor);
  259. }
  260. break;
  261. case VK_DOWN:
  262. case VK_RIGHT:
  263. if (ColorId < IDC_CNSL_COLOR_16) {
  264. SendMessage(hDlg, CM_SETCOLOR,
  265. ColorId + 1 - IDC_CNSL_COLOR_1, (LPARAM)hColor);
  266. }
  267. break;
  268. case VK_TAB:
  269. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_1);
  270. hWnd = GetNextDlgTabItem(hDlg, hWnd, GetKeyState(VK_SHIFT) < 0);
  271. SetFocus(hWnd);
  272. break;
  273. default:
  274. return DefWindowProc(hColor, wMsg, wParam, lParam);
  275. }
  276. break;
  277. case WM_RBUTTONDOWN:
  278. case WM_LBUTTONDOWN:
  279. SendMessage(hDlg, CM_SETCOLOR,
  280. ColorId - IDC_CNSL_COLOR_1, (LPARAM)hColor);
  281. break;
  282. case WM_PAINT:
  283. BeginPaint(hColor, &ps);
  284. GetClientRect(hColor, &rColor);
  285. rgbBrush = GetNearestColor(ps.hdc, pcpd->lpConsole->ColorTable[ColorId-IDC_CNSL_COLOR_1]);
  286. if ((hbr = CreateSolidBrush(rgbBrush)) != NULL) {
  287. //
  288. // are we the selected color for the current object?
  289. //
  290. if (pcpd->ColorArray[pcpd->Index] == (BYTE)(ColorId - IDC_CNSL_COLOR_1)) {
  291. //
  292. // put current values in dialog box
  293. //
  294. SendDlgItemMessage(hDlg, IDC_CNSL_COLOR_REDSCROLL, UDM_SETPOS, 0, MAKELONG( GetRValue(AttrToRGB(pcpd->ColorArray[pcpd->Index])),0));
  295. SendDlgItemMessage(hDlg, IDC_CNSL_COLOR_GREENSCROLL, UDM_SETPOS, 0, MAKELONG( GetGValue(AttrToRGB(pcpd->ColorArray[pcpd->Index])),0));
  296. SendDlgItemMessage(hDlg, IDC_CNSL_COLOR_BLUESCROLL, UDM_SETPOS, 0, MAKELONG( GetBValue(AttrToRGB(pcpd->ColorArray[pcpd->Index])),0));
  297. //
  298. // highlight the selected color
  299. //
  300. FrameRect(ps.hdc, &rColor, GetStockObject(BLACK_BRUSH));
  301. InflateRect(&rColor, -1, -1);
  302. FrameRect(ps.hdc, &rColor, GetStockObject(BLACK_BRUSH));
  303. }
  304. InflateRect(&rColor, -1, -1);
  305. FillRect(ps.hdc, &rColor, hbr);
  306. DeleteObject(hbr);
  307. }
  308. EndPaint(hColor, &ps);
  309. break;
  310. default:
  311. return DefWindowProc(hColor, wMsg, wParam, lParam);
  312. break;
  313. }
  314. return TRUE;
  315. }
  316. LRESULT
  317. ColorTextProc(
  318. HWND hWnd,
  319. UINT wMsg,
  320. WPARAM wParam,
  321. LPARAM lParam
  322. )
  323. /*++
  324. Window proc for the color preview windows
  325. --*/
  326. {
  327. PAINTSTRUCT ps;
  328. int ColorId;
  329. RECT rect;
  330. HBRUSH hbr;
  331. HFONT hfT;
  332. CONSOLEPROP_DATA * pcpd = (CONSOLEPROP_DATA *)GetWindowLongPtr( hWnd, 0 );
  333. ColorId = GetWindowLong(hWnd, GWL_ID);
  334. switch (wMsg) {
  335. case CM_COLOR_INIT:
  336. SetWindowLongPtr( hWnd, 0, lParam );
  337. break;
  338. case WM_PAINT:
  339. BeginPaint(hWnd, &ps);
  340. GetClientRect(hWnd, &rect);
  341. InflateRect(&rect, -2, -2);
  342. if (ColorId == IDC_CNSL_COLOR_SCREEN_COLORS) {
  343. SetTextColor(ps.hdc, ScreenTextColor(pcpd));
  344. SetBkColor(ps.hdc, ScreenBkColor(pcpd));
  345. hbr = CreateSolidBrush( ScreenBkColor(pcpd) );
  346. } else {
  347. SetTextColor(ps.hdc, PopupTextColor(pcpd));
  348. SetBkColor(ps.hdc, PopupBkColor(pcpd));
  349. hbr = CreateSolidBrush( PopupBkColor(pcpd) );
  350. }
  351. /* Draw the text sample */
  352. if (hbr)
  353. {
  354. FillRect(ps.hdc, &rect, hbr);
  355. DeleteObject(hbr);
  356. }
  357. hfT = SelectObject(ps.hdc, pcpd->FontInfo[pcpd->CurrentFontIndex].hFont);
  358. DrawText(ps.hdc, g_szPreviewText, -1, &rect, 0);
  359. SelectObject(ps.hdc, hfT);
  360. EndPaint(hWnd, &ps);
  361. break;
  362. default:
  363. return DefWindowProc(hWnd, wMsg, wParam, lParam);
  364. break;
  365. }
  366. return TRUE;
  367. }
  368. BOOL_PTR
  369. WINAPI
  370. _ColorDlgProc(
  371. HWND hDlg,
  372. UINT wMsg,
  373. WPARAM wParam,
  374. LPARAM lParam
  375. )
  376. /*++
  377. Dialog proc for the color selection dialog box.
  378. --*/
  379. {
  380. UINT Value;
  381. UINT Red;
  382. UINT Green;
  383. UINT Blue;
  384. UINT Item;
  385. HWND hWnd;
  386. HWND hWndOld;
  387. BOOL bOK;
  388. LINKDATA *pld = (LINKDATA *)GetWindowLongPtr(hDlg, DWLP_USER);
  389. switch (wMsg) {
  390. case WM_INITDIALOG:
  391. pld = (LINKDATA *)((PROPSHEETPAGE *)lParam)->lParam;
  392. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)pld);
  393. pld->cpd.bColorInit = FALSE;
  394. pld->cpd.ColorArray[IDC_CNSL_COLOR_SCREEN_TEXT - IDC_CNSL_COLOR_SCREEN_TEXT] =
  395. LOBYTE(pld->cpd.lpConsole->wFillAttribute) & 0x0F;
  396. pld->cpd.ColorArray[IDC_CNSL_COLOR_SCREEN_BKGND - IDC_CNSL_COLOR_SCREEN_TEXT] =
  397. LOBYTE(pld->cpd.lpConsole->wFillAttribute >> 4);
  398. pld->cpd.ColorArray[IDC_CNSL_COLOR_POPUP_TEXT - IDC_CNSL_COLOR_SCREEN_TEXT] =
  399. LOBYTE(pld->cpd.lpConsole->wPopupFillAttribute) & 0x0F;
  400. pld->cpd.ColorArray[IDC_CNSL_COLOR_POPUP_BKGND - IDC_CNSL_COLOR_SCREEN_TEXT] =
  401. LOBYTE(pld->cpd.lpConsole->wPopupFillAttribute >> 4);
  402. CheckRadioButton(hDlg,IDC_CNSL_COLOR_SCREEN_TEXT,IDC_CNSL_COLOR_POPUP_BKGND,IDC_CNSL_COLOR_SCREEN_BKGND);
  403. pld->cpd.Index = IDC_CNSL_COLOR_SCREEN_BKGND - IDC_CNSL_COLOR_SCREEN_TEXT;
  404. // initialize color controls
  405. for (Item=IDC_CNSL_COLOR_1; Item<=IDC_CNSL_COLOR_16; Item++)
  406. SendDlgItemMessage(hDlg, Item, CM_COLOR_INIT, 0, (LPARAM)&pld->cpd );
  407. // initialize text preview controls
  408. SendDlgItemMessage(hDlg, IDC_CNSL_COLOR_SCREEN_COLORS, CM_COLOR_INIT, 0, (LPARAM)&pld->cpd );
  409. SendDlgItemMessage(hDlg, IDC_CNSL_COLOR_POPUP_COLORS, CM_COLOR_INIT, 0, (LPARAM)&pld->cpd );
  410. // Set ranges & position for updown controls
  411. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_REDSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 255, 0 ) );
  412. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_GREENSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 255, 0 ) );
  413. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_BLUESCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 255, 0 ) );
  414. #define pcpd (&pld->cpd)
  415. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_REDSCROLL, UDM_SETPOS, 0,
  416. (LPARAM)MAKELONG(GetRValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index])), 0 ) );
  417. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_GREENSCROLL, UDM_SETPOS, 0,
  418. (LPARAM)MAKELONG(GetGValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index])), 0 ) );
  419. SendDlgItemMessage( hDlg, IDC_CNSL_COLOR_BLUESCROLL, UDM_SETPOS, 0,
  420. (LPARAM)MAKELONG(GetBValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index])), 0 ) );
  421. #undef pcpd
  422. pld->cpd.bColorInit = TRUE;
  423. return TRUE;
  424. //
  425. // handle help messages
  426. //
  427. case WM_HELP: /* F1 or title-bar help button */
  428. WinHelp( (HWND) ((LPHELPINFO) lParam)->hItemHandle,
  429. NULL,
  430. HELP_WM_HELP,
  431. (ULONG_PTR) (LPVOID) &rgdwHelpColor[0]
  432. );
  433. break;
  434. case WM_CONTEXTMENU: /* right mouse click */
  435. WinHelp( (HWND) wParam,
  436. NULL,
  437. HELP_CONTEXTMENU,
  438. (ULONG_PTR) (LPVOID) &rgdwHelpColor[0]
  439. );
  440. break;
  441. case WM_COMMAND:
  442. Item = LOWORD(wParam);
  443. switch (Item)
  444. {
  445. case IDC_CNSL_COLOR_SCREEN_TEXT:
  446. case IDC_CNSL_COLOR_SCREEN_BKGND:
  447. case IDC_CNSL_COLOR_POPUP_TEXT:
  448. case IDC_CNSL_COLOR_POPUP_BKGND:
  449. hWndOld = GetDlgItem(hDlg, pld->cpd.ColorArray[pld->cpd.Index]+IDC_CNSL_COLOR_1);
  450. pld->cpd.Index = Item - IDC_CNSL_COLOR_SCREEN_TEXT;
  451. CheckRadioButton(hDlg,IDC_CNSL_COLOR_SCREEN_TEXT,IDC_CNSL_COLOR_POPUP_BKGND,Item);
  452. // repaint new color
  453. hWnd = GetDlgItem(hDlg, pld->cpd.ColorArray[pld->cpd.Index]+IDC_CNSL_COLOR_1);
  454. InvalidateRect(hWnd, NULL, TRUE);
  455. // repaint old color
  456. if (hWndOld != hWnd)
  457. {
  458. InvalidateRect(hWndOld, NULL, TRUE);
  459. }
  460. return TRUE;
  461. case IDC_CNSL_COLOR_RED:
  462. case IDC_CNSL_COLOR_GREEN:
  463. case IDC_CNSL_COLOR_BLUE:
  464. switch (HIWORD(wParam))
  465. {
  466. case EN_UPDATE:
  467. Value = GetDlgItemInt(hDlg, Item, &bOK, TRUE);
  468. if (bOK)
  469. {
  470. if (Value > 255) {
  471. Value = 255;
  472. SetDlgItemInt( hDlg, Item, Value, TRUE );
  473. }
  474. if ((int)Value < 0) {
  475. Value = 0;
  476. SetDlgItemInt( hDlg, Item, Value, TRUE );
  477. }
  478. }
  479. if (pld)
  480. pld->cpd.bConDirty = TRUE;
  481. PropSheet_Changed( GetParent( hDlg ), hDlg );
  482. break;
  483. case EN_KILLFOCUS:
  484. if (!pld)
  485. return FALSE;
  486. //
  487. // Update the state info structure
  488. //
  489. #define pcpd (&pld->cpd)
  490. Value = GetDlgItemInt(hDlg, Item, &bOK, TRUE);
  491. if (bOK)
  492. {
  493. if (Value > 255) {
  494. Value = 255;
  495. SetDlgItemInt( hDlg, Item, Value, TRUE );
  496. }
  497. if ((int)Value < 0) {
  498. Value = 0;
  499. SetDlgItemInt( hDlg, Item, Value, TRUE );
  500. }
  501. if (Item == IDC_CNSL_COLOR_RED) {
  502. Red = Value;
  503. } else {
  504. Red = GetRValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index]));
  505. }
  506. if (Item == IDC_CNSL_COLOR_GREEN) {
  507. Green = Value;
  508. } else {
  509. Green = GetGValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index]));
  510. }
  511. if (Item == IDC_CNSL_COLOR_BLUE) {
  512. Blue = Value;
  513. } else {
  514. Blue = GetBValue(AttrToRGB(pld->cpd.ColorArray[pld->cpd.Index]));
  515. }
  516. pld->cpd.lpConsole->ColorTable[pld->cpd.ColorArray[pld->cpd.Index]] =
  517. RGB(Red, Green, Blue);
  518. }
  519. #undef pcpd
  520. //
  521. // Update the preview windows with the new value
  522. //
  523. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_SCREEN_COLORS);
  524. InvalidateRect(hWnd, NULL, FALSE);
  525. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_POPUP_COLORS);
  526. InvalidateRect(hWnd, NULL, FALSE);
  527. hWnd = GetDlgItem(hDlg, pld->cpd.ColorArray[pld->cpd.Index]+IDC_CNSL_COLOR_1);
  528. InvalidateRect(hWnd, NULL, FALSE);
  529. break;
  530. }
  531. return TRUE;
  532. }
  533. break;
  534. case WM_NOTIFY:
  535. switch (((LPNMHDR)lParam)->code) {
  536. case PSN_APPLY:
  537. /*
  538. * Write out the state values and exit.
  539. */
  540. if (FAILED(SaveLink(pld)))
  541. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  542. break;
  543. }
  544. break;
  545. case WM_VSCROLL:
  546. // minus 1 because edit control precedes the updown control in the .rc file
  547. Item = GetDlgCtrlID( (HWND)lParam ) - 1;
  548. switch (LOWORD(wParam)) {
  549. case SB_ENDSCROLL:
  550. SendDlgItemMessage(hDlg, Item, EM_SETSEL, 0, (DWORD)-1);
  551. break;
  552. default:
  553. /*
  554. * Get the new value for the control
  555. */
  556. Value = GetDlgItemInt(hDlg, Item, &bOK, TRUE);
  557. SendDlgItemMessage(hDlg, Item, EM_SETSEL, 0, (DWORD)-1);
  558. hWnd = GetDlgItem(hDlg, Item);
  559. SetFocus(hWnd);
  560. /*
  561. * Fake the dialog proc into thinking the edit control just
  562. * lost focus so it'll update properly
  563. */
  564. SendMessage(hDlg, WM_COMMAND, MAKELONG(Item, EN_KILLFOCUS), 0);
  565. pld->cpd.bConDirty = TRUE;
  566. PropSheet_Changed( GetParent( hDlg ), hDlg );
  567. break;
  568. }
  569. return TRUE;
  570. case CM_SETCOLOR:
  571. switch( pld->cpd.Index + IDC_CNSL_COLOR_SCREEN_TEXT )
  572. {
  573. case IDC_CNSL_COLOR_SCREEN_TEXT:
  574. pld->cpd.lpConsole->wFillAttribute = (WORD)
  575. ((pld->cpd.lpConsole->wFillAttribute & 0xF0) |
  576. (wParam & 0x0F));
  577. break;
  578. case IDC_CNSL_COLOR_SCREEN_BKGND:
  579. pld->cpd.lpConsole->wFillAttribute = (WORD)
  580. ((pld->cpd.lpConsole->wFillAttribute & 0x0F) |
  581. (wParam << 4));
  582. break;
  583. case IDC_CNSL_COLOR_POPUP_TEXT:
  584. pld->cpd.lpConsole->wPopupFillAttribute = (WORD)
  585. ((pld->cpd.lpConsole->wPopupFillAttribute & 0xF0) |
  586. (wParam & 0x0F));
  587. break;
  588. case IDC_CNSL_COLOR_POPUP_BKGND:
  589. pld->cpd.lpConsole->wPopupFillAttribute = (WORD)
  590. ((pld->cpd.lpConsole->wPopupFillAttribute & 0x0F) |
  591. (wParam << 4));
  592. break;
  593. }
  594. hWndOld = GetDlgItem(hDlg, pld->cpd.ColorArray[pld->cpd.Index]+IDC_CNSL_COLOR_1);
  595. pld->cpd.ColorArray[pld->cpd.Index] = (BYTE)wParam;
  596. pld->cpd.bConDirty = TRUE;
  597. PropSheet_Changed( GetParent( hDlg ), hDlg );
  598. // Force the preview window to repaint
  599. if (pld->cpd.Index < (IDC_CNSL_COLOR_POPUP_TEXT - IDC_CNSL_COLOR_SCREEN_TEXT)) {
  600. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_SCREEN_COLORS);
  601. } else {
  602. hWnd = GetDlgItem(hDlg, IDC_CNSL_COLOR_POPUP_COLORS);
  603. }
  604. InvalidateRect(hWnd, NULL, TRUE);
  605. // repaint new color
  606. hWnd = GetDlgItem(hDlg, pld->cpd.ColorArray[pld->cpd.Index]+IDC_CNSL_COLOR_1);
  607. InvalidateRect(hWnd, NULL, TRUE);
  608. SetFocus(hWnd);
  609. // repaint old color
  610. if (hWndOld != hWnd) {
  611. InvalidateRect(hWndOld, NULL, TRUE);
  612. }
  613. return TRUE;
  614. default:
  615. break;
  616. }
  617. return FALSE;
  618. }
  619. BOOL_PTR
  620. CALLBACK
  621. _ConsoleSettingsDlgProc(
  622. HWND hDlg,
  623. UINT wMsg,
  624. WPARAM wParam,
  625. LPARAM lParam
  626. )
  627. /*++
  628. Dialog proc for the settings dialog box.
  629. --*/
  630. {
  631. UINT Item;
  632. SYSTEM_INFO SystemInfo;
  633. LINKDATA *pld = (LINKDATA *)GetWindowLongPtr(hDlg, DWLP_USER);
  634. switch (wMsg) {
  635. case WM_INITDIALOG:
  636. pld = (LINKDATA *)((PROPSHEETPAGE *)lParam)->lParam;
  637. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)pld);
  638. GetSystemInfo(&SystemInfo);
  639. if (SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {
  640. if (pld->cpd.lpConsole->bFullScreen)
  641. CheckRadioButton(hDlg,IDC_CNSL_WINDOWED,IDC_CNSL_FULLSCREEN,IDC_CNSL_FULLSCREEN);
  642. else
  643. CheckRadioButton(hDlg,IDC_CNSL_WINDOWED,IDC_CNSL_FULLSCREEN,IDC_CNSL_WINDOWED);
  644. } else {
  645. ShowWindow(GetDlgItem(hDlg, IDC_CNSL_WINDOWED), SW_HIDE);
  646. ShowWindow(GetDlgItem(hDlg, IDC_CNSL_FULLSCREEN), SW_HIDE);
  647. ShowWindow(GetDlgItem(hDlg, IDC_CNSL_GROUP2), SW_HIDE);
  648. }
  649. CheckDlgButton(hDlg, IDC_CNSL_HISTORY_NODUP, pld->cpd.lpConsole->bHistoryNoDup);
  650. CheckDlgButton(hDlg, IDC_CNSL_QUICKEDIT, pld->cpd.lpConsole->bQuickEdit);
  651. CheckDlgButton(hDlg, IDC_CNSL_INSERT, pld->cpd.lpConsole->bInsertMode);
  652. // initialize cursor radio buttons
  653. if (pld->cpd.lpConsole->uCursorSize <= 25)
  654. {
  655. Item = IDC_CNSL_CURSOR_SMALL;
  656. }
  657. else if (pld->cpd.lpConsole->uCursorSize <= 50)
  658. {
  659. Item = IDC_CNSL_CURSOR_MEDIUM;
  660. }
  661. else
  662. {
  663. Item = IDC_CNSL_CURSOR_LARGE;
  664. }
  665. CheckRadioButton(hDlg, IDC_CNSL_CURSOR_SMALL, IDC_CNSL_CURSOR_LARGE, Item);
  666. // initialize updown controls
  667. SendDlgItemMessage( hDlg, IDC_CNSL_HISTORY_SIZESCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 999, 1 ) );
  668. SendDlgItemMessage( hDlg, IDC_CNSL_HISTORY_NUMSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 999, 1 ) );
  669. //
  670. // put current values in dialog box
  671. //
  672. SendDlgItemMessage( hDlg, IDC_CNSL_HISTORY_SIZESCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->uHistoryBufferSize, 0 ) );
  673. SendDlgItemMessage( hDlg, IDC_CNSL_HISTORY_NUMSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->uNumberOfHistoryBuffers, 0 ) );
  674. if (IsFarEastCP(pld->cpd.uOEMCP))
  675. LanguageListCreate(hDlg, pld->cpd.lpFEConsole->uCodePage);
  676. else
  677. {
  678. ShowWindow(GetDlgItem(hDlg, IDC_CNSL_GROUP3), SW_HIDE);
  679. ShowWindow(GetDlgItem(hDlg, IDC_CNSL_LANGUAGELIST), SW_HIDE);
  680. }
  681. return TRUE;
  682. case WM_DESTROY:
  683. EndDialog( hDlg, TRUE );
  684. break;
  685. //
  686. // handle help messages
  687. //
  688. case WM_HELP: /* F1 or title-bar help button */
  689. WinHelp( (HWND) ((LPHELPINFO) lParam)->hItemHandle,
  690. NULL,
  691. HELP_WM_HELP,
  692. (ULONG_PTR) (LPVOID) &rgdwHelpSettings[0]
  693. );
  694. break;
  695. case WM_CONTEXTMENU: /* right mouse click */
  696. WinHelp( (HWND) wParam,
  697. NULL,
  698. HELP_CONTEXTMENU,
  699. (ULONG_PTR) (LPVOID) &rgdwHelpSettings[0]
  700. );
  701. break;
  702. case WM_COMMAND:
  703. Item = LOWORD(wParam);
  704. switch (Item)
  705. {
  706. case IDC_CNSL_HISTORY_SIZE:
  707. if (pld && (HIWORD(wParam)==EN_UPDATE))
  708. {
  709. pld->cpd.lpConsole->uHistoryBufferSize =
  710. GetDlgItemInt( hDlg, Item, NULL, FALSE );
  711. pld->cpd.bConDirty = TRUE;
  712. PropSheet_Changed( GetParent( hDlg ), hDlg );
  713. }
  714. break;
  715. case IDC_CNSL_HISTORY_NUM:
  716. if (pld && (HIWORD(wParam)==EN_UPDATE))
  717. {
  718. pld->cpd.lpConsole->uNumberOfHistoryBuffers =
  719. GetDlgItemInt( hDlg, Item, NULL, FALSE );
  720. pld->cpd.bConDirty = TRUE;
  721. PropSheet_Changed( GetParent( hDlg ), hDlg );
  722. }
  723. break;
  724. #ifdef i386
  725. case IDC_CNSL_WINDOWED:
  726. case IDC_CNSL_FULLSCREEN:
  727. CheckRadioButton(hDlg, IDC_CNSL_WINDOWED, IDC_CNSL_FULLSCREEN, Item);
  728. pld->cpd.lpConsole->bFullScreen = (Item == IDC_CNSL_FULLSCREEN);
  729. pld->cpd.bConDirty = TRUE;
  730. PropSheet_Changed( GetParent( hDlg ), hDlg );
  731. return TRUE;
  732. #endif
  733. case IDC_CNSL_LANGUAGELIST:
  734. switch (HIWORD(wParam)) {
  735. case CBN_KILLFOCUS: {
  736. HWND hWndLanguageCombo;
  737. LONG lListIndex;
  738. UINT Value;
  739. hWndLanguageCombo = GetDlgItem(hDlg, IDC_CNSL_LANGUAGELIST);
  740. lListIndex = (LONG) SendMessage(hWndLanguageCombo, CB_GETCURSEL, 0, 0L);
  741. Value = (UINT) SendMessage(hWndLanguageCombo, CB_GETITEMDATA, lListIndex, 0L);
  742. if (Value != (UINT)-1) {
  743. pld->cpd.fChangeCodePage = (Value != pld->cpd.lpFEConsole->uCodePage);
  744. pld->cpd.lpFEConsole->uCodePage = Value;
  745. PropSheet_Changed( GetParent( hDlg ), hDlg );
  746. }
  747. break;
  748. }
  749. default:
  750. break;
  751. }
  752. return TRUE;
  753. case IDC_CNSL_CURSOR_SMALL:
  754. pld->cpd.lpConsole->uCursorSize = 25;
  755. goto SetCursorSize;
  756. case IDC_CNSL_CURSOR_MEDIUM:
  757. pld->cpd.lpConsole->uCursorSize = 50;
  758. goto SetCursorSize;
  759. case IDC_CNSL_CURSOR_LARGE:
  760. pld->cpd.lpConsole->uCursorSize = 100;
  761. SetCursorSize:
  762. pld->cpd.bConDirty = TRUE;
  763. PropSheet_Changed( GetParent( hDlg ), hDlg );
  764. CheckRadioButton(hDlg, IDC_CNSL_CURSOR_SMALL, IDC_CNSL_CURSOR_LARGE, Item);
  765. return TRUE;
  766. case IDC_CNSL_HISTORY_NODUP:
  767. pld->cpd.lpConsole->bHistoryNoDup = IsDlgButtonChecked( hDlg, Item );
  768. pld->cpd.bConDirty = TRUE;
  769. PropSheet_Changed( GetParent( hDlg ), hDlg );
  770. return TRUE;
  771. case IDC_CNSL_QUICKEDIT:
  772. pld->cpd.lpConsole->bQuickEdit = IsDlgButtonChecked( hDlg, Item );
  773. pld->cpd.bConDirty = TRUE;
  774. PropSheet_Changed( GetParent( hDlg ), hDlg );
  775. return TRUE;
  776. case IDC_CNSL_INSERT:
  777. pld->cpd.lpConsole->bInsertMode = IsDlgButtonChecked( hDlg, Item );
  778. pld->cpd.bConDirty = TRUE;
  779. PropSheet_Changed( GetParent( hDlg ), hDlg );
  780. return TRUE;
  781. default:
  782. break;
  783. }
  784. break;
  785. case WM_NOTIFY:
  786. switch (((LPNMHDR)lParam)->code) {
  787. case PSN_APPLY:
  788. /*
  789. * Write out the state values and exit.
  790. */
  791. if (FAILED(SaveLink(pld)))
  792. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  793. break;
  794. case PSN_KILLACTIVE:
  795. /*
  796. * Fake the dialog proc into thinking the edit control just
  797. * lost focus so it'll update properly
  798. */
  799. if (0 != (Item = GetDlgCtrlID(GetFocus()))) {
  800. SendMessage(hDlg, WM_COMMAND, MAKELONG(Item, EN_KILLFOCUS), 0);
  801. }
  802. return TRUE;
  803. }
  804. break;
  805. default:
  806. break;
  807. }
  808. return FALSE;
  809. }
  810. BOOL
  811. CheckBufferSize(
  812. HWND hDlg,
  813. UINT Item,
  814. LINKDATA *pld,
  815. INT i
  816. )
  817. /*++
  818. Checks to make sure the buffer size is not smaller than the window size
  819. Returns: TRUE if preview window should be updated
  820. FALSE if not
  821. --*/
  822. {
  823. BOOL fRet = FALSE;
  824. if (!pld)
  825. return fRet;
  826. switch (Item)
  827. {
  828. case IDC_CNSL_SCRBUF_WIDTHSCROLL:
  829. case IDC_CNSL_SCRBUF_WIDTH:
  830. if (i >= 1)
  831. {
  832. pld->cpd.lpConsole->dwScreenBufferSize.X = (SHORT) i;
  833. if (pld->cpd.lpConsole->dwWindowSize.X > i)
  834. {
  835. pld->cpd.lpConsole->dwWindowSize.X = (SHORT) i;
  836. SetDlgItemInt( hDlg,
  837. IDC_CNSL_WINDOW_WIDTH,
  838. pld->cpd.lpConsole->dwWindowSize.X,
  839. TRUE
  840. );
  841. fRet = TRUE;
  842. }
  843. }
  844. break;
  845. case IDC_CNSL_SCRBUF_HEIGHTSCROLL:
  846. case IDC_CNSL_SCRBUF_HEIGHT:
  847. if (i >= 1)
  848. {
  849. pld->cpd.lpConsole->dwScreenBufferSize.Y = (SHORT) i;
  850. if (pld->cpd.lpConsole->dwWindowSize.Y > i)
  851. {
  852. pld->cpd.lpConsole->dwWindowSize.Y = (SHORT) i;
  853. SetDlgItemInt( hDlg,
  854. IDC_CNSL_WINDOW_HEIGHT,
  855. pld->cpd.lpConsole->dwWindowSize.Y,
  856. TRUE
  857. );
  858. fRet = TRUE;
  859. }
  860. }
  861. break;
  862. case IDC_CNSL_WINDOW_WIDTHSCROLL:
  863. case IDC_CNSL_WINDOW_WIDTH:
  864. if (i >= 1)
  865. {
  866. pld->cpd.lpConsole->dwWindowSize.X = (SHORT) i;
  867. if (pld->cpd.lpConsole->dwScreenBufferSize.X < i)
  868. {
  869. pld->cpd.lpConsole->dwScreenBufferSize.X = (SHORT) i;
  870. SetDlgItemInt( hDlg,
  871. IDC_CNSL_SCRBUF_WIDTH,
  872. pld->cpd.lpConsole->dwScreenBufferSize.X,
  873. TRUE
  874. );
  875. fRet = TRUE;
  876. }
  877. }
  878. break;
  879. case IDC_CNSL_WINDOW_HEIGHTSCROLL:
  880. case IDC_CNSL_WINDOW_HEIGHT:
  881. if (i >= 1)
  882. {
  883. pld->cpd.lpConsole->dwWindowSize.Y = (SHORT) i;
  884. if (pld->cpd.lpConsole->dwScreenBufferSize.Y < i)
  885. {
  886. pld->cpd.lpConsole->dwScreenBufferSize.Y = (SHORT) i;
  887. SetDlgItemInt( hDlg,
  888. IDC_CNSL_SCRBUF_HEIGHT,
  889. pld->cpd.lpConsole->dwScreenBufferSize.Y,
  890. TRUE
  891. );
  892. fRet = TRUE;
  893. }
  894. }
  895. }
  896. return fRet;
  897. }
  898. BOOL
  899. IsValidSetting(
  900. HWND hDlg,
  901. UINT Item,
  902. LINKDATA *pld,
  903. INT i
  904. )
  905. /*++
  906. Checks to make sure the proposed new value is valid for the console
  907. Returns: TRUE if it is valid
  908. FALSE if not
  909. --*/
  910. {
  911. BOOL fRet = TRUE;
  912. if (!pld)
  913. return FALSE;
  914. if (i>9999)
  915. i = -1;
  916. switch (Item)
  917. {
  918. case IDC_CNSL_WINDOW_HEIGHT:
  919. if (i <= 0)
  920. {
  921. SetDlgItemInt( hDlg,
  922. Item,
  923. pld->cpd.lpConsole->dwWindowSize.Y,
  924. TRUE
  925. );
  926. fRet = FALSE;
  927. }
  928. else
  929. {
  930. pld->cpd.lpConsole->dwWindowSize.Y = (SHORT) i;
  931. }
  932. break;
  933. case IDC_CNSL_WINDOW_WIDTH:
  934. if (i <= 0)
  935. {
  936. SetDlgItemInt( hDlg,
  937. Item,
  938. pld->cpd.lpConsole->dwWindowSize.X,
  939. TRUE
  940. );
  941. fRet = FALSE;
  942. }
  943. else
  944. {
  945. pld->cpd.lpConsole->dwWindowSize.X = (SHORT) i;
  946. }
  947. break;
  948. case IDC_CNSL_SCRBUF_WIDTH:
  949. if (i <= 0)
  950. {
  951. SetDlgItemInt( hDlg,
  952. Item,
  953. pld->cpd.lpConsole->dwScreenBufferSize.X,
  954. TRUE
  955. );
  956. fRet = FALSE;
  957. }
  958. else
  959. {
  960. pld->cpd.lpConsole->dwScreenBufferSize.X = (SHORT) i;
  961. }
  962. break;
  963. case IDC_CNSL_SCRBUF_HEIGHT:
  964. if (i <= 0)
  965. {
  966. SetDlgItemInt( hDlg,
  967. Item,
  968. pld->cpd.lpConsole->dwScreenBufferSize.Y,
  969. TRUE
  970. );
  971. fRet = FALSE;
  972. }
  973. else
  974. {
  975. pld->cpd.lpConsole->dwScreenBufferSize.Y = (SHORT) i;
  976. }
  977. break;
  978. }
  979. if (i <= 0)
  980. {
  981. SendDlgItemMessage( hDlg,
  982. Item,
  983. EM_SETSEL,
  984. (WPARAM)(INT)4,
  985. (WPARAM)(INT)4
  986. );
  987. }
  988. return fRet;
  989. }
  990. BOOL_PTR
  991. CALLBACK
  992. _ScreenSizeDlgProc(
  993. HWND hDlg,
  994. UINT wMsg,
  995. WPARAM wParam,
  996. LPARAM lParam
  997. )
  998. /*++
  999. Dialog proc for the screen size dialog box.
  1000. --*/
  1001. {
  1002. UINT Value;
  1003. UINT Item;
  1004. HWND hWnd;
  1005. LONG xScreen;
  1006. LONG yScreen;
  1007. LONG cxScreen;
  1008. LONG cyScreen;
  1009. LONG cxFrame;
  1010. LONG cyFrame;
  1011. LINKDATA *pld = (LINKDATA *)GetWindowLongPtr(hDlg, DWLP_USER);
  1012. switch (wMsg) {
  1013. case WM_INITDIALOG:
  1014. pld = (LINKDATA *)((PROPSHEETPAGE *)lParam)->lParam;
  1015. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)pld);
  1016. SendDlgItemMessage(hDlg, IDC_CNSL_PREVIEWWINDOW, CM_PREVIEW_INIT, 0, (LPARAM)&pld->cpd );
  1017. SendDlgItemMessage(hDlg, IDC_CNSL_PREVIEWWINDOW, CM_PREVIEW_UPDATE, 0, 0 );
  1018. // Get some system parameters
  1019. xScreen = GetSystemMetrics(SM_XVIRTUALSCREEN);
  1020. yScreen = GetSystemMetrics(SM_YVIRTUALSCREEN);
  1021. cxScreen = GetSystemMetrics(SM_CXVIRTUALSCREEN);
  1022. cyScreen = GetSystemMetrics(SM_CYVIRTUALSCREEN);
  1023. cxFrame = GetSystemMetrics(SM_CXFRAME);
  1024. cyFrame = GetSystemMetrics(SM_CYFRAME);
  1025. // initialize updown controls
  1026. SendDlgItemMessage( hDlg, IDC_CNSL_SCRBUF_WIDTHSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( MAX_SCRBUF_WIDTH, 1 ) );
  1027. SendDlgItemMessage( hDlg, IDC_CNSL_SCRBUF_HEIGHTSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( MAX_SCRBUF_HEIGHT, 1 ) );
  1028. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_WIDTHSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 9999, 1 ) );
  1029. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_HEIGHTSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( 9999, 1 ) );
  1030. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_POSXSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( xScreen + cxScreen - cxFrame, xScreen - cxFrame ) );
  1031. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_POSYSCROLL, UDM_SETRANGE, 0, (LPARAM)MAKELONG( yScreen + cyScreen - cyFrame, yScreen - cyFrame ) );
  1032. //
  1033. // put current values in dialog box
  1034. //
  1035. SendDlgItemMessage( hDlg, IDC_CNSL_SCRBUF_WIDTHSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwScreenBufferSize.X, 0 ) );
  1036. SendDlgItemMessage( hDlg, IDC_CNSL_SCRBUF_HEIGHTSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwScreenBufferSize.Y, 0 ) );
  1037. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_WIDTHSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwWindowSize.X, 0 ) );
  1038. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_HEIGHTSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwWindowSize.Y, 0 ) );
  1039. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_POSXSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwWindowOrigin.X, 0 ) );
  1040. SendDlgItemMessage( hDlg, IDC_CNSL_WINDOW_POSYSCROLL, UDM_SETPOS, 0, (LPARAM)MAKELONG( pld->cpd.lpConsole->dwWindowOrigin.Y, 0 ) );
  1041. CheckDlgButton(hDlg, IDC_CNSL_AUTO_POSITION, pld->cpd.lpConsole->bAutoPosition);
  1042. SendMessage(hDlg, WM_COMMAND, IDC_CNSL_AUTO_POSITION, 0);
  1043. return TRUE;
  1044. case WM_DESTROY:
  1045. EndDialog( hDlg, TRUE );
  1046. break;
  1047. //
  1048. // handle help messages
  1049. //
  1050. case WM_HELP: /* F1 or title-bar help button */
  1051. WinHelp( (HWND) ((LPHELPINFO) lParam)->hItemHandle,
  1052. NULL,
  1053. HELP_WM_HELP,
  1054. (ULONG_PTR) (LPVOID) &rgdwHelpSize[0]
  1055. );
  1056. break;
  1057. case WM_CONTEXTMENU: /* right mouse click */
  1058. WinHelp( (HWND) wParam,
  1059. NULL,
  1060. HELP_CONTEXTMENU,
  1061. (ULONG_PTR) (LPVOID) &rgdwHelpSize[0]
  1062. );
  1063. break;
  1064. case WM_COMMAND:
  1065. Item = LOWORD(wParam);
  1066. if (Item==IDC_CNSL_AUTO_POSITION)
  1067. {
  1068. pld->cpd.lpConsole->bAutoPosition = IsDlgButtonChecked( hDlg, Item );
  1069. pld->cpd.bConDirty = TRUE;
  1070. PropSheet_Changed( GetParent( hDlg ), hDlg );
  1071. Value = IsDlgButtonChecked(hDlg, IDC_CNSL_AUTO_POSITION);
  1072. for (Item = IDC_CNSL_WINDOW_POSX; Item < IDC_CNSL_AUTO_POSITION; Item++) {
  1073. hWnd = GetDlgItem(hDlg, Item);
  1074. EnableWindow(hWnd, (Value == FALSE));
  1075. }
  1076. }
  1077. //
  1078. // Make sure that we don't have a buffer size smaller than a window size
  1079. //
  1080. if (pld && (HIWORD(wParam)==EN_KILLFOCUS))
  1081. {
  1082. INT i;
  1083. i = GetDlgItemInt( hDlg, Item, NULL, FALSE );
  1084. if (CheckBufferSize( hDlg, Item, pld, i ))
  1085. goto UpdatePrevWindow;
  1086. }
  1087. //
  1088. // Verify that what is typed is a valid quantity...
  1089. //
  1090. if (pld && (HIWORD(wParam)==EN_UPDATE))
  1091. {
  1092. INT i;
  1093. i = GetDlgItemInt( hDlg, Item, NULL, FALSE );
  1094. IsValidSetting( hDlg, Item, pld, i );
  1095. switch( Item )
  1096. {
  1097. case IDC_CNSL_WINDOW_POSX:
  1098. pld->cpd.lpConsole->dwWindowOrigin.X = (SHORT)
  1099. GetDlgItemInt( hDlg, Item, NULL, TRUE );
  1100. break;
  1101. case IDC_CNSL_WINDOW_POSY:
  1102. pld->cpd.lpConsole->dwWindowOrigin.Y = (SHORT)
  1103. GetDlgItemInt( hDlg, Item, NULL, TRUE );
  1104. break;
  1105. }
  1106. UpdatePrevWindow:
  1107. pld->cpd.bConDirty = TRUE;
  1108. PropSheet_Changed( GetParent( hDlg ), hDlg );
  1109. SendDlgItemMessage(hDlg, IDC_CNSL_PREVIEWWINDOW, CM_PREVIEW_UPDATE, 0, 0 );
  1110. }
  1111. break;
  1112. case WM_NOTIFY:
  1113. switch (((LPNMHDR)lParam)->code) {
  1114. case UDN_DELTAPOS:
  1115. {
  1116. NM_UPDOWN * lpud = (NM_UPDOWN *)lParam;
  1117. INT i;
  1118. i = lpud->iPos + lpud->iDelta;
  1119. // Check for bad ranges
  1120. if ((i > 9999) || (i < 1))
  1121. return TRUE;
  1122. // check restrictions and alter values accordingly. (Buffer size
  1123. // can never be smaller than window size!)
  1124. CheckBufferSize( hDlg, (UINT)wParam, pld, i);
  1125. // highlight the changed entry
  1126. SendDlgItemMessage( hDlg,
  1127. (UINT)wParam,
  1128. EM_SETSEL,
  1129. (WPARAM)(INT)4,
  1130. (WPARAM)(INT)4
  1131. );
  1132. // Update the preview window
  1133. pld->cpd.bConDirty = TRUE;
  1134. PropSheet_Changed( GetParent( hDlg ), hDlg );
  1135. SendDlgItemMessage(hDlg, IDC_CNSL_PREVIEWWINDOW, CM_PREVIEW_UPDATE, 0, 0 );
  1136. }
  1137. break;
  1138. case PSN_APPLY:
  1139. /*
  1140. * Write out the state values and exit.
  1141. */
  1142. if (FAILED(SaveLink(pld)))
  1143. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  1144. break;
  1145. // case PSN_HELP:
  1146. // //WinHelp(hDlg, szHelpFileName, HELP_CONTEXT, DID_SCRBUFSIZE);
  1147. // return TRUE;
  1148. case PSN_KILLACTIVE:
  1149. /*
  1150. * Fake the dialog proc into thinking the edit control just
  1151. * lost focus so it'll update properly
  1152. */
  1153. if (0 != (Item = GetDlgCtrlID(GetFocus()))) {
  1154. SendMessage(hDlg, WM_COMMAND, MAKELONG(Item, EN_KILLFOCUS), 0);
  1155. }
  1156. return TRUE;
  1157. }
  1158. break;
  1159. default:
  1160. break;
  1161. }
  1162. return FALSE;
  1163. }
  1164. void *_CopyDataBlock(IShellLink *psl, DWORD dwSig)
  1165. {
  1166. void *pv = NULL;
  1167. IShellLinkDataList *psld;
  1168. if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl, &IID_IShellLinkDataList, (void **)&psld)))
  1169. {
  1170. psld->lpVtbl->CopyDataBlock(psld, dwSig, &pv);
  1171. psld->lpVtbl->Release(psld);
  1172. }
  1173. return (void *)pv;
  1174. }
  1175. void _RemoveDataBlock(IShellLink *psl, DWORD dwSig)
  1176. {
  1177. IShellLinkDataList *psld;
  1178. if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl, &IID_IShellLinkDataList, (void **)&psld)))
  1179. {
  1180. psld->lpVtbl->RemoveDataBlock(psld, dwSig);
  1181. psld->lpVtbl->Release(psld);
  1182. }
  1183. }
  1184. void _AddDataBlock(IShellLink *psl, void *pv)
  1185. {
  1186. IShellLinkDataList *psld;
  1187. if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl, &IID_IShellLinkDataList, (void **)&psld)))
  1188. {
  1189. psld->lpVtbl->AddDataBlock(psld, pv);
  1190. psld->lpVtbl->Release(psld);
  1191. }
  1192. }
  1193. STDAPI_(void) LinkConsolePagesSave( LINKDATA *pld )
  1194. {
  1195. // First, remove the console settings section if it exists
  1196. _RemoveDataBlock(pld->cpd.psl, NT_CONSOLE_PROPS_SIG);
  1197. _RemoveDataBlock(pld->cpd.psl, NT_FE_CONSOLE_PROPS_SIG);
  1198. #ifndef UNICODE
  1199. // if we're the ANSI shell, we need to convert FACENAME
  1200. // over to UNICODE before saving...
  1201. {
  1202. WCHAR wszFaceName[LF_FACESIZE];
  1203. MultiByteToWideChar( CP_ACP, 0,
  1204. pld->cpd.lpFaceName, LF_FACESIZE,
  1205. wszFaceName, LF_FACESIZE
  1206. );
  1207. hmemcpy(pld->cpd.lpConsole->FaceName, wszFaceName, LF_FACESIZE*SIZEOF(WCHAR));
  1208. }
  1209. #endif
  1210. //
  1211. // Now, add back the new console settings
  1212. _AddDataBlock(pld->cpd.psl, pld->cpd.lpConsole);
  1213. //
  1214. // Now, update registry settings for this title...
  1215. SetRegistryValues( &pld->cpd );
  1216. if (IsFarEastCP(pld->cpd.uOEMCP))
  1217. {
  1218. // Same for FarEast console settings
  1219. //
  1220. _AddDataBlock(pld->cpd.psl, pld->cpd.lpFEConsole);
  1221. SetFERegistryValues( &pld->cpd );
  1222. }
  1223. // And, mark the console data as current
  1224. pld->cpd.bConDirty = FALSE;
  1225. }
  1226. #define PEMAGIC ((WORD)'P'+((WORD)'E'<<8))
  1227. STDAPI_(void) AddLinkConsolePages(LINKDATA *pld, IShellLink * psl, LPCTSTR pszFile, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
  1228. {
  1229. HPROPSHEETPAGE hpage;
  1230. PROPSHEETPAGE psp;
  1231. HRESULT hres;
  1232. TCHAR szTarget[ MAX_PATH ];
  1233. TCHAR szBuffer[ MAX_PATH ];
  1234. WNDCLASS wc;
  1235. IPersistFile *ppf;
  1236. LPNT_FE_CONSOLE_PROPS lpFEConsole;
  1237. LPNT_CONSOLE_PROPS lpConsole;
  1238. // do this here so we don't slow down the loading
  1239. // of other pages
  1240. if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf)))
  1241. {
  1242. WCHAR wszPath[ MAX_PATH ];
  1243. SHTCharToUnicode(pszFile, wszPath, ARRAYSIZE(wszPath));
  1244. hres = ppf->lpVtbl->Load(ppf, wszPath, 0);
  1245. ppf->lpVtbl->Release(ppf);
  1246. }
  1247. // Get the target of the link
  1248. hres = psl->lpVtbl->GetPath(psl, szBuffer, ARRAYSIZE(szBuffer), NULL, 0);
  1249. pld->cpd.psl = psl;
  1250. if (FAILED(hres) || hres == S_FALSE)
  1251. goto Exit;
  1252. // Remove args first, to:
  1253. // (1) shorten our string, avoiding ExpandEnvironmentStrings overflowing the buffer
  1254. // (2) increase liklihood that PathRemoveArgs won't get confused by spaces in "Program Files" etc
  1255. PathRemoveArgs(szTarget);
  1256. // expand the target
  1257. if (!SHExpandEnvironmentStrings(szBuffer, szTarget, ARRAYSIZE(szTarget)))
  1258. goto Exit;
  1259. // Check what kind of app target is LOWORD==PEMAGIC, HIWORD==0
  1260. if (GetExeType( szTarget )!=PEMAGIC)
  1261. goto Exit;
  1262. // It's a WIN32 console mode app, let's put up our property sheet
  1263. wc.lpszClassName = TEXT("WOACnslWinPreview");
  1264. wc.hInstance = HINST_THISDLL;
  1265. wc.lpfnWndProc = PreviewWndProc;
  1266. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  1267. wc.hIcon = NULL;
  1268. wc.lpszMenuName = NULL;
  1269. wc.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1);
  1270. wc.style = 0L;
  1271. wc.cbClsExtra = 0;
  1272. wc.cbWndExtra = 2 * sizeof(PVOID); // (two pointers)
  1273. if (!RegisterClass(&wc))
  1274. if (GetLastError()!=ERROR_CLASS_ALREADY_EXISTS)
  1275. goto Exit;
  1276. wc.lpszClassName = TEXT("WOACnslFontPreview");
  1277. wc.hInstance = HINST_THISDLL;
  1278. wc.lpfnWndProc = _FontPreviewWndProc;
  1279. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  1280. wc.hIcon = NULL;
  1281. wc.lpszMenuName = NULL;
  1282. wc.hbrBackground = GetStockObject(BLACK_BRUSH);
  1283. wc.style = 0L;
  1284. wc.cbClsExtra = 0;
  1285. wc.cbWndExtra = sizeof(PVOID); // (one pointer)
  1286. if (!RegisterClass(&wc))
  1287. if (GetLastError()!=ERROR_CLASS_ALREADY_EXISTS)
  1288. goto Exit;
  1289. wc.lpszClassName = TEXT("cpColor");
  1290. wc.hInstance = HINST_THISDLL;
  1291. wc.lpfnWndProc = ColorControlProc;
  1292. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  1293. wc.hIcon = NULL;
  1294. wc.lpszMenuName = NULL;
  1295. wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  1296. wc.style = 0L;
  1297. wc.cbClsExtra = 0;
  1298. wc.cbWndExtra = sizeof(PVOID); // (one pointer)
  1299. if (!RegisterClass(&wc))
  1300. if (GetLastError()!=ERROR_CLASS_ALREADY_EXISTS)
  1301. goto Exit;
  1302. wc.lpszClassName = TEXT("cpShowColor");
  1303. wc.hInstance = HINST_THISDLL;
  1304. wc.lpfnWndProc = ColorTextProc;
  1305. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  1306. wc.hIcon = NULL;
  1307. wc.lpszMenuName = NULL;
  1308. wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  1309. wc.style = 0L;
  1310. wc.cbClsExtra = 0;
  1311. wc.cbWndExtra = sizeof(PVOID); // (one pointer)
  1312. if (!RegisterClass(&wc))
  1313. if (GetLastError()!=ERROR_CLASS_ALREADY_EXISTS)
  1314. goto Exit;
  1315. // Needs TTFontList for all platform.
  1316. if (!NT_SUCCESS( InitializeDbcsMisc(&pld->cpd) ))
  1317. goto Exit;
  1318. GetTitleFromLinkName( (LPTSTR)pszFile, (LPTSTR)pld->cpd.ConsoleTitle, ARRAYSIZE(pld->cpd.ConsoleTitle));
  1319. // Check if Far East settings exist...
  1320. lpFEConsole =(LPNT_FE_CONSOLE_PROPS)_CopyDataBlock(psl, NT_FE_CONSOLE_PROPS_SIG);
  1321. if (lpFEConsole && lpFEConsole->cbSize != SIZEOF(NT_FE_CONSOLE_PROPS))
  1322. {
  1323. LocalFree(lpFEConsole);
  1324. lpFEConsole = NULL;
  1325. }
  1326. if (lpFEConsole)
  1327. {
  1328. pld->cpd.lpFEConsole = lpFEConsole;
  1329. }
  1330. else
  1331. {
  1332. pld->cpd.lpFEConsole = (LPNT_FE_CONSOLE_PROPS)LocalAlloc( LPTR, SIZEOF(NT_FE_CONSOLE_PROPS) );
  1333. if (pld->cpd.lpFEConsole)
  1334. {
  1335. // Initialize Far East Console settings
  1336. pld->cpd.lpFEConsole->cbSize = SIZEOF( NT_FE_CONSOLE_PROPS );
  1337. pld->cpd.lpFEConsole->dwSignature = NT_FE_CONSOLE_PROPS_SIG;
  1338. if (IsFarEastCP(pld->cpd.uOEMCP))
  1339. {
  1340. InitFERegistryValues( &pld->cpd );
  1341. GetFERegistryValues( &pld->cpd );
  1342. }
  1343. }
  1344. }
  1345. if (!pld->cpd.lpFEConsole)
  1346. goto Exit;
  1347. // Get standard settings from link if they exist...
  1348. lpConsole = (LPNT_CONSOLE_PROPS)_CopyDataBlock(psl, NT_CONSOLE_PROPS_SIG);
  1349. if (lpConsole != NULL && lpConsole->cbSize != SIZEOF(NT_CONSOLE_PROPS))
  1350. {
  1351. LocalFree(lpConsole);
  1352. lpConsole = NULL;
  1353. }
  1354. if (lpConsole)
  1355. {
  1356. pld->cpd.lpConsole = lpConsole;
  1357. }
  1358. else
  1359. {
  1360. pld->cpd.lpConsole = (LPNT_CONSOLE_PROPS)LocalAlloc(LPTR, SIZEOF(NT_CONSOLE_PROPS) );
  1361. if (pld->cpd.lpConsole)
  1362. {
  1363. // Initialize console settings
  1364. pld->cpd.lpConsole->cbSize = SIZEOF( NT_CONSOLE_PROPS );
  1365. pld->cpd.lpConsole->dwSignature = NT_CONSOLE_PROPS_SIG;
  1366. InitRegistryValues( &pld->cpd );
  1367. GetRegistryValues( &pld->cpd );
  1368. }
  1369. else
  1370. {
  1371. // if the above alloc failes, we fault dereferencing lpConsole...
  1372. ASSERT(FALSE);
  1373. }
  1374. }
  1375. #ifndef UNICODE
  1376. else
  1377. {
  1378. // we read the properties off of disk -- so need to convert the
  1379. // UNICODE string to ANSI
  1380. WCHAR wszFaceName[LF_FACESIZE];
  1381. hmemcpy(wszFaceName,pld->cpd.lpConsole->FaceName,LF_FACESIZE*SIZEOF(WCHAR));
  1382. WideCharToMultiByte( CP_ACP, 0,
  1383. wszFaceName, LF_FACESIZE,
  1384. pld->cpd.szFaceName, LF_FACESIZE,
  1385. NULL, NULL
  1386. );
  1387. }
  1388. #endif
  1389. if (!pld->cpd.lpConsole)
  1390. goto Exit;
  1391. // set facename pointer to correct place
  1392. #ifdef UNICODE
  1393. pld->cpd.lpFaceName = (LPTSTR)pld->cpd.lpConsole->FaceName;
  1394. #else
  1395. pld->cpd.lpFaceName = (LPTSTR)pld->cpd.szFaceName;
  1396. #endif
  1397. //
  1398. // Initialize the font cache and current font index
  1399. //
  1400. if (STATUS_SUCCESS != InitializeFonts( &pld->cpd ))
  1401. {
  1402. goto Exit;
  1403. }
  1404. pld->cpd.CurrentFontIndex = FindCreateFont( &pld->cpd,
  1405. pld->cpd.lpConsole->uFontFamily,
  1406. pld->cpd.lpFaceName,
  1407. pld->cpd.lpConsole->dwFontSize,
  1408. pld->cpd.lpConsole->uFontWeight);
  1409. // Mark the console data as current
  1410. pld->cpd.bConDirty = FALSE;
  1411. // add console settings property sheet
  1412. psp.dwSize = SIZEOF( psp );
  1413. psp.dwFlags = PSP_DEFAULT;
  1414. psp.hInstance = HINST_THISDLL;
  1415. psp.pszTemplate = MAKEINTRESOURCE(IDD_CONSOLE_SETTINGS);
  1416. psp.pfnDlgProc = _ConsoleSettingsDlgProc;
  1417. psp.lParam = (LPARAM)pld;
  1418. hpage = CreatePropertySheetPage( &psp );
  1419. if (hpage)
  1420. {
  1421. if (!pfnAddPage(hpage, lParam))
  1422. {
  1423. DestroyPropertySheetPage(hpage);
  1424. goto Exit;
  1425. }
  1426. }
  1427. else
  1428. {
  1429. if (pld->cpd.lpConsole)
  1430. {
  1431. LocalFree( pld->cpd.lpConsole );
  1432. pld->cpd.lpConsole = NULL;
  1433. }
  1434. if (pld->cpd.lpFEConsole)
  1435. {
  1436. LocalFree( pld->cpd.lpFEConsole );
  1437. pld->cpd.lpFEConsole = NULL;
  1438. }
  1439. goto Exit;
  1440. }
  1441. // add font selection property sheet
  1442. psp.dwSize = SIZEOF( psp );
  1443. psp.dwFlags = PSP_DEFAULT;
  1444. psp.hInstance = HINST_THISDLL;
  1445. psp.pszTemplate = MAKEINTRESOURCE(IDD_CONSOLE_FONTDLG);
  1446. psp.pfnDlgProc = _FontDlgProc;
  1447. psp.lParam = (LPARAM)pld;
  1448. hpage = CreatePropertySheetPage( &psp );
  1449. if (hpage)
  1450. {
  1451. if (!pfnAddPage(hpage, lParam))
  1452. {
  1453. DestroyPropertySheetPage(hpage);
  1454. goto Exit;
  1455. }
  1456. }
  1457. else
  1458. {
  1459. if (pld->cpd.lpConsole)
  1460. {
  1461. LocalFree( pld->cpd.lpConsole );
  1462. pld->cpd.lpConsole = NULL;
  1463. }
  1464. if (pld->cpd.lpFEConsole)
  1465. {
  1466. LocalFree( pld->cpd.lpFEConsole );
  1467. pld->cpd.lpFEConsole = NULL;
  1468. }
  1469. goto Exit;
  1470. }
  1471. // add console size propery sheet
  1472. psp.dwSize = SIZEOF( psp );
  1473. psp.dwFlags = PSP_DEFAULT;
  1474. psp.hInstance = HINST_THISDLL;
  1475. psp.pszTemplate = MAKEINTRESOURCE(IDD_CONSOLE_SCRBUFSIZE);
  1476. psp.pfnDlgProc = _ScreenSizeDlgProc;
  1477. psp.lParam = (LPARAM)pld;
  1478. hpage = CreatePropertySheetPage( &psp );
  1479. if (hpage)
  1480. {
  1481. if (!pfnAddPage(hpage, lParam))
  1482. {
  1483. DestroyPropertySheetPage(hpage);
  1484. goto Exit;
  1485. }
  1486. }
  1487. else
  1488. {
  1489. if (pld->cpd.lpConsole)
  1490. {
  1491. LocalFree( pld->cpd.lpConsole );
  1492. pld->cpd.lpConsole = NULL;
  1493. }
  1494. goto Exit;
  1495. }
  1496. // add console color propery sheet
  1497. psp.dwSize = SIZEOF( psp );
  1498. psp.dwFlags = PSP_DEFAULT;
  1499. psp.hInstance = HINST_THISDLL;
  1500. psp.pszTemplate = MAKEINTRESOURCE(IDD_CONSOLE_COLOR);
  1501. psp.pfnDlgProc = _ColorDlgProc;
  1502. psp.lParam = (LPARAM)pld;
  1503. hpage = CreatePropertySheetPage( &psp );
  1504. if (hpage)
  1505. {
  1506. if (!pfnAddPage(hpage, lParam))
  1507. {
  1508. DestroyPropertySheetPage(hpage);
  1509. goto Exit;
  1510. }
  1511. }
  1512. else
  1513. {
  1514. if (pld->cpd.lpConsole)
  1515. {
  1516. LocalFree( pld->cpd.lpConsole );
  1517. pld->cpd.lpConsole = NULL;
  1518. }
  1519. if (pld->cpd.lpFEConsole)
  1520. {
  1521. LocalFree( pld->cpd.lpFEConsole );
  1522. pld->cpd.lpFEConsole = NULL;
  1523. }
  1524. goto Exit;
  1525. }
  1526. #ifdef ADVANCED_PAGE
  1527. // add "advanced" settings propery sheet
  1528. psp.dwSize = SIZEOF( psp );
  1529. psp.dwFlags = PSP_DEFAULT;
  1530. psp.hInstance = HINST_THISDLL;
  1531. psp.pszTemplate = MAKEINTRESOURCE(IDD_CONSOLE_ADVANCED);
  1532. psp.pfnDlgProc = _AdvancedDlgProc;
  1533. psp.lParam = (LPARAM)pld;
  1534. hpage = CreatePropertySheetPage( &psp );
  1535. if (hpage)
  1536. {
  1537. if (!pfnAddPage(hpage, lParam))
  1538. {
  1539. DestroyPropertySheetPage(hpage);
  1540. goto Exit;
  1541. }
  1542. }
  1543. else
  1544. {
  1545. if (pld->cpd.lpConsole)
  1546. {
  1547. LocalFree( pld->cpd.lpConsole );
  1548. pld->cpd.lpConsole = NULL;
  1549. }
  1550. if (pld->cpd.lpFEConsole)
  1551. {
  1552. LocalFree( pld->cpd.lpFEConsole );
  1553. pld->cpd.lpFEConsole = NULL;
  1554. }
  1555. goto Exit;
  1556. }
  1557. #endif
  1558. Exit:
  1559. ;
  1560. }