00045 {
00046
SHORT DeltaX,DeltaY;
00047
SHORT PixelDeltaX,PixelDeltaY;
00048
DWORD Flags=0;
00049 COORD FontSize;
00050
00051
#ifdef THERESES_DEBUG
00052
DbgPrint(
"WM_WINDOWPOSCHANGING message ");
00053
DbgPrint(
" WindowSize is %d %d\n",
CONSOLE_WINDOW_SIZE_X(ScreenInfo),
CONSOLE_WINDOW_SIZE_Y(ScreenInfo));
00054
DbgPrint(
" WindowRect is %d %d %d %d\n",Console->WindowRect.left,
00055 Console->WindowRect.top,
00056 Console->WindowRect.right,
00057 Console->WindowRect.bottom);
00058
DbgPrint(
" window pos is %d %d %d %d\n",WindowPos->x,
00059 WindowPos->y,
00060 WindowPos->cx,
00061 WindowPos->cy);
00062
#endif
00063
00064
00065
00066
00067
00068
if (WindowPos->flags & SWP_NOSIZE) {
00069
return;
00070 }
00071
00072
if (ScreenInfo->Flags &
CONSOLE_TEXTMODE_BUFFER) {
00073 FontSize =
SCR_FONTSIZE(ScreenInfo);
00074 }
else {
00075 FontSize.X = 1;
00076 FontSize.Y = 1;
00077 }
00078
00079
00080
00081
00082
00083
if (WindowPos->flags & SWP_FRAMECHANGED) {
00084
00085
InitializeSystemMetrics();
00086
if (Console->VerticalClientToWindow !=
VerticalClientToWindow ||
00087 Console->HorizontalClientToWindow !=
HorizontalClientToWindow) {
00088
00089 Console->VerticalClientToWindow =
VerticalClientToWindow;
00090 Console->HorizontalClientToWindow =
HorizontalClientToWindow;
00091 Console->WindowRect.left = WindowPos->x;
00092 Console->WindowRect.top = WindowPos->y;
00093 Console->WindowRect.right = WindowPos->x + WindowPos->cx;
00094 Console->WindowRect.bottom = WindowPos->y + WindowPos->cy;
00095
return;
00096 }
00097 }
00098
00099 PixelDeltaX = (
SHORT)(WindowPos->cx - (Console->WindowRect.right - Console->WindowRect.left));
00100 PixelDeltaY = (
SHORT)(WindowPos->cy - (Console->WindowRect.bottom - Console->WindowRect.top));
00101
00102
if (WindowPos->cx >= (ScreenInfo->ScreenBufferSize.X * FontSize.X +
VerticalClientToWindow) &&
00103 WindowPos->cy >= (ScreenInfo->ScreenBufferSize.Y * FontSize.Y +
HorizontalClientToWindow)) {
00104
00105
00106
00107
00108
00109 ScreenInfo->WindowMaximizedX =
TRUE;
00110 ScreenInfo->WindowMaximizedY =
TRUE;
00111 DeltaX = (
SHORT)(ScreenInfo->ScreenBufferSize.X -
CONSOLE_WINDOW_SIZE_X(ScreenInfo));
00112 DeltaY = (
SHORT)(ScreenInfo->ScreenBufferSize.Y -
CONSOLE_WINDOW_SIZE_Y(ScreenInfo));
00113 }
else {
00114
00115 DeltaX = PixelDeltaX / FontSize.X;
00116 DeltaY = PixelDeltaY / FontSize.Y;
00117
00118
00119
00120
00121
00122
00123
00124
00125
CalculateNewSize(&ScreenInfo->WindowMaximizedX,
00126 &ScreenInfo->WindowMaximizedY,
00127 &DeltaX,
00128 &DeltaY,
00129 (SHORT)(
CONSOLE_WINDOW_SIZE_X(ScreenInfo)),
00130 (SHORT)(
CONSOLE_WINDOW_SIZE_Y(ScreenInfo)),
00131 ScreenInfo->ScreenBufferSize,
00132 FontSize
00133 );
00134
#ifdef THERESES_DEBUG
00135
DbgPrint(
"Delta X Y is now %d %d\n",DeltaX,DeltaY);
00136
DbgPrint(
"Maximized X Y is now %d %d\n",ScreenInfo->WindowMaximizedX,ScreenInfo->WindowMaximizedY);
00137
#endif
00138
}
00139
00140
00141
00142
00143
00144
if (!DeltaX && !DeltaY && (PixelDeltaX || PixelDeltaY)) {
00145 COORD OriginDifference;
00146
00147
00148
00149
00150
00151
00152
00153 OriginDifference.X = (
SHORT)(WindowPos->x - Console->WindowRect.left);
00154 OriginDifference.Y = (
SHORT)(WindowPos->y - Console->WindowRect.top);
00155
if (OriginDifference.X < FontSize.X && OriginDifference.X > -FontSize.X &&
00156 OriginDifference.Y < FontSize.Y && OriginDifference.Y > -FontSize.Y) {
00157 WindowPos->x = Console->WindowRect.left;
00158 WindowPos->y = Console->WindowRect.top;
00159 WindowPos->cx = Console->WindowRect.right - Console->WindowRect.left;
00160 WindowPos->cy = Console->WindowRect.bottom - Console->WindowRect.top;
00161
return;
00162 }
00163 }
00164
00165 Flags |=
RESIZE_SCROLL_BARS;
00166 WindowPos->cx = (DeltaX +
CONSOLE_WINDOW_SIZE_X(ScreenInfo)) * FontSize.X + (!ScreenInfo->WindowMaximizedY *
VerticalScrollSize) +
VerticalClientToWindow;
00167 WindowPos->cy = (DeltaY +
CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) * FontSize.Y + (!ScreenInfo->WindowMaximizedX *
HorizontalScrollSize) +
HorizontalClientToWindow;
00168
00169
00170
00171
00172
00173
00174 {
00175
SHORT ScrollRange,ScrollPos;
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 ScrollRange = (
SHORT)(ScreenInfo->ScreenBufferSize.X -
CONSOLE_WINDOW_SIZE_X(ScreenInfo));
00199 ScrollPos = ScreenInfo->Window.Left;
00200
00201
if (WindowPos->x != Console->WindowRect.left) {
00202
SHORT NumLinesFromRight;
00203
if (ScrollRange) {
00204 NumLinesFromRight = DeltaX * (ScrollRange - ScrollPos) / ScrollRange;
00205 }
else {
00206 NumLinesFromRight = DeltaX;
00207 }
00208 ScreenInfo->Window.Left -= DeltaX - NumLinesFromRight;
00209 ScreenInfo->Window.Right += NumLinesFromRight;
00210 }
else {
00211
SHORT NumLinesFromLeft;
00212
if (ScrollRange) {
00213 NumLinesFromLeft = DeltaX * ScrollPos / ScrollRange;
00214 }
else {
00215 NumLinesFromLeft = 0;
00216 }
00217 ScreenInfo->Window.Left -= NumLinesFromLeft;
00218 ScreenInfo->Window.Right += DeltaX - NumLinesFromLeft;
00219 }
00220
00221 ScrollRange = (
SHORT)(ScreenInfo->ScreenBufferSize.Y -
CONSOLE_WINDOW_SIZE_Y(ScreenInfo));
00222 ScrollPos = ScreenInfo->Window.Top;
00223
if (WindowPos->y != Console->WindowRect.top) {
00224
SHORT NumLinesFromBottom;
00225
if (ScrollRange) {
00226 NumLinesFromBottom = DeltaY * (ScrollRange - ScrollPos) / ScrollRange;
00227 }
else {
00228 NumLinesFromBottom = DeltaY;
00229 }
00230 ScreenInfo->Window.Top -= DeltaY - NumLinesFromBottom;
00231 ScreenInfo->Window.Bottom += NumLinesFromBottom;
00232 }
else {
00233
SHORT NumLinesFromTop;
00234
if (ScrollRange) {
00235 NumLinesFromTop = DeltaY * ScrollPos / ScrollRange;
00236 }
else {
00237 NumLinesFromTop = 0;
00238 }
00239 ScreenInfo->Window.Top -= NumLinesFromTop;
00240 ScreenInfo->Window.Bottom += DeltaY - NumLinesFromTop;
00241 }
00242 }
00243
00244
if (ScreenInfo->WindowMaximizedX)
00245
ASSERT (
CONSOLE_WINDOW_SIZE_X(ScreenInfo) == ScreenInfo->ScreenBufferSize.X);
00246
if (ScreenInfo->WindowMaximizedY)
00247
ASSERT (
CONSOLE_WINDOW_SIZE_Y(ScreenInfo) == ScreenInfo->ScreenBufferSize.Y);
00248
#ifdef THERESES_DEBUG
00249
DbgPrint(
" WindowSize is now %d %d\n",
CONSOLE_WINDOW_SIZE_X(ScreenInfo),
CONSOLE_WINDOW_SIZE_Y(ScreenInfo));
00250
DbgPrint(
" window pos is now %d %d %d %d\n",WindowPos->x,
00251 WindowPos->y,
00252 WindowPos->cx,
00253 WindowPos->cy);
00254
#endif
00255
Console->ResizeFlags = Flags | (Console->ResizeFlags &
SCREEN_BUFFER_CHANGE);
00256 }