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.

715 lines
22 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. menu.c
  5. Abstract:
  6. This file implements the system menu management.
  7. Author:
  8. Therese Stowell (thereses) Jan-24-1992 (swiped from Win3.1)
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. VOID
  13. MyModifyMenuItem(
  14. IN PCONSOLE_INFORMATION Console,
  15. IN UINT ItemId
  16. )
  17. /*++
  18. This routine edits the indicated control to one word. This is used to
  19. trim the Accelerator key text off of the end of the standard menu
  20. items because we don't support the accelerators.
  21. --*/
  22. {
  23. WCHAR ItemString[30];
  24. int ItemLength;
  25. MENUITEMINFO mii;
  26. ItemLength = LoadString(ghInstance,ItemId,ItemString,NELEM(ItemString));
  27. if (ItemLength == 0) {
  28. //DbgPrint("LoadString in MyModifyMenu failed %d\n",GetLastError());
  29. return;
  30. }
  31. mii.cbSize = sizeof(mii);
  32. mii.fMask = MIIM_STRING;
  33. mii.dwTypeData = ItemString;
  34. if (ItemId == SC_CLOSE) {
  35. mii.fMask |= MIIM_BITMAP;
  36. mii.hbmpItem = HBMMENU_POPUP_CLOSE;
  37. }
  38. SetMenuItemInfo(Console->hMenu, ItemId, FALSE, &mii);
  39. }
  40. VOID
  41. InitSystemMenu(
  42. IN PCONSOLE_INFORMATION Console
  43. )
  44. {
  45. WCHAR ItemString[30];
  46. int ItemLength;
  47. //
  48. // load the clipboard menu.
  49. //
  50. Console->hHeirMenu = LoadMenu(ghInstance, MAKEINTRESOURCE(ID_WOMENU));
  51. if (Console->hHeirMenu) {
  52. ItemLength = LoadString(ghInstance,cmEdit,ItemString,NELEM(ItemString));
  53. if (ItemLength == 0)
  54. RIPMSG1(RIP_WARNING, "LoadString 1 failed 0x%x", GetLastError());
  55. } else {
  56. RIPMSG1(RIP_WARNING, "LoadMenu 1 failed 0x%x", GetLastError());
  57. }
  58. //
  59. // Edit the accelerators off of the standard items.
  60. //
  61. MyModifyMenuItem(Console, SC_CLOSE);
  62. //
  63. // Append the clipboard menu to system menu.
  64. //
  65. if (!AppendMenu(Console->hMenu,
  66. MF_POPUP | MF_STRING,
  67. (ULONG_PTR)Console->hHeirMenu,
  68. ItemString)) {
  69. RIPMSG1(RIP_WARNING, "AppendMenu 1 failed 0x%x", GetLastError());
  70. }
  71. //
  72. // Add other items to system menu
  73. //
  74. ItemLength = LoadString(ghInstance, cmDefaults, ItemString, ARRAY_SIZE(ItemString));
  75. if (ItemLength == 0)
  76. RIPMSG2(RIP_WARNING, "LoadString 0x%x failed 0x%x", cmDefaults, GetLastError());
  77. if (ItemLength) {
  78. if (!AppendMenu(Console->hMenu, MF_STRING, cmDefaults, ItemString)) {
  79. RIPMSG2(RIP_WARNING, "AppendMenu 0x%x failed 0x%x", cmDefaults, GetLastError());
  80. }
  81. }
  82. ItemLength = LoadString(ghInstance,cmControl,ItemString,NELEM(ItemString));
  83. if (ItemLength == 0)
  84. RIPMSG2(RIP_WARNING, "LoadString 0x%x failed 0x%x\n", cmControl, GetLastError());
  85. if (ItemLength) {
  86. if (!AppendMenu(Console->hMenu, MF_STRING, cmControl, ItemString)) {
  87. RIPMSG2(RIP_WARNING, "AppendMenu 0x%x failed 0x%x\n", cmControl, GetLastError());
  88. }
  89. }
  90. }
  91. VOID
  92. InitializeMenu(
  93. IN PCONSOLE_INFORMATION Console
  94. )
  95. /*++
  96. this initializes the system menu when a WM_INITMENU message
  97. is read.
  98. --*/
  99. {
  100. HMENU hMenu = Console->hMenu;
  101. HMENU hHeirMenu = Console->hHeirMenu;
  102. //
  103. // if we're in graphics mode, disable size menu
  104. //
  105. if (!(Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER)) {
  106. EnableMenuItem(hMenu,SC_SIZE,MF_GRAYED);
  107. }
  108. //
  109. // if the console is iconic, disable Mark and Scroll.
  110. //
  111. if (Console->Flags & CONSOLE_IS_ICONIC) {
  112. EnableMenuItem(hHeirMenu,cmMark,MF_GRAYED);
  113. EnableMenuItem(hHeirMenu,cmScroll,MF_GRAYED);
  114. } else {
  115. //
  116. // if the console is not iconic
  117. // if there are no scroll bars
  118. // or we're in mark mode
  119. // disable scroll
  120. // else
  121. // enable scroll
  122. //
  123. // if we're in scroll mode
  124. // disable mark
  125. // else
  126. // enable mark
  127. if ((Console->CurrentScreenBuffer->WindowMaximizedX &&
  128. Console->CurrentScreenBuffer->WindowMaximizedY) ||
  129. Console->Flags & CONSOLE_SELECTING) {
  130. EnableMenuItem(hHeirMenu,cmScroll,MF_GRAYED);
  131. } else {
  132. EnableMenuItem(hHeirMenu,cmScroll,MF_ENABLED);
  133. }
  134. if (Console->Flags & CONSOLE_SCROLLING) {
  135. EnableMenuItem(hHeirMenu,cmMark,MF_GRAYED);
  136. } else {
  137. EnableMenuItem(hHeirMenu,cmMark,MF_ENABLED);
  138. }
  139. }
  140. //
  141. // if we're selecting or scrolling, disable Paste.
  142. // otherwise enable it.
  143. //
  144. if (Console->Flags & (CONSOLE_SELECTING | CONSOLE_SCROLLING)) {
  145. EnableMenuItem(hHeirMenu,cmPaste,MF_GRAYED);
  146. } else {
  147. EnableMenuItem(hHeirMenu,cmPaste,MF_ENABLED);
  148. }
  149. //
  150. // if app has active selection, enable copy; else disabled
  151. //
  152. if (Console->Flags & CONSOLE_SELECTING &&
  153. Console->SelectionFlags & CONSOLE_SELECTION_NOT_EMPTY) {
  154. EnableMenuItem(hHeirMenu,cmCopy,MF_ENABLED);
  155. } else {
  156. EnableMenuItem(hHeirMenu,cmCopy,MF_GRAYED);
  157. }
  158. //
  159. // disable close
  160. //
  161. if (Console->Flags & CONSOLE_DISABLE_CLOSE)
  162. EnableMenuItem(hMenu,SC_CLOSE,MF_GRAYED);
  163. else
  164. EnableMenuItem(hMenu,SC_CLOSE,MF_ENABLED);
  165. //
  166. // enable Move if not iconic
  167. //
  168. if (Console->Flags & CONSOLE_IS_ICONIC) {
  169. EnableMenuItem(hMenu,SC_MOVE,MF_GRAYED);
  170. } else {
  171. EnableMenuItem(hMenu,SC_MOVE,MF_ENABLED);
  172. }
  173. //
  174. // enable Settings if not already doing it
  175. //
  176. if (Console->hWndProperties && IsWindow(Console->hWndProperties)) {
  177. EnableMenuItem(hMenu,cmControl,MF_GRAYED);
  178. } else {
  179. EnableMenuItem(hMenu,cmControl,MF_ENABLED);
  180. Console->hWndProperties = NULL;
  181. }
  182. }
  183. VOID
  184. SetWinText(
  185. IN PCONSOLE_INFORMATION Console,
  186. IN UINT wID,
  187. IN BOOL Add
  188. )
  189. /*++
  190. This routine adds or removes the name to or from the
  191. beginning of the window title. The possible names
  192. are "Scroll", "Mark", "Paste", and "Copy".
  193. --*/
  194. {
  195. WCHAR TextBuf[256];
  196. PWCHAR TextBufPtr;
  197. int TextLength;
  198. int NameLength;
  199. WCHAR NameString[20];
  200. NameLength = LoadString(ghInstance,wID,NameString,
  201. sizeof(NameString)/sizeof(WCHAR));
  202. if (Add) {
  203. RtlCopyMemory(TextBuf,NameString,NameLength*sizeof(WCHAR));
  204. TextBuf[NameLength] = ' ';
  205. TextBufPtr = TextBuf + NameLength + 1;
  206. } else {
  207. TextBufPtr = TextBuf;
  208. }
  209. TextLength = GetWindowText(Console->hWnd,
  210. TextBufPtr,
  211. sizeof(TextBuf)/sizeof(WCHAR)-NameLength-1);
  212. if (TextLength == 0)
  213. return;
  214. if (Add) {
  215. TextBufPtr = TextBuf;
  216. } else {
  217. /*
  218. * The window title might have already been reset, so make sure
  219. * the name is there before trying to remove it.
  220. */
  221. if (wcsncmp(NameString, TextBufPtr, NameLength) != 0)
  222. return;
  223. TextBufPtr = TextBuf + NameLength + 1;
  224. }
  225. SetWindowText(Console->hWnd,TextBufPtr);
  226. }
  227. VOID
  228. PropertiesDlgShow(
  229. IN PCONSOLE_INFORMATION Console,
  230. IN BOOL fCurrent
  231. )
  232. /*++
  233. Displays the properties dialog and updates the window state,
  234. if necessary.
  235. --*/
  236. {
  237. HANDLE hSection = NULL;
  238. HANDLE hClientSection = NULL;
  239. HANDLE hThread;
  240. SIZE_T ulViewSize;
  241. LARGE_INTEGER li;
  242. NTSTATUS Status;
  243. PCONSOLE_STATE_INFO pStateInfo;
  244. PCONSOLE_PROCESS_HANDLE ProcessHandleRecord;
  245. PSCREEN_INFORMATION ScreenInfo;
  246. LPTHREAD_START_ROUTINE MyPropRoutine;
  247. /*
  248. * Map the shared memory block handle into the client side process's
  249. * address space.
  250. */
  251. ProcessHandleRecord = CONTAINING_RECORD(Console->ProcessHandleList.Blink,
  252. CONSOLE_PROCESS_HANDLE,
  253. ListLink);
  254. /*
  255. * For global properties pass in hWnd for the hClientSection
  256. */
  257. if (!fCurrent) {
  258. hClientSection = Console->hWnd;
  259. goto PropCallback;
  260. }
  261. /*
  262. * Create a shared memory block.
  263. */
  264. li.QuadPart = sizeof(CONSOLE_STATE_INFO) + Console->OriginalTitleLength;
  265. Status = NtCreateSection(&hSection,
  266. SECTION_ALL_ACCESS,
  267. NULL,
  268. &li,
  269. PAGE_READWRITE,
  270. SEC_COMMIT,
  271. NULL);
  272. if (!NT_SUCCESS(Status)) {
  273. RIPMSG1(RIP_WARNING, "Error 0x%x creating file mapping", Status);
  274. return;
  275. }
  276. /*
  277. * Get a pointer to the shared memory block.
  278. */
  279. pStateInfo = NULL;
  280. ulViewSize = 0;
  281. Status = NtMapViewOfSection(hSection,
  282. NtCurrentProcess(),
  283. &pStateInfo,
  284. 0,
  285. 0,
  286. NULL,
  287. &ulViewSize,
  288. ViewUnmap,
  289. 0,
  290. PAGE_READWRITE);
  291. if (!NT_SUCCESS(Status)) {
  292. RIPMSG1(RIP_WARNING, "Error 0x%x mapping view of file", Status);
  293. NtClose(hSection);
  294. return;
  295. }
  296. /*
  297. * Fill in the shared memory block with the current values.
  298. */
  299. ScreenInfo = Console->CurrentScreenBuffer;
  300. pStateInfo->Length = li.LowPart;
  301. pStateInfo->ScreenBufferSize = ScreenInfo->ScreenBufferSize;
  302. pStateInfo->WindowSize.X = CONSOLE_WINDOW_SIZE_X(ScreenInfo);
  303. pStateInfo->WindowSize.Y = CONSOLE_WINDOW_SIZE_Y(ScreenInfo);
  304. pStateInfo->WindowPosX = Console->WindowRect.left;
  305. pStateInfo->WindowPosY = Console->WindowRect.top;
  306. if (ScreenInfo->Flags & CONSOLE_TEXTMODE_BUFFER) {
  307. pStateInfo->FontSize = SCR_FONTSIZE(ScreenInfo);
  308. pStateInfo->FontFamily = SCR_FAMILY(ScreenInfo);
  309. pStateInfo->FontWeight = SCR_FONTWEIGHT(ScreenInfo);
  310. wcscpy(pStateInfo->FaceName, SCR_FACENAME(ScreenInfo));
  311. #if defined(FE_SB)
  312. // if TT font has external leading, the Size.Y <> SizeWant.Y
  313. // if we still pass actual Size.Y to console.cpl to query font,
  314. // it will be incorrect. Jun-26-1996
  315. if (CONSOLE_IS_DBCS_ENABLED() &&
  316. TM_IS_TT_FONT(SCR_FAMILY(ScreenInfo)))
  317. {
  318. if (SCR_FONTNUMBER(ScreenInfo) < NumberOfFonts) {
  319. pStateInfo->FontSize = FontInfo[SCR_FONTNUMBER(ScreenInfo)].SizeWant;
  320. }
  321. }
  322. #endif
  323. pStateInfo->CursorSize = ScreenInfo->BufferInfo.TextInfo.CursorSize;
  324. }
  325. pStateInfo->FullScreen = Console->FullScreenFlags & CONSOLE_FULLSCREEN;
  326. pStateInfo->QuickEdit = Console->Flags & CONSOLE_QUICK_EDIT_MODE;
  327. pStateInfo->AutoPosition = Console->Flags & CONSOLE_AUTO_POSITION;
  328. pStateInfo->InsertMode = Console->InsertMode;
  329. pStateInfo->ScreenAttributes = ScreenInfo->Attributes;
  330. pStateInfo->PopupAttributes = ScreenInfo->PopupAttributes;
  331. pStateInfo->HistoryBufferSize = Console->CommandHistorySize;
  332. pStateInfo->NumberOfHistoryBuffers = Console->MaxCommandHistories;
  333. pStateInfo->HistoryNoDup = Console->Flags & CONSOLE_HISTORY_NODUP;
  334. RtlCopyMemory(pStateInfo->ColorTable,
  335. Console->ColorTable,
  336. sizeof(Console->ColorTable));
  337. pStateInfo->hWnd = Console->hWnd;
  338. wcscpy(pStateInfo->ConsoleTitle, Console->OriginalTitle);
  339. #if defined(FE_SB)
  340. pStateInfo->CodePage = Console->OutputCP;
  341. #endif
  342. NtUnmapViewOfSection(NtCurrentProcess(), pStateInfo);
  343. Status = NtDuplicateObject(NtCurrentProcess(),
  344. hSection,
  345. ProcessHandleRecord->ProcessHandle,
  346. &hClientSection,
  347. 0,
  348. 0,
  349. DUPLICATE_SAME_ACCESS);
  350. if (!NT_SUCCESS(Status)) {
  351. RIPMSG1(RIP_WARNING, "Error 0x%x mapping handle to client", Status);
  352. NtClose(hSection);
  353. return;
  354. }
  355. PropCallback:
  356. /*
  357. * Get a pointer to the client-side properties routine.
  358. */
  359. MyPropRoutine = ProcessHandleRecord->PropRoutine;
  360. ASSERT(MyPropRoutine);
  361. /*
  362. * Call back into the client process to spawn the properties dialog.
  363. */
  364. UnlockConsole(Console);
  365. hThread = InternalCreateCallbackThread(ProcessHandleRecord->ProcessHandle,
  366. (ULONG_PTR)MyPropRoutine,
  367. (ULONG_PTR)hClientSection);
  368. if (!hThread) {
  369. RIPMSG1(RIP_WARNING, "CreateRemoteThread failed 0x%x", GetLastError());
  370. }
  371. LockConsole(Console);
  372. /*
  373. * Close any open handles and free allocated memory.
  374. */
  375. if (hThread)
  376. NtClose(hThread);
  377. if (hSection)
  378. NtClose(hSection);
  379. return;
  380. }
  381. VOID
  382. PropertiesUpdate(
  383. IN PCONSOLE_INFORMATION Console,
  384. IN HANDLE hClientSection
  385. )
  386. /*++
  387. Updates the console state from information sent by the properties
  388. dialog box.
  389. --*/
  390. {
  391. HANDLE hSection;
  392. SIZE_T ulViewSize;
  393. NTSTATUS Status;
  394. PCONSOLE_STATE_INFO pStateInfo;
  395. PCONSOLE_PROCESS_HANDLE ProcessHandleRecord;
  396. PSCREEN_INFORMATION ScreenInfo;
  397. ULONG FontIndex;
  398. WINDOWPLACEMENT wp;
  399. COORD NewSize;
  400. WINDOW_LIMITS WindowLimits;
  401. /*
  402. * Map the shared memory block handle into our address space.
  403. */
  404. ProcessHandleRecord = CONTAINING_RECORD(Console->ProcessHandleList.Blink,
  405. CONSOLE_PROCESS_HANDLE,
  406. ListLink);
  407. Status = NtDuplicateObject(ProcessHandleRecord->ProcessHandle,
  408. hClientSection,
  409. NtCurrentProcess(),
  410. &hSection,
  411. 0,
  412. 0,
  413. DUPLICATE_SAME_ACCESS);
  414. if (!NT_SUCCESS(Status)) {
  415. RIPMSG1(RIP_WARNING, "Error 0x%x mapping client handle", Status);
  416. return;
  417. }
  418. /*
  419. * Get a pointer to the shared memory block.
  420. */
  421. pStateInfo = NULL;
  422. ulViewSize = 0;
  423. Status = NtMapViewOfSection(hSection,
  424. NtCurrentProcess(),
  425. &pStateInfo,
  426. 0,
  427. 0,
  428. NULL,
  429. &ulViewSize,
  430. ViewUnmap,
  431. 0,
  432. PAGE_READONLY);
  433. if (!NT_SUCCESS(Status)) {
  434. RIPMSG1(RIP_WARNING, "Error %x mapping view of file", Status);
  435. NtClose(hSection);
  436. return;
  437. }
  438. /*
  439. * Verify the size of the shared memory block.
  440. */
  441. if (ulViewSize < sizeof(CONSOLE_STATE_INFO)) {
  442. RIPMSG0(RIP_WARNING, "sizeof(hSection) < sizeof(CONSOLE_STATE_INFO)");
  443. NtUnmapViewOfSection(NtCurrentProcess(), pStateInfo);
  444. NtClose(hSection);
  445. return;
  446. }
  447. ScreenInfo = Console->CurrentScreenBuffer;
  448. #if defined(FE_SB)
  449. if (Console->OutputCP != pStateInfo->CodePage)
  450. {
  451. UINT CodePage = Console->OutputCP;
  452. Console->OutputCP = pStateInfo->CodePage;
  453. if (CONSOLE_IS_DBCS_ENABLED())
  454. Console->fIsDBCSOutputCP = !!IsAvailableFarEastCodePage(Console->OutputCP);
  455. else
  456. Console->fIsDBCSOutputCP = FALSE;
  457. SetConsoleCPInfo(Console,TRUE);
  458. #if defined(FE_IME)
  459. SetImeOutputCodePage(Console, ScreenInfo, CodePage);
  460. #endif // FE_IME
  461. }
  462. if (Console->CP != pStateInfo->CodePage)
  463. {
  464. UINT CodePage = Console->CP;
  465. Console->CP = pStateInfo->CodePage;
  466. if (CONSOLE_IS_DBCS_ENABLED())
  467. Console->fIsDBCSCP = !!IsAvailableFarEastCodePage(Console->CP);
  468. else
  469. Console->fIsDBCSCP = FALSE;
  470. SetConsoleCPInfo(Console,FALSE);
  471. #if defined(FE_IME)
  472. SetImeCodePage(Console);
  473. #endif // FE_IME
  474. }
  475. #endif // FE_SB
  476. /*
  477. * Update the console state from the supplied values.
  478. */
  479. if (!(Console->Flags & CONSOLE_VDM_REGISTERED) &&
  480. (pStateInfo->ScreenBufferSize.X != ScreenInfo->ScreenBufferSize.X ||
  481. pStateInfo->ScreenBufferSize.Y != ScreenInfo->ScreenBufferSize.Y)) {
  482. PCOOKED_READ_DATA CookedReadData = Console->lpCookedReadData;
  483. if (CookedReadData && CookedReadData->NumberOfVisibleChars) {
  484. DeleteCommandLine(CookedReadData, FALSE);
  485. }
  486. ResizeScreenBuffer(ScreenInfo,
  487. pStateInfo->ScreenBufferSize,
  488. TRUE);
  489. if (CookedReadData && CookedReadData->NumberOfVisibleChars) {
  490. RedrawCommandLine(CookedReadData);
  491. }
  492. }
  493. #if !defined(FE_SB)
  494. FontIndex = FindCreateFont(pStateInfo->FontFamily,
  495. pStateInfo->FaceName,
  496. pStateInfo->FontSize,
  497. pStateInfo->FontWeight);
  498. #else
  499. FontIndex = FindCreateFont(pStateInfo->FontFamily,
  500. pStateInfo->FaceName,
  501. pStateInfo->FontSize,
  502. pStateInfo->FontWeight,
  503. pStateInfo->CodePage);
  504. #endif
  505. #if defined(FE_SB)
  506. #if defined(i386)
  507. if (! (Console->FullScreenFlags & CONSOLE_FULLSCREEN)) {
  508. SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
  509. }
  510. else {
  511. ChangeDispSettings(Console, Console->hWnd, 0);
  512. SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
  513. ConvertToFullScreen(Console);
  514. ChangeDispSettings(Console, Console->hWnd, CDS_FULLSCREEN);
  515. }
  516. #else // i386
  517. SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
  518. #endif
  519. #else // FE_SB
  520. SetScreenBufferFont(ScreenInfo, FontIndex);
  521. #endif // FE_SB
  522. SetCursorInformation(ScreenInfo,
  523. pStateInfo->CursorSize,
  524. ScreenInfo->BufferInfo.TextInfo.CursorVisible);
  525. GetWindowLimits(ScreenInfo, &WindowLimits);
  526. NewSize.X = min(pStateInfo->WindowSize.X, WindowLimits.MaximumWindowSize.X);
  527. NewSize.Y = min(pStateInfo->WindowSize.Y, WindowLimits.MaximumWindowSize.Y);
  528. if (NewSize.X != CONSOLE_WINDOW_SIZE_X(ScreenInfo) ||
  529. NewSize.Y != CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) {
  530. wp.length = sizeof(wp);
  531. GetWindowPlacement(Console->hWnd, &wp);
  532. wp.rcNormalPosition.right += (NewSize.X - CONSOLE_WINDOW_SIZE_X(ScreenInfo)) *
  533. SCR_FONTSIZE(ScreenInfo).X;
  534. wp.rcNormalPosition.bottom += (NewSize.Y - CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) *
  535. SCR_FONTSIZE(ScreenInfo).Y;
  536. SetWindowPlacement(Console->hWnd, &wp);
  537. }
  538. #ifdef i386
  539. if (FullScreenInitialized && ! GetSystemMetrics(SM_REMOTESESSION)) {
  540. if (pStateInfo->FullScreen == FALSE) {
  541. if (Console->FullScreenFlags & CONSOLE_FULLSCREEN) {
  542. ConvertToWindowed(Console);
  543. #if defined(FE_SB)
  544. /*
  545. * Should not sets 0 always.
  546. * because exist CONSOLE_FULLSCREEN_HARDWARE bit by avobe
  547. * else {
  548. * ChangeDispSettings(Console, Console->hWnd, 0);
  549. * SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
  550. * ConvertToFullScreen(Console);
  551. * ChangeDispSettings(Console, Console->hWnd, CDS_FULLSCREEN);
  552. * }
  553. * block.
  554. *
  555. * This block enable as follows:
  556. * 1. console window is full screen
  557. * 2. open property by ALT+SPACE
  558. * 3. changes window mode by settings.
  559. */
  560. Console->FullScreenFlags &= ~CONSOLE_FULLSCREEN;
  561. #else
  562. ASSERT(!(Console->FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE));
  563. Console->FullScreenFlags = 0;
  564. #endif
  565. ChangeDispSettings(Console, Console->hWnd, 0);
  566. }
  567. } else {
  568. if (Console->FullScreenFlags == 0) {
  569. ConvertToFullScreen(Console);
  570. Console->FullScreenFlags |= CONSOLE_FULLSCREEN;
  571. ChangeDispSettings(Console, Console->hWnd, CDS_FULLSCREEN);
  572. }
  573. }
  574. }
  575. #endif
  576. if (pStateInfo->QuickEdit) {
  577. Console->Flags |= CONSOLE_QUICK_EDIT_MODE;
  578. } else {
  579. Console->Flags &= ~CONSOLE_QUICK_EDIT_MODE;
  580. }
  581. if (pStateInfo->AutoPosition) {
  582. Console->Flags |= CONSOLE_AUTO_POSITION;
  583. } else {
  584. Console->Flags &= ~CONSOLE_AUTO_POSITION;
  585. SetWindowPos(Console->hWnd, NULL,
  586. pStateInfo->WindowPosX,
  587. pStateInfo->WindowPosY,
  588. 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  589. }
  590. if (Console->InsertMode != pStateInfo->InsertMode) {
  591. SetCursorMode(ScreenInfo, FALSE);
  592. Console->InsertMode = (pStateInfo->InsertMode != FALSE);
  593. #ifdef FE_SB
  594. if (Console->lpCookedReadData) {
  595. ((PCOOKED_READ_DATA)Console->lpCookedReadData)->InsertMode = Console->InsertMode;
  596. }
  597. #endif
  598. }
  599. RtlCopyMemory(Console->ColorTable,
  600. pStateInfo->ColorTable,
  601. sizeof(Console->ColorTable));
  602. SetScreenColors(ScreenInfo,
  603. pStateInfo->ScreenAttributes,
  604. pStateInfo->PopupAttributes,
  605. TRUE);
  606. ResizeCommandHistoryBuffers(Console, pStateInfo->HistoryBufferSize);
  607. Console->MaxCommandHistories = (SHORT)pStateInfo->NumberOfHistoryBuffers;
  608. if (pStateInfo->HistoryNoDup) {
  609. Console->Flags |= CONSOLE_HISTORY_NODUP;
  610. } else {
  611. Console->Flags &= ~CONSOLE_HISTORY_NODUP;
  612. }
  613. #if defined(FE_IME)
  614. SetUndetermineAttribute(Console) ;
  615. #endif
  616. NtUnmapViewOfSection(NtCurrentProcess(), pStateInfo);
  617. NtClose(hSection);
  618. return;
  619. }