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)
15 /* CONSOLE WINDOW PREVIEW Control *********************************************/
17 #define WIN_PREVIEW_CLASS L"WinPreview"
19 typedef struct _WINPREV_DATA
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
26 } WINPREV_DATA
, *PWINPREV_DATA
;
28 static LRESULT CALLBACK
29 WinPrevProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
33 IN HINSTANCE hInstance
)
37 WndClass
.lpszClassName
= WIN_PREVIEW_CLASS
;
38 WndClass
.lpfnWndProc
= WinPrevProc
;
40 WndClass
.hInstance
= hInstance
;
41 WndClass
.hIcon
= NULL
;
42 WndClass
.hCursor
= LoadCursorW(NULL
, MAKEINTRESOURCEW(IDC_ARROW
));
43 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BACKGROUND
+ 1);
44 WndClass
.lpszMenuName
= NULL
;
45 WndClass
.cbClsExtra
= 0;
46 WndClass
.cbWndExtra
= 0; // sizeof(PWINPREV_DATA);
48 return (RegisterClassW(&WndClass
) != 0);
52 UnRegisterWinPrevClass(
53 IN HINSTANCE hInstance
)
55 return UnregisterClassW(WIN_PREVIEW_CLASS
, hInstance
);
59 WinPrev_OnDisplayChange(
60 IN PWINPREV_DATA pData
)
64 pData
->siVirtScr
.cx
= GetSystemMetrics(SM_CXVIRTUALSCREEN
);
65 pData
->siVirtScr
.cy
= GetSystemMetrics(SM_CYVIRTUALSCREEN
);
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.
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
)
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
);
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
);
87 * Now, the lengths in screen-units can be rescaled into preview-units with:
88 * MulDiv(cx, pData->siPreview.cx, pData->siVirtScr.cx);
90 * MulDiv(cy, pData->siPreview.cy, pData->siVirtScr.cy);
93 #if 0 // TODO: Investigate!
95 * Since both rcMaxArea and siPreview are client window area sizes,
96 * transform them into window sizes.
98 SetRect(&rcNew
, 0, 0, pData
->siPreview
.cx
, pData
->siPreview
.cy
);
99 AdjustWindowRect(&rcNew
,
101 // GetWindowLongPtrW(pData->hWnd, GWL_STYLE) & ~WS_OVERLAPPED,
103 OffsetRect(&rcNew
, -rcNew
.left
, -rcNew
.top
);
108 SetWindowPos(pData
->hWnd
,
111 pData
->siPreview
.cx
, pData
->siPreview
.cy
,
112 // rcNew.right, rcNew.bottom,
113 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
116 #define RescaleCX(pData, len) \
117 MulDiv((len), (pData)->siPreview.cx, (pData)->siVirtScr.cx)
119 #define RescaleCY(pData, len) \
120 MulDiv((len), (pData)->siPreview.cy, (pData)->siVirtScr.cy)
122 #define RescaleRect(pData, rect) \
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); \
140 IN PWINPREV_DATA pData
)
142 PCONSOLE_STATE_INFO pConInfo
= (PCONSOLE_STATE_INFO
)pData
->pData
;
145 SIZE
/*siBorder,*/ siFrame
, siButton
, siScroll
;
150 GetClientRect(pData
->hWnd
, &rcItem
);
153 * Retrieve some system metrics and rescale them.
154 * They will be added separately, so that to always round the sizes up.
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);
162 /* Window frame size */
163 siFrame
.cx
= GetSystemMetrics(SM_CXFRAME
);
166 siFrame
.cx
= RescaleCX(pData
, siFrame
.cx
);
167 siFrame
.cx
= max(1, siFrame
.cx
);
169 siFrame
.cy
= GetSystemMetrics(SM_CYFRAME
);
172 siFrame
.cy
= RescaleCY(pData
, siFrame
.cy
);
173 siFrame
.cy
= max(1, siFrame
.cy
);
176 /* Window caption buttons */
177 siButton
.cx
= GetSystemMetrics(SM_CXSIZE
);
178 siButton
.cx
= RescaleCX(pData
, siButton
.cx
);
179 siButton
.cx
= max(1, siButton
.cx
);
181 siButton
.cy
= GetSystemMetrics(SM_CYSIZE
);
182 siButton
.cy
= RescaleCY(pData
, siButton
.cy
);
183 siButton
.cy
= max(1, siButton
.cy
);
185 /* Enlarge them for improving their appearance */
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
);
194 siScroll
.cy
= GetSystemMetrics(SM_CYHSCROLL
);
195 siScroll
.cy
= RescaleCY(pData
, siScroll
.cy
);
196 siScroll
.cy
= max(1, siScroll
.cy
);
199 // FIXME: Use SM_CXMIN, SM_CYMIN ??
203 * Compute the console window layout
206 /* We start with the console client area, rescaled for the preview */
207 SetRect(&rcWin
, 0, 0,
208 pConInfo
->WindowSize
.X
* FontPreview
.CharWidth
,
209 pConInfo
->WindowSize
.Y
* FontPreview
.CharHeight
);
210 RescaleRect(pData
, rcWin
);
212 /* Add the scrollbars if needed (does not account for any frame) */
213 if (pConInfo
->WindowSize
.X
< pConInfo
->ScreenBufferSize
.X
)
215 /* Horizontal scrollbar */
216 rcWin
.bottom
+= siScroll
.cy
;
217 // NOTE: If an additional exterior frame is needed, add +1
224 if (pConInfo
->WindowSize
.Y
< pConInfo
->ScreenBufferSize
.Y
)
226 /* Vertical scrollbar */
227 rcWin
.right
+= siScroll
.cx
;
228 // NOTE: If an additional exterior frame is needed, add +1
236 /* Add the title bar, taking into account the frames */
237 rcWin
.top
-= siButton
.cy
- 1;
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);
243 /* Add the outer border */
244 ++resize
.cx
, ++resize
.cy
;
246 InflateRect(&rcWin
, resize
.cx
, resize
.cy
);
248 /* Finally, move the window rectangle back to its correct origin */
249 OffsetRect(&rcWin
, -rcWin
.left
, -rcWin
.top
);
251 if ( pConInfo
->WindowPosition
.x
== MAXDWORD
&&
252 pConInfo
->WindowPosition
.y
== MAXDWORD
)
254 // OffsetRect(&rcWin, (rcItem.right - rcItem.left) / 3, (rcItem.bottom - rcItem.top) / 3);
255 OffsetRect(&rcWin
, 0, 0);
260 RescaleCX(pData
, pConInfo
->WindowPosition
.x
),
261 RescaleCY(pData
, pConInfo
->WindowPosition
.y
));
266 * Paint the preview window
269 /* Fill the background with desktop colour */
270 FillRect(hDC
, &rcItem
, GetSysColorBrush(COLOR_BACKGROUND
));
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'.
278 FillRect(hDC
, &rcWin
, GetSysColorBrush(COLOR_WINDOWFRAME
));
279 InflateRect(&rcWin
, -1, -1);
281 /* Draw the border */
282 hBrush
= GetSysColorBrush(COLOR_ACTIVEBORDER
);
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
);
290 InflateRect(&rcWin
, -siFrame
.cx
, 0);
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
);
299 InflateRect(&rcWin
, 0, -siFrame
.cy
);
302 /* Draw the interior frame if we had a border */
303 if (siFrame
.cx
> 0 || siFrame
.cy
> 0)
305 #if 0 // See the remark above
306 SetRect(&fRect
, rcWin
.left
, rcWin
.top
, rcWin
.right
, rcWin
.bottom
);
307 FrameRect(hDC
, &fRect
, GetSysColorBrush(COLOR_WINDOWFRAME
));
309 InflateRect(&rcWin
, (siFrame
.cx
> 0 ? -1 : 0), (siFrame
.cy
> 0 ? -1 : 0));
312 /* Draw the console window title bar */
313 hBrush
= GetSysColorBrush(COLOR_BTNFACE
);
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
321 /* Draw the caption bar */
322 SetRect(&fRect
, fRect
.right
, fRect
.top
, rcWin
.right
- 2 * (siButton
.cx
+ 1), fRect
.bottom
);
323 FillRect(hDC
, &fRect
, GetSysColorBrush(COLOR_ACTIVECAPTION
));
324 fRect
.right
++; // Separation
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
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
);
337 rcWin
.top
+= siButton
.cy
- 1;
339 /* Add the scrollbars if needed */
340 if (siScroll
.cy
> 0 || siScroll
.cx
> 0)
345 bottom
= rcWin
.bottom
;
348 * If both the horizontal and vertical scrollbars are present,
349 * reserve some space for the "dead square" at the bottom right.
351 if (siScroll
.cy
> 0 && siScroll
.cx
> 0)
353 right
-= (1 + siScroll
.cx
);
354 bottom
-= (1 + siScroll
.cy
);
357 hBrush
= GetSysColorBrush(COLOR_SCROLLBAR
);
359 /* Horizontal scrollbar */
362 SetRect(&fRect
, rcWin
.left
, rcWin
.bottom
- siScroll
.cy
, right
, rcWin
.bottom
);
363 FillRect(hDC
, &fRect
, hBrush
);
366 /* Vertical scrollbar */
369 SetRect(&fRect
, rcWin
.right
- siScroll
.cx
, rcWin
.top
, rcWin
.right
, bottom
);
370 FillRect(hDC
, &fRect
, hBrush
);
374 * If both the horizontal and vertical scrollbars are present,
375 * draw the "dead square" at the bottom right.
377 if (siScroll
.cy
> 0 && siScroll
.cx
> 0)
379 SetRect(&fRect
, rcWin
.right
- siScroll
.cx
, rcWin
.bottom
- siScroll
.cy
, rcWin
.right
, rcWin
.bottom
);
380 FillRect(hDC
, &fRect
, hBrush
);
383 // NOTE: If an additional exterior frame is needed, remove +1 for each direction
384 rcWin
.right
-= siScroll
.cx
;
385 rcWin
.bottom
-= siScroll
.cy
;
388 /* Draw the console background */
389 hBrush
= CreateSolidBrush(pConInfo
->ColorTable
[BkgdAttribFromAttrib(pConInfo
->ScreenAttributes
)]);
390 FillRect(hDC
, &rcWin
, hBrush
);
391 DeleteObject(hBrush
);
394 static LRESULT CALLBACK
395 WinPrevProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
399 pData
= (PWINPREV_DATA
)GetWindowLongPtrW(hWnd
, GWLP_USERDATA
);
405 pData
= (PWINPREV_DATA
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*pData
));
408 /* We failed to allocate our private data, halt the window creation */
412 pData
->pData
= ConInfo
;
413 GetClientRect(pData
->hWnd
, &pData
->rcMaxArea
);
414 // LPCREATESTRUCT::cx and cy give window (not client) size
415 WinPrev_OnDisplayChange(pData
);
416 SetWindowLongPtrW(hWnd
, GWLP_USERDATA
, (LONG_PTR
)pData
);
423 HeapFree(GetProcessHeap(), 0, pData
);
427 case WM_DISPLAYCHANGE
:
429 WinPrev_OnDisplayChange(pData
);
431 // InvalidateRect(hWnd, NULL, FALSE);
444 BeginPaint(hWnd
, &ps
);
445 WinPrev_OnDraw(ps
.hdc
, pData
);
451 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
455 /* CONSOLE TEXT PREVIEW *******************************************************/
457 const WCHAR szPreviewText
[] =
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" ;
469 IN LPDRAWITEMSTRUCT drawItem
,
470 IN PCONSOLE_STATE_INFO pConInfo
,
471 IN TEXT_TYPE TextMode
)
473 USHORT CurrentAttrib
;
474 COLORREF pbkColor
, ptColor
;
475 COLORREF nbkColor
, ntColor
;
479 if (TextMode
== Screen
)
480 CurrentAttrib
= pConInfo
->ScreenAttributes
;
481 else if (TextMode
== Popup
)
482 CurrentAttrib
= pConInfo
->PopupAttributes
;
486 nbkColor
= pConInfo
->ColorTable
[BkgdAttribFromAttrib(CurrentAttrib
)];
487 ntColor
= pConInfo
->ColorTable
[TextAttribFromAttrib(CurrentAttrib
)];
489 hBrush
= CreateSolidBrush(nbkColor
);
492 hOldFont
= SelectObject(drawItem
->hDC
, FontPreview
.hFont
);
493 //if (hOldFont == NULL)
495 // DeleteObject(hBrush);
499 FillRect(drawItem
->hDC
, &drawItem
->rcItem
, hBrush
);
501 /* Add a few space between the preview window border and the text sample */
502 InflateRect(&drawItem
->rcItem
, -2, -2);
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
);
510 SelectObject(drawItem
->hDC
, hOldFont
);
511 DeleteObject(hBrush
);
515 /* LAYOUT DIALOG **************************************************************/
519 LayoutProc(HWND hDlg
,
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
533 xVirtScr
= GetSystemMetrics(SM_XVIRTUALSCREEN
);
534 yVirtScr
= GetSystemMetrics(SM_YVIRTUALSCREEN
);
535 cxVirtScr
= GetSystemMetrics(SM_CXVIRTUALSCREEN
);
536 cyVirtScr
= GetSystemMetrics(SM_CYVIRTUALSCREEN
);
537 cxFrame
= GetSystemMetrics(SM_CXFRAME
);
538 cyFrame
= GetSystemMetrics(SM_CYFRAME
);
540 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_SCREEN_BUFFER_HEIGHT
, UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(9999, 1));
541 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_SCREEN_BUFFER_WIDTH
, UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(9999, 1));
542 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_WINDOW_SIZE_HEIGHT
, UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(9999, 1));
543 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_WINDOW_SIZE_WIDTH
, UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(9999, 1));
545 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, ConInfo
->ScreenBufferSize
.Y
, FALSE
);
546 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, ConInfo
->ScreenBufferSize
.X
, FALSE
);
547 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, ConInfo
->WindowSize
.Y
, FALSE
);
548 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, ConInfo
->WindowSize
.X
, FALSE
);
550 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_WINDOW_POS_LEFT
, UDM_SETRANGE
, 0,
551 (LPARAM
)MAKELONG(xVirtScr
+ cxVirtScr
- cxFrame
, xVirtScr
- cxFrame
));
552 SendDlgItemMessageW(hDlg
, IDC_UPDOWN_WINDOW_POS_TOP
, UDM_SETRANGE
, 0,
553 (LPARAM
)MAKELONG(yVirtScr
+ cyVirtScr
- cyFrame
, yVirtScr
- cyFrame
));
555 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, ConInfo
->WindowPosition
.x
, TRUE
);
556 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, ConInfo
->WindowPosition
.y
, TRUE
);
558 if (ConInfo
->AutoPosition
)
560 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, FALSE
);
561 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, FALSE
);
562 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_LEFT
, FALSE
);
563 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_TOP
, FALSE
);
565 CheckDlgButton(hDlg
, IDC_CHECK_SYSTEM_POS_WINDOW
,
566 ConInfo
->AutoPosition
? BST_CHECKED
: BST_UNCHECKED
);
571 case WM_DISPLAYCHANGE
:
573 /* Retransmit to the preview window */
574 SendDlgItemMessageW(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
,
575 WM_DISPLAYCHANGE
, wParam
, lParam
);
581 LPPSHNOTIFY lppsn
= (LPPSHNOTIFY
)lParam
;
583 if (lppsn
->hdr
.code
== UDN_DELTAPOS
)
585 LPNMUPDOWN lpnmud
= (LPNMUPDOWN
)lParam
;
586 DWORD wheight
, wwidth
;
587 DWORD sheight
, swidth
;
590 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_SIZE_WIDTH
)
592 wwidth
= lpnmud
->iPos
+ lpnmud
->iDelta
;
596 wwidth
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, NULL
, FALSE
);
599 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_SIZE_HEIGHT
)
601 wheight
= lpnmud
->iPos
+ lpnmud
->iDelta
;
605 wheight
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, NULL
, FALSE
);
608 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_SCREEN_BUFFER_WIDTH
)
610 swidth
= lpnmud
->iPos
+ lpnmud
->iDelta
;
614 swidth
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, NULL
, FALSE
);
617 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_SCREEN_BUFFER_HEIGHT
)
619 sheight
= lpnmud
->iPos
+ lpnmud
->iDelta
;
623 sheight
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, NULL
, FALSE
);
626 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_POS_LEFT
)
628 left
= lpnmud
->iPos
+ lpnmud
->iDelta
;
632 left
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, NULL
, TRUE
);
635 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_POS_TOP
)
637 top
= lpnmud
->iPos
+ lpnmud
->iDelta
;
641 top
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, NULL
, TRUE
);
644 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_SIZE_WIDTH
|| lppsn
->hdr
.idFrom
== IDC_UPDOWN_WINDOW_SIZE_HEIGHT
)
646 /* Automatically adjust screen buffer size when window size enlarges */
647 if (wwidth
>= swidth
)
649 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, wwidth
, TRUE
);
652 if (wheight
>= sheight
)
654 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, wheight
, TRUE
);
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);
663 if (lppsn
->hdr
.idFrom
== IDC_UPDOWN_SCREEN_BUFFER_WIDTH
|| lppsn
->hdr
.idFrom
== IDC_UPDOWN_SCREEN_BUFFER_HEIGHT
)
665 /* Automatically adjust window size when screen buffer decreases */
668 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, swidth
, TRUE
);
671 if (wheight
> sheight
)
673 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, sheight
, TRUE
);
678 ConInfo
->ScreenBufferSize
.X
= (SHORT
)swidth
;
679 ConInfo
->ScreenBufferSize
.Y
= (SHORT
)sheight
;
680 ConInfo
->WindowSize
.X
= (SHORT
)wwidth
;
681 ConInfo
->WindowSize
.Y
= (SHORT
)wheight
;
682 ConInfo
->WindowPosition
.x
= left
;
683 ConInfo
->WindowPosition
.y
= top
;
685 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
686 PropSheet_Changed(GetParent(hDlg
), hDlg
);
693 if (HIWORD(wParam
) == EN_KILLFOCUS
)
695 switch (LOWORD(wParam
))
697 case IDC_EDIT_SCREEN_BUFFER_WIDTH
:
699 DWORD swidth
, wwidth
;
701 swidth
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, NULL
, FALSE
);
702 wwidth
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, NULL
, FALSE
);
704 /* Be sure that the (new) screen buffer width is in the correct range */
705 swidth
= min(max(swidth
, 1), 0xFFFF);
707 /* Automatically adjust window size when screen buffer decreases */
711 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, wwidth
, TRUE
);
714 ConInfo
->ScreenBufferSize
.X
= (SHORT
)swidth
;
715 ConInfo
->WindowSize
.X
= (SHORT
)wwidth
;
717 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
718 PropSheet_Changed(GetParent(hDlg
), hDlg
);
722 case IDC_EDIT_WINDOW_SIZE_WIDTH
:
724 DWORD swidth
, wwidth
;
726 swidth
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, NULL
, FALSE
);
727 wwidth
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_WIDTH
, NULL
, FALSE
);
729 /* Automatically adjust screen buffer size when window size enlarges */
730 if (wwidth
>= swidth
)
734 /* Be sure that the (new) screen buffer width is in the correct range */
735 swidth
= min(max(swidth
, 1), 0xFFFF);
737 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_WIDTH
, swidth
, TRUE
);
740 ConInfo
->ScreenBufferSize
.X
= (SHORT
)swidth
;
741 ConInfo
->WindowSize
.X
= (SHORT
)wwidth
;
743 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
744 PropSheet_Changed(GetParent(hDlg
), hDlg
);
748 case IDC_EDIT_SCREEN_BUFFER_HEIGHT
:
750 DWORD sheight
, wheight
;
752 sheight
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, NULL
, FALSE
);
753 wheight
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, NULL
, FALSE
);
755 /* Be sure that the (new) screen buffer width is in the correct range */
756 sheight
= min(max(sheight
, 1), 0xFFFF);
758 /* Automatically adjust window size when screen buffer decreases */
759 if (wheight
> sheight
)
762 SetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, wheight
, TRUE
);
765 ConInfo
->ScreenBufferSize
.Y
= (SHORT
)sheight
;
766 ConInfo
->WindowSize
.Y
= (SHORT
)wheight
;
768 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
769 PropSheet_Changed(GetParent(hDlg
), hDlg
);
773 case IDC_EDIT_WINDOW_SIZE_HEIGHT
:
775 DWORD sheight
, wheight
;
777 sheight
= GetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, NULL
, FALSE
);
778 wheight
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_SIZE_HEIGHT
, NULL
, FALSE
);
780 /* Automatically adjust screen buffer size when window size enlarges */
781 if (wheight
>= sheight
)
785 /* Be sure that the (new) screen buffer width is in the correct range */
786 sheight
= min(max(sheight
, 1), 0xFFFF);
788 SetDlgItemInt(hDlg
, IDC_EDIT_SCREEN_BUFFER_HEIGHT
, sheight
, TRUE
);
791 ConInfo
->ScreenBufferSize
.Y
= (SHORT
)sheight
;
792 ConInfo
->WindowSize
.Y
= (SHORT
)wheight
;
794 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
795 PropSheet_Changed(GetParent(hDlg
), hDlg
);
799 case IDC_EDIT_WINDOW_POS_LEFT
:
800 case IDC_EDIT_WINDOW_POS_TOP
:
802 ConInfo
->WindowPosition
.x
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, NULL
, TRUE
);
803 ConInfo
->WindowPosition
.y
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, NULL
, TRUE
);
805 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
806 PropSheet_Changed(GetParent(hDlg
), hDlg
);
812 if (HIWORD(wParam
) == BN_CLICKED
&&
813 LOWORD(wParam
) == IDC_CHECK_SYSTEM_POS_WINDOW
)
815 if (IsDlgButtonChecked(hDlg
, IDC_CHECK_SYSTEM_POS_WINDOW
) == BST_CHECKED
)
817 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, FALSE
);
818 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, FALSE
);
819 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_LEFT
, FALSE
);
820 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_TOP
, FALSE
);
822 ConInfo
->AutoPosition
= TRUE
;
823 // Do not touch ConInfo->WindowPosition !!
825 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
826 PropSheet_Changed(GetParent(hDlg
), hDlg
);
832 left
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, NULL
, TRUE
);
833 top
= GetDlgItemInt(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, NULL
, TRUE
);
835 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_LEFT
, TRUE
);
836 EnableDlgItem(hDlg
, IDC_EDIT_WINDOW_POS_TOP
, TRUE
);
837 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_LEFT
, TRUE
);
838 EnableDlgItem(hDlg
, IDC_UPDOWN_WINDOW_POS_TOP
, TRUE
);
840 ConInfo
->AutoPosition
= FALSE
;
841 ConInfo
->WindowPosition
.x
= left
;
842 ConInfo
->WindowPosition
.y
= top
;
844 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_LAYOUT_WINDOW_PREVIEW
), NULL
, TRUE
);
845 PropSheet_Changed(GetParent(hDlg
), hDlg
);