ReactOS  0.4.13-dev-101-g0ca4b50
layout.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Console Configuration DLL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/console/layout.c
5  * PURPOSE: Layout dialog
6  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
7  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 #include "console.h"
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* CONSOLE WINDOW PREVIEW Control *********************************************/
16 
17 #define WIN_PREVIEW_CLASS L"WinPreview"
18 
19 typedef struct _WINPREV_DATA
20 {
21  HWND hWnd; // The window which this structure refers to
22  RECT rcMaxArea; // Maximum rectangle in which the preview window can be sized
23  SIZE siPreview; // Actual size of the preview window
24  SIZE siVirtScr; // Width and Height of the virtual screen
25  PVOID pData; // Private data
27 
28 static LRESULT CALLBACK
30 
31 BOOL
34 {
36 
37  WndClass.lpszClassName = WIN_PREVIEW_CLASS;
38  WndClass.lpfnWndProc = WinPrevProc;
39  WndClass.style = 0;
40  WndClass.hInstance = hInstance;
41  WndClass.hIcon = NULL;
43  WndClass.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
44  WndClass.lpszMenuName = NULL;
45  WndClass.cbClsExtra = 0;
46  WndClass.cbWndExtra = 0; // sizeof(PWINPREV_DATA);
47 
48  return (RegisterClassW(&WndClass) != 0);
49 }
50 
51 BOOL
54 {
56 }
57 
58 static VOID
61 {
62  // RECT rcNew;
63 
64  pData->siVirtScr.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
65  pData->siVirtScr.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
66 
67  /*
68  * The rescaling factor "siPreview / siVirtScr" should be the minimum of the ratios
69  * pData->rcMaxArea.right / pData->siVirtScr.cx , and
70  * pData->rcMaxArea.bottom / pData->siVirtScr.cy ,
71  * or equivalently, the maximum of the inverse of these ratios.
72  * This condition is equivalent to the following inequality being tested.
73  */
74  // if (pData->siVirtScr.cx / pData->rcMaxArea.right >= pData->siVirtScr.cy / pData->rcMaxArea.bottom)
75  if (pData->siVirtScr.cx * pData->rcMaxArea.bottom >= pData->siVirtScr.cy * pData->rcMaxArea.right)
76  {
77  pData->siPreview.cx = MulDiv(pData->siVirtScr.cx, pData->rcMaxArea.right, pData->siVirtScr.cx);
78  pData->siPreview.cy = MulDiv(pData->siVirtScr.cy, pData->rcMaxArea.right, pData->siVirtScr.cx);
79  }
80  else
81  {
82  pData->siPreview.cx = MulDiv(pData->siVirtScr.cx, pData->rcMaxArea.bottom, pData->siVirtScr.cy);
83  pData->siPreview.cy = MulDiv(pData->siVirtScr.cy, pData->rcMaxArea.bottom, pData->siVirtScr.cy);
84  }
85 
86  /*
87  * Now, the lengths in screen-units can be rescaled into preview-units with:
88  * MulDiv(cx, pData->siPreview.cx, pData->siVirtScr.cx);
89  * and:
90  * MulDiv(cy, pData->siPreview.cy, pData->siVirtScr.cy);
91  */
92 
93 #if 0 // TODO: Investigate!
94  /*
95  * Since both rcMaxArea and siPreview are client window area sizes,
96  * transform them into window sizes.
97  */
98  SetRect(&rcNew, 0, 0, pData->siPreview.cx, pData->siPreview.cy);
99  AdjustWindowRect(&rcNew,
100  WS_BORDER,
101  // GetWindowLongPtrW(pData->hWnd, GWL_STYLE) & ~WS_OVERLAPPED,
102  FALSE);
103  OffsetRect(&rcNew, -rcNew.left, -rcNew.top);
104  rcNew.right += 2;
105  rcNew.bottom += 2;
106 #endif
107 
108  SetWindowPos(pData->hWnd,
109  0 /* HWND_TOP */,
110  0, 0,
111  pData->siPreview.cx, pData->siPreview.cy,
112  // rcNew.right, rcNew.bottom,
114 }
115 
116 #define RescaleCX(pData, len) \
117  MulDiv((len), (pData)->siPreview.cx, (pData)->siVirtScr.cx)
118 
119 #define RescaleCY(pData, len) \
120  MulDiv((len), (pData)->siPreview.cy, (pData)->siVirtScr.cy)
121 
122 #define RescaleRect(pData, rect) \
123 do { \
124  (rect).left = RescaleCX((pData), (rect).left); \
125  (rect).right = RescaleCX((pData), (rect).right); \
126  (rect).top = RescaleCY((pData), (rect).top); \
127  (rect).bottom = RescaleCY((pData), (rect).bottom); \
128 } while (0)
129 
130 #if 0
131 static VOID
132 WinPrev_OnSize(VOID)
133 {
134 }
135 #endif
136 
137 static VOID
139  IN HDC hDC,
141 {
142  PCONSOLE_STATE_INFO pConInfo = (PCONSOLE_STATE_INFO)pData->pData;
143  HBRUSH hBrush;
144  RECT rcWin, fRect;
145  SIZE /*siBorder,*/ siFrame, siButton, siScroll;
146  SIZE resize;
147 
148  RECT rcItem;
149 
150  GetClientRect(pData->hWnd, &rcItem);
151 
152  /*
153  * Retrieve some system metrics and rescale them.
154  * They will be added separately, so that to always round the sizes up.
155  */
156 
157  /* Don't care about border as it is almost always 1 and <= frame size */
158  /* Example: Frame = 4, or 13 ... while Border = 1 */
159  // siBorder.cx = GetSystemMetrics(SM_CXBORDER);
160  // siBorder.cy = GetSystemMetrics(SM_CYBORDER);
161 
162  /* Window frame size */
163  siFrame.cx = GetSystemMetrics(SM_CXFRAME);
164  if (siFrame.cx > 0)
165  {
166  siFrame.cx = RescaleCX(pData, siFrame.cx);
167  siFrame.cx = max(1, siFrame.cx);
168  }
169  siFrame.cy = GetSystemMetrics(SM_CYFRAME);
170  if (siFrame.cy > 0)
171  {
172  siFrame.cy = RescaleCY(pData, siFrame.cy);
173  siFrame.cy = max(1, siFrame.cy);
174  }
175 
176  /* Window caption buttons */
177  siButton.cx = GetSystemMetrics(SM_CXSIZE);
178  siButton.cx = RescaleCX(pData, siButton.cx);
179  siButton.cx = max(1, siButton.cx);
180 
181  siButton.cy = GetSystemMetrics(SM_CYSIZE);
182  siButton.cy = RescaleCY(pData, siButton.cy);
183  siButton.cy = max(1, siButton.cy);
184 
185  /* Enlarge them for improving their appearance */
186  // siButton.cx *= 2;
187  siButton.cy *= 2;
188 
189  /* Dimensions of the scrollbars */
190  siScroll.cx = GetSystemMetrics(SM_CXVSCROLL);
191  siScroll.cx = RescaleCX(pData, siScroll.cx);
192  siScroll.cx = max(1, siScroll.cx);
193 
194  siScroll.cy = GetSystemMetrics(SM_CYHSCROLL);
195  siScroll.cy = RescaleCY(pData, siScroll.cy);
196  siScroll.cy = max(1, siScroll.cy);
197 
198 
199  // FIXME: Use SM_CXMIN, SM_CYMIN ??
200 
201 
202  /*
203  * Compute the console window layout
204  */
205 
206  /* We start with the console client area, rescaled for the preview */
207  SetRect(&rcWin, 0, 0,
208  pConInfo->WindowSize.X * pConInfo->FontSize.X,
209  pConInfo->WindowSize.Y * pConInfo->FontSize.Y);
210  RescaleRect(pData, rcWin);
211 
212  /* Add the scrollbars if needed (does not account for any frame) */
213  if (pConInfo->WindowSize.X < pConInfo->ScreenBufferSize.X)
214  {
215  /* Horizontal scrollbar */
216  rcWin.bottom += siScroll.cy;
217  // NOTE: If an additional exterior frame is needed, add +1
218  }
219  else
220  {
221  /* No scrollbar */
222  siScroll.cy = 0;
223  }
224  if (pConInfo->WindowSize.Y < pConInfo->ScreenBufferSize.Y)
225  {
226  /* Vertical scrollbar */
227  rcWin.right += siScroll.cx;
228  // NOTE: If an additional exterior frame is needed, add +1
229  }
230  else
231  {
232  /* No scrollbar */
233  siScroll.cx = 0;
234  }
235 
236  /* Add the title bar, taking into account the frames */
237  rcWin.top -= siButton.cy - 1;
238 
239  /* If we have a non-zero window frame size, add an interior border and the frame */
240  resize.cx = (siFrame.cx > 0 ? 1 + siFrame.cx : 0);
241  resize.cy = (siFrame.cy > 0 ? 1 + siFrame.cy : 0);
242 
243  /* Add the outer border */
244  ++resize.cx, ++resize.cy;
245 
246  InflateRect(&rcWin, resize.cx, resize.cy);
247 
248  /* Finally, move the window rectangle back to its correct origin */
249  OffsetRect(&rcWin, -rcWin.left, -rcWin.top);
250 
251  if ( pConInfo->WindowPosition.x == MAXDWORD &&
252  pConInfo->WindowPosition.y == MAXDWORD )
253  {
254  // OffsetRect(&rcWin, (rcItem.right - rcItem.left) / 3, (rcItem.bottom - rcItem.top) / 3);
255  OffsetRect(&rcWin, 0, 0);
256  }
257  else
258  {
259  OffsetRect(&rcWin,
260  RescaleCX(pData, pConInfo->WindowPosition.x),
261  RescaleCY(pData, pConInfo->WindowPosition.y));
262  }
263 
264 
265  /*
266  * Paint the preview window
267  */
268 
269  /* Fill the background with desktop colour */
271 
272  /*
273  * Draw the exterior frame. Use 'FillRect' instead of 'FrameRect'
274  * so that, when we want to draw frames around other elements,
275  * we can just instead separate them with space instead of redrawing
276  * a frame with 'FrameRect'.
277  */
279  InflateRect(&rcWin, -1, -1);
280 
281  /* Draw the border */
283  if (siFrame.cx > 0)
284  {
285  SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siFrame.cx, rcWin.bottom);
286  FillRect(hDC, &fRect, hBrush);
287  SetRect(&fRect, rcWin.right - siFrame.cx, rcWin.top, rcWin.right, rcWin.bottom);
288  FillRect(hDC, &fRect, hBrush);
289 
290  InflateRect(&rcWin, -siFrame.cx, 0);
291  }
292  if (siFrame.cy > 0)
293  {
294  SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.top + siFrame.cy);
295  FillRect(hDC, &fRect, hBrush);
296  SetRect(&fRect, rcWin.left, rcWin.bottom - siFrame.cy, rcWin.right, rcWin.bottom);
297  FillRect(hDC, &fRect, hBrush);
298 
299  InflateRect(&rcWin, 0, -siFrame.cy);
300  }
301 
302  /* Draw the interior frame if we had a border */
303  if (siFrame.cx > 0 || siFrame.cy > 0)
304  {
305 #if 0 // See the remark above
306  SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
308 #endif
309  InflateRect(&rcWin, (siFrame.cx > 0 ? -1 : 0), (siFrame.cy > 0 ? -1 : 0));
310  }
311 
312  /* Draw the console window title bar */
314 
315  /* Draw the system menu (left button) */
316  SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siButton.cx, rcWin.top + siButton.cy - 2);
317  // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
318  FillRect(hDC, &fRect, hBrush);
319  fRect.right++; // Separation
320 
321  /* Draw the caption bar */
322  SetRect(&fRect, fRect.right, fRect.top, rcWin.right - 2 * (siButton.cx + 1), fRect.bottom);
324  fRect.right++; // Separation
325 
326  /* Draw the minimize menu (first right button) */
327  SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
328  // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMIN);
329  FillRect(hDC, &fRect, hBrush);
330  fRect.right++; // Separation
331 
332  /* Draw the maximize menu (second right button) */
333  SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
334  // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMAX);
335  FillRect(hDC, &fRect, hBrush);
336 
337  rcWin.top += siButton.cy - 1;
338 
339  /* Add the scrollbars if needed */
340  if (siScroll.cy > 0 || siScroll.cx > 0)
341  {
342  LONG right, bottom;
343 
344  right = rcWin.right;
345  bottom = rcWin.bottom;
346 
347  /*
348  * If both the horizontal and vertical scrollbars are present,
349  * reserve some space for the "dead square" at the bottom right.
350  */
351  if (siScroll.cy > 0 && siScroll.cx > 0)
352  {
353  right -= (1 + siScroll.cx);
354  bottom -= (1 + siScroll.cy);
355  }
356 
358 
359  /* Horizontal scrollbar */
360  if (siScroll.cy > 0)
361  {
362  SetRect(&fRect, rcWin.left, rcWin.bottom - siScroll.cy, right, rcWin.bottom);
363  FillRect(hDC, &fRect, hBrush);
364  }
365 
366  /* Vertical scrollbar */
367  if (siScroll.cx > 0)
368  {
369  SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.top, rcWin.right, bottom);
370  FillRect(hDC, &fRect, hBrush);
371  }
372 
373  /*
374  * If both the horizontal and vertical scrollbars are present,
375  * draw the "dead square" at the bottom right.
376  */
377  if (siScroll.cy > 0 && siScroll.cx > 0)
378  {
379  SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.bottom - siScroll.cy, rcWin.right, rcWin.bottom);
380  FillRect(hDC, &fRect, hBrush);
381  }
382 
383  // NOTE: If an additional exterior frame is needed, remove +1 for each direction
384  rcWin.right -= siScroll.cx;
385  rcWin.bottom -= siScroll.cy;
386  }
387 
388  /* Draw the console background */
389  hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
390  FillRect(hDC, &rcWin, hBrush);
391  DeleteObject(hBrush);
392 }
393 
394 static LRESULT CALLBACK
396 {
398 
400 
401  switch (msg)
402  {
403  case WM_CREATE:
404  {
406  if (!pData)
407  {
408  /* We failed to allocate our private data, halt the window creation */
409  return (LRESULT)-1;
410  }
411  pData->hWnd = hWnd;
412  pData->pData = ConInfo;
413  GetClientRect(pData->hWnd, &pData->rcMaxArea);
414  // LPCREATESTRUCT::cx and cy give window (not client) size
417  break;
418  }
419 
420  case WM_DESTROY:
421  {
422  if (pData)
424  break;
425  }
426 
427  case WM_DISPLAYCHANGE:
428  {
431  // InvalidateRect(hWnd, NULL, FALSE);
432  break;
433  }
434 
435  case WM_SIZE:
436  break;
437 
438  case WM_ERASEBKGND:
439  return 1;
440 
441  case WM_PAINT:
442  {
443  PAINTSTRUCT ps;
444  BeginPaint(hWnd, &ps);
445  WinPrev_OnDraw(ps.hdc, pData);
446  EndPaint(hWnd, &ps);
447  return 0;
448  }
449  }
450 
451  return DefWindowProcW(hWnd, msg, wParam, lParam);
452 }
453 
454 
455 /* CONSOLE TEXT PREVIEW *******************************************************/
456 
458  L"C:\\ReactOS> dir \n" \
459  L"SYSTEM <DIR> 13-04-15 5:00a\n" \
460  L"SYSTEM32 <DIR> 13-04-15 5:00a\n" \
461  L"readme txt 1739 13-04-15 5:00a\n" \
462  L"explorer exe 3329536 13-04-15 5:00a\n" \
463  L"vgafonts cab 18736 13-04-15 5:00a\n" \
464  L"setuplog txt 313 13-04-15 5:00a\n" \
465  L"win ini 7005 13-04-15 5:00a\n" ;
466 
467 VOID
469  IN LPDRAWITEMSTRUCT drawItem,
470  IN PCONSOLE_STATE_INFO pConInfo,
471  IN TEXT_TYPE TextMode)
472 {
473  USHORT CurrentAttrib;
474  COLORREF pbkColor, ptColor;
475  COLORREF nbkColor, ntColor;
476  HBRUSH hBrush;
477  HFONT hOldFont;
478 
479  if (TextMode == Screen)
480  CurrentAttrib = pConInfo->ScreenAttributes;
481  else if (TextMode == Popup)
482  CurrentAttrib = pConInfo->PopupAttributes;
483  else
484  return;
485 
486  nbkColor = pConInfo->ColorTable[BkgdAttribFromAttrib(CurrentAttrib)];
487  ntColor = pConInfo->ColorTable[TextAttribFromAttrib(CurrentAttrib)];
488 
489  hBrush = CreateSolidBrush(nbkColor);
490  if (!hBrush) return;
491 
492  hOldFont = SelectObject(drawItem->hDC, hCurrentFont);
493  //if (hOldFont == NULL)
494  //{
495  // DeleteObject(hBrush);
496  // return;
497  //}
498 
499  FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
500 
501  /* Add a few space between the preview window border and the text sample */
502  InflateRect(&drawItem->rcItem, -2, -2);
503 
504  ptColor = SetTextColor(drawItem->hDC, ntColor);
505  pbkColor = SetBkColor(drawItem->hDC, nbkColor);
506  DrawTextW(drawItem->hDC, szPreviewText, (INT)wcslen(szPreviewText), &drawItem->rcItem, 0);
507  SetTextColor(drawItem->hDC, ptColor);
508  SetBkColor(drawItem->hDC, pbkColor);
509 
510  SelectObject(drawItem->hDC, hOldFont);
511  DeleteObject(hBrush);
512 }
513 
514 
515 /* LAYOUT DIALOG **************************************************************/
516 
517 INT_PTR
518 CALLBACK
520  UINT uMsg,
521  WPARAM wParam,
522  LPARAM lParam)
523 {
524  switch (uMsg)
525  {
526  case WM_INITDIALOG:
527  {
528  /* Multi-monitor support */
529  LONG xVirtScr, yVirtScr; // Coordinates of the top-left virtual screen
530  LONG cxVirtScr, cyVirtScr; // Width and Height of the virtual screen
531  LONG cxFrame , cyFrame ; // Thickness of the window frame
532 
537  cxFrame = GetSystemMetrics(SM_CXFRAME);
538  cyFrame = GetSystemMetrics(SM_CYFRAME);
539 
544 
549 
551  (LPARAM)MAKELONG(xVirtScr + cxVirtScr - cxFrame, xVirtScr - cxFrame));
553  (LPARAM)MAKELONG(yVirtScr + cyVirtScr - cyFrame, yVirtScr - cyFrame));
554 
557 
558  if (ConInfo->AutoPosition)
559  {
564  }
567 
568  return TRUE;
569  }
570 
571  case WM_DISPLAYCHANGE:
572  {
573  /* Retransmit to the preview window */
575  WM_DISPLAYCHANGE, wParam, lParam);
576  break;
577  }
578 
579  case WM_NOTIFY:
580  {
581  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
582 
583  if (lppsn->hdr.code == UDN_DELTAPOS)
584  {
585  LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
586  DWORD wheight, wwidth;
587  DWORD sheight, swidth;
588  DWORD left, top;
589 
591  {
592  wwidth = lpnmud->iPos + lpnmud->iDelta;
593  }
594  else
595  {
597  }
598 
600  {
601  wheight = lpnmud->iPos + lpnmud->iDelta;
602  }
603  else
604  {
606  }
607 
609  {
610  swidth = lpnmud->iPos + lpnmud->iDelta;
611  }
612  else
613  {
615  }
616 
618  {
619  sheight = lpnmud->iPos + lpnmud->iDelta;
620  }
621  else
622  {
624  }
625 
626  if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_LEFT)
627  {
628  left = lpnmud->iPos + lpnmud->iDelta;
629  }
630  else
631  {
633  }
634 
635  if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_TOP)
636  {
637  top = lpnmud->iPos + lpnmud->iDelta;
638  }
639  else
640  {
642  }
643 
645  {
646  /* Automatically adjust screen buffer size when window size enlarges */
647  if (wwidth >= swidth)
648  {
650  swidth = wwidth;
651  }
652  if (wheight >= sheight)
653  {
655  sheight = wheight;
656  }
657  }
658 
659  /* Be sure that the (new) screen buffer sizes are in the correct range */
660  swidth = min(max(swidth , 1), 0xFFFF);
661  sheight = min(max(sheight, 1), 0xFFFF);
662 
664  {
665  /* Automatically adjust window size when screen buffer decreases */
666  if (wwidth > swidth)
667  {
669  wwidth = swidth;
670  }
671  if (wheight > sheight)
672  {
674  wheight = sheight;
675  }
676  }
677 
678  ConInfo->ScreenBufferSize.X = (SHORT)swidth;
679  ConInfo->ScreenBufferSize.Y = (SHORT)sheight;
680  ConInfo->WindowSize.X = (SHORT)wwidth;
681  ConInfo->WindowSize.Y = (SHORT)wheight;
684 
686  PropSheet_Changed(GetParent(hDlg), hDlg);
687  }
688  break;
689  }
690 
691  case WM_COMMAND:
692  {
693  if (HIWORD(wParam) == EN_KILLFOCUS)
694  {
695  switch (LOWORD(wParam))
696  {
698  {
699  DWORD swidth, wwidth;
700 
703 
704  /* Be sure that the (new) screen buffer width is in the correct range */
705  swidth = min(max(swidth, 1), 0xFFFF);
706 
707  /* Automatically adjust window size when screen buffer decreases */
708  if (wwidth > swidth)
709  {
710  wwidth = swidth;
712  }
713 
714  ConInfo->ScreenBufferSize.X = (SHORT)swidth;
715  ConInfo->WindowSize.X = (SHORT)wwidth;
716 
718  PropSheet_Changed(GetParent(hDlg), hDlg);
719  break;
720  }
721 
723  {
724  DWORD swidth, wwidth;
725 
728 
729  /* Automatically adjust screen buffer size when window size enlarges */
730  if (wwidth >= swidth)
731  {
732  swidth = wwidth;
733 
734  /* Be sure that the (new) screen buffer width is in the correct range */
735  swidth = min(max(swidth, 1), 0xFFFF);
736 
738  }
739 
740  ConInfo->ScreenBufferSize.X = (SHORT)swidth;
741  ConInfo->WindowSize.X = (SHORT)wwidth;
742 
744  PropSheet_Changed(GetParent(hDlg), hDlg);
745  break;
746  }
747 
749  {
750  DWORD sheight, wheight;
751 
754 
755  /* Be sure that the (new) screen buffer width is in the correct range */
756  sheight = min(max(sheight, 1), 0xFFFF);
757 
758  /* Automatically adjust window size when screen buffer decreases */
759  if (wheight > sheight)
760  {
761  wheight = sheight;
763  }
764 
765  ConInfo->ScreenBufferSize.Y = (SHORT)sheight;
766  ConInfo->WindowSize.Y = (SHORT)wheight;
767 
769  PropSheet_Changed(GetParent(hDlg), hDlg);
770  break;
771  }
772 
774  {
775  DWORD sheight, wheight;
776 
779 
780  /* Automatically adjust screen buffer size when window size enlarges */
781  if (wheight >= sheight)
782  {
783  sheight = wheight;
784 
785  /* Be sure that the (new) screen buffer width is in the correct range */
786  sheight = min(max(sheight, 1), 0xFFFF);
787 
789  }
790 
791  ConInfo->ScreenBufferSize.Y = (SHORT)sheight;
792  ConInfo->WindowSize.Y = (SHORT)wheight;
793 
795  PropSheet_Changed(GetParent(hDlg), hDlg);
796  break;
797  }
798 
801  {
804 
806  PropSheet_Changed(GetParent(hDlg), hDlg);
807  break;
808  }
809  }
810  }
811  else
812  if (HIWORD(wParam) == BN_CLICKED &&
814  {
816  {
821 
823  // Do not touch ConInfo->WindowPosition !!
824 
826  PropSheet_Changed(GetParent(hDlg), hDlg);
827  }
828  else
829  {
830  ULONG left, top;
831 
834 
839 
843 
845  PropSheet_Changed(GetParent(hDlg), hDlg);
846  }
847  }
848 
849  break;
850  }
851 
852  default:
853  break;
854  }
855 
856  return FALSE;
857 }
SIZE siVirtScr
Definition: layout.c:24
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IN
Definition: typedefs.h:38
#define max(a, b)
Definition: svc.c:63
#define IDC_EDIT_WINDOW_SIZE_WIDTH
Definition: resource.h:55
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define COLOR_WINDOWFRAME
Definition: winuser.h:909
#define SM_CYSIZE
Definition: winuser.h:982
BOOL RegisterWinPrevClass(IN HINSTANCE hInstance)
Definition: layout.c:32
USHORT ScreenAttributes
Definition: settings.h:47
long y
Definition: polytest.cpp:48
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
HFONT hCurrentFont
Definition: font.c:21
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
long x
Definition: polytest.cpp:48
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
struct _PSHNOTIFY * LPPSHNOTIFY
POINT WindowPosition
Definition: settings.h:34
struct _NM_UPDOWN * LPNMUPDOWN
static LRESULT CALLBACK WinPrevProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: layout.c:395
VOID PaintText(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo, IN TEXT_TYPE TextMode)
Definition: layout.c:468
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static VOID WinPrev_OnDisplayChange(IN PWINPREV_DATA pData)
Definition: layout.c:59
RECT rcMaxArea
Definition: layout.c:22
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SM_CYFRAME
Definition: winuser.h:986
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
int32_t INT_PTR
Definition: typedefs.h:62
#define SM_CXFRAME
Definition: winuser.h:984
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT code
Definition: winuser.h:3112
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
NMHDR hdr
Definition: prsht.h:312
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
HINSTANCE hInstance
Definition: charmap.c:20
#define EN_KILLFOCUS
Definition: winuser.h:1986
struct _WINPREV_DATA WINPREV_DATA
struct _WINPREV_DATA * PWINPREV_DATA
#define IDC_UPDOWN_WINDOW_SIZE_HEIGHT
Definition: resource.h:58
#define IDC_EDIT_WINDOW_POS_TOP
Definition: resource.h:61
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define COLOR_SCROLLBAR
Definition: winuser.h:902
short SHORT
Definition: pedump.c:59
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
UINT_PTR idFrom
Definition: winuser.h:3111
COLORREF ColorTable[16]
Definition: settings.h:53
#define IDC_UPDOWN_WINDOW_POS_TOP
Definition: resource.h:62
#define GWLP_USERDATA
Definition: treelist.c:63
#define MAKELONG(a, b)
Definition: typedefs.h:248
HWND hWnd
Definition: layout.c:21
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define COLOR_ACTIVECAPTION
Definition: winuser.h:905
#define MAXDWORD
#define IDC_STATIC_LAYOUT_WINDOW_PREVIEW
Definition: resource.h:64
LONG_PTR LPARAM
Definition: windef.h:208
GLint GLint bottom
Definition: glext.h:7726
#define IDC_UPDOWN_SCREEN_BUFFER_WIDTH
Definition: resource.h:51
#define UDM_SETRANGE
Definition: commctrl.h:2113
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
struct _CONSOLE_STATE_INFO * PCONSOLE_STATE_INFO
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
#define WM_DESTROY
Definition: winuser.h:1591
#define BkgdAttribFromAttrib(Attribute)
Definition: settings.h:73
ULONG X
Definition: bl.h:1340
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDC_UPDOWN_WINDOW_POS_LEFT
Definition: resource.h:60
#define WM_SIZE
Definition: winuser.h:1593
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define SWP_NOACTIVATE
Definition: winuser.h:1227
DWORD COLORREF
Definition: windef.h:285
#define RescaleRect(pData, rect)
Definition: layout.c:122
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define COLOR_ACTIVEBORDER
Definition: winuser.h:913
int WINAPI GetSystemMetrics(_In_ int)
#define BN_CLICKED
Definition: winuser.h:1886
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLdouble GLdouble right
Definition: glext.h:10859
SIZE siPreview
Definition: layout.c:23
#define WM_PAINT
Definition: winuser.h:1602
const WCHAR szPreviewText[]
Definition: layout.c:457
#define IDC_EDIT_WINDOW_POS_LEFT
Definition: resource.h:59
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define UDN_DELTAPOS
Definition: commctrl.h:2141
static const WCHAR L[]
Definition: oid.c:1250
#define COLOR_BTNFACE
Definition: winuser.h:918
#define IDC_EDIT_WINDOW_SIZE_HEIGHT
Definition: resource.h:57
#define RescaleCY(pData, len)
Definition: layout.c:119
enum _TEXT_TYPE TEXT_TYPE
#define WM_COMMAND
Definition: winuser.h:1716
#define RescaleCX(pData, len)
Definition: layout.c:116
INT_PTR CALLBACK LayoutProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: layout.c:519
#define TextAttribFromAttrib(Attribute)
Definition: settings.h:72
#define BST_UNCHECKED
Definition: winuser.h:199
Definition: console.h:35
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
#define IDC_UPDOWN_WINDOW_SIZE_WIDTH
Definition: resource.h:56
#define IDC_EDIT_SCREEN_BUFFER_HEIGHT
Definition: resource.h:53
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:884
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int iDelta
Definition: commctrl.h:2138
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define WS_BORDER
Definition: pedump.c:625
#define IDC_CHECK_SYSTEM_POS_WINDOW
Definition: resource.h:63
unsigned short USHORT
Definition: pedump.c:61
#define EnableDlgItem(hDlg, nID, bEnable)
Definition: eventvwr.h:52
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
PCONSOLE_STATE_INFO ConInfo
Definition: console.c:23
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define SM_CXVSCROLL
Definition: winuser.h:951
#define BST_CHECKED
Definition: winuser.h:197
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WM_CREATE
Definition: winuser.h:1590
#define SM_CXSIZE
Definition: winuser.h:981
COORD ScreenBufferSize
Definition: settings.h:32
BOOL UnRegisterWinPrevClass(IN HINSTANCE hInstance)
Definition: layout.c:52
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
Definition: console.h:34
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define COLOR_BACKGROUND
Definition: hardware.h:164
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
#define WM_ERASEBKGND
Definition: winuser.h:1607
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG_PTR LRESULT
Definition: windef.h:209
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
ULONG Y
Definition: bl.h:1341
#define WM_INITDIALOG
Definition: winuser.h:1715
PVOID pData
Definition: layout.c:25
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
static VOID WinPrev_OnDraw(IN HDC hDC, IN PWINPREV_DATA pData)
Definition: layout.c:138
#define WM_NOTIFY
Definition: richedit.h:61
WCHAR WndClass[]
Definition: capicon.c:23
#define IDC_UPDOWN_SCREEN_BUFFER_HEIGHT
Definition: resource.h:54
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define IDC_EDIT_SCREEN_BUFFER_WIDTH
Definition: resource.h:52
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
#define WIN_PREVIEW_CLASS
Definition: layout.c:17