source: trunk/src/user32/wintrack.cpp

Last change on this file was 10511, checked in by sandervl, 21 years ago

WM_EXITSIZEMOVE should be sent after the window position and/or size has been changed.

File size: 27.6 KB
Line 
1/*
2 * Window tracking related functions.
3 *
4 * Copyright 2001 Sander van Leeuwen
5 *
6 * Changes from Wine code: (20011004)
7 * - Only draw changed track frame instead of clearing the old one and
8 * drawing the new one (less flickering)
9 * - Send WM_MOVING when moving a window (not done in Wine)
10 * - Send WM_SIZING only when sizing a window
11 * - Fixed handling of rectangles changed by WM_SIZING/MOVING
12 *
13 * Based on Wine code: (dlls\x11drv\winpos.c)
14 *
15 * Copyright 1993, 1994, 1995, 2001 Alexandre Julliard
16 * Copyright 1995, 1996, 1999 Alex Korobka
17 *
18 */
19#include <os2win.h>
20#include <string.h>
21
22#include "win32wbase.h"
23#include "hook.h"
24#include "pmwindow.h"
25
26#define ON_LEFT_BORDER(hit) \
27 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
28#define ON_RIGHT_BORDER(hit) \
29 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
30#define ON_TOP_BORDER(hit) \
31 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
32#define ON_BOTTOM_BORDER(hit) \
33 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
34
35#define RECT_WIDTH(a) ((a)->right - (a)->left)
36#define RECT_HEIGHT(a) ((a)->bottom - (a)->top)
37#define RECT_EQUAL(a,b) (memcmp(a, b, sizeof(RECT)) == 0)
38
39
40/***********************************************************************
41 * draw_moving_frame
42 *
43 * Draw the frame used when moving or resizing window.
44 *
45 * FIXME: This causes problems in Win95 mode. (why?)
46 */
47static void draw_moving_frame( HDC hdc, RECT *rect, BOOL thickframe, DWORD hittest, BOOL fRedraw)
48{
49 if(hdc == 0) {
50 DebugInt3();
51 return;
52 }
53 if (thickframe)
54 {
55 const int width = GetSystemMetrics(SM_CXFRAME);
56 const int height = GetSystemMetrics(SM_CYFRAME);
57
58 static RECT oldRect = {0};
59
60 if(fRedraw && EqualRect(&oldRect, rect)) {
61 return;
62 }
63
64 HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
65 if(fRedraw && hittest != HTCAPTION)
66 {
67 int x, y, linewidth, lineheight;
68
69 //This should be done in a better way (less code), but at least
70 //it works.
71 switch(hittest) {
72 case HTLEFT:
73 //clear old edge
74 PatBlt( hdc, oldRect.left, oldRect.top + height,
75 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
76 //and draw new one
77 PatBlt( hdc, rect->left, rect->top + height,
78 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
79
80 if(oldRect.left > rect->left) {
81 x = rect->left;
82 linewidth = oldRect.left - rect->left;
83 }
84 else {
85 x = oldRect.left;
86 linewidth = rect->left - oldRect.left;
87 }
88 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
89 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
90 break;
91 case HTRIGHT:
92 //clear old edge
93 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
94 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
95 //and draw new one
96 PatBlt( hdc, rect->right-1, rect->top + height,
97 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
98
99 if(oldRect.right > rect->right) {
100 x = rect->right;
101 linewidth = oldRect.right - rect->right;
102 }
103 else {
104 x = oldRect.right;
105 linewidth = rect->right - oldRect.right;
106 }
107 PatBlt( hdc, x, oldRect.top, linewidth, height, PATINVERT );
108 PatBlt( hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT );
109 break;
110
111 case HTTOP:
112 //clear old edge
113 PatBlt( hdc, oldRect.left + width, oldRect.top,
114 RECT_WIDTH(&oldRect) - 2*width, height, PATINVERT );
115 //and draw new one
116 PatBlt( hdc, rect->left + width, rect->top,
117 RECT_WIDTH(rect) - 2*width, height, PATINVERT );
118
119 if(oldRect.top > rect->top) {
120 y = rect->top;
121 lineheight = oldRect.top - rect->top;
122 }
123 else {
124 y = oldRect.top;
125 lineheight = rect->top - oldRect.top;
126 }
127
128 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
129 PatBlt( hdc, oldRect.right - 1, y, -width, lineheight, PATINVERT );
130 break;
131
132 case HTBOTTOM:
133 //clear old edge
134 PatBlt( hdc, oldRect.left + width, oldRect.bottom-1,
135 RECT_WIDTH(&oldRect) - 2*width, -height, PATINVERT );
136 //and draw new one
137 PatBlt( hdc, rect->left + width, rect->bottom-1,
138 RECT_WIDTH(rect) - 2*width, -height, PATINVERT );
139
140 if(oldRect.bottom > rect->bottom) {
141 y = rect->bottom;
142 lineheight = oldRect.bottom - rect->bottom;
143 }
144 else {
145 y = oldRect.bottom;
146 lineheight = rect->bottom - oldRect.bottom;
147 }
148
149 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
150 PatBlt( hdc, oldRect.right - 1, y, -width, lineheight, PATINVERT );
151 break;
152
153 case HTBOTTOMLEFT:
154 //clear old edge (bottom)
155 PatBlt( hdc, oldRect.left, oldRect.bottom-1,
156 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
157 //and draw new one
158 PatBlt( hdc, rect->left, rect->bottom-1,
159 RECT_WIDTH(rect) - width, -height, PATINVERT );
160
161 //clear old edge (left)
162 PatBlt( hdc, oldRect.left, oldRect.top + height,
163 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
164 //and draw new one
165 PatBlt( hdc, rect->left, rect->top + height,
166 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
167
168 //right
169 if(oldRect.bottom > rect->bottom) {
170 y = rect->bottom;
171 lineheight = oldRect.bottom - rect->bottom;
172 }
173 else {
174 y = oldRect.bottom;
175 lineheight = rect->bottom - oldRect.bottom;
176 }
177 PatBlt( hdc, oldRect.right-1, y, -width, lineheight, PATINVERT );
178
179 //top
180 if(oldRect.left > rect->left) {
181 x = rect->left;
182 linewidth = oldRect.left - rect->left;
183 }
184 else {
185 x = oldRect.left;
186 linewidth = rect->left - oldRect.left;
187 }
188 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
189 break;
190
191 case HTBOTTOMRIGHT:
192 //clear old edge (bottom)
193 PatBlt( hdc, oldRect.left + width, oldRect.bottom-1,
194 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
195 //and draw new one
196 PatBlt( hdc, rect->left + width, rect->bottom-1,
197 RECT_WIDTH(rect) - width, -height, PATINVERT );
198
199 //clear old edge (right)
200 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
201 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
202 //and draw new one
203 PatBlt( hdc, rect->right-1, rect->top + height,
204 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
205
206 //left
207 if(oldRect.bottom > rect->bottom) {
208 y = rect->bottom;
209 lineheight = oldRect.bottom - rect->bottom;
210 }
211 else {
212 y = oldRect.bottom;
213 lineheight = rect->bottom - oldRect.bottom;
214 }
215 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
216
217 //top
218 if(oldRect.right > rect->right) {
219 x = rect->right;
220 linewidth = oldRect.right - rect->right;
221 }
222 else {
223 x = oldRect.right;
224 linewidth = rect->right - oldRect.right;
225 }
226 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
227 break;
228
229 case HTTOPLEFT:
230 //clear old edge (top)
231 PatBlt( hdc, oldRect.left, oldRect.top,
232 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
233 //and draw new one
234 PatBlt( hdc, rect->left, rect->top,
235 RECT_WIDTH(rect) - width, height, PATINVERT );
236
237 //clear old edge (left)
238 PatBlt( hdc, oldRect.left, oldRect.top + height,
239 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
240 //and draw new one
241 PatBlt( hdc, rect->left, rect->top + height,
242 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
243
244 //right
245 if(oldRect.top > rect->top) {
246 y = rect->top;
247 lineheight = oldRect.top - rect->top;
248 }
249 else {
250 y = oldRect.top;
251 lineheight = rect->top - oldRect.top;
252 }
253 PatBlt( hdc, oldRect.right-1, y, -width, lineheight, PATINVERT );
254
255 //bottom
256 if(oldRect.left > rect->left) {
257 x = rect->left;
258 linewidth = oldRect.left - rect->left;
259 }
260 else {
261 x = oldRect.left;
262 linewidth = rect->left - oldRect.left;
263 }
264 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
265 break;
266
267 case HTTOPRIGHT:
268 //clear old edge (top)
269 PatBlt( hdc, oldRect.left+width, oldRect.top,
270 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
271 //and draw new one
272 PatBlt( hdc, rect->left+width, rect->top,
273 RECT_WIDTH(rect) - width, height, PATINVERT );
274
275 //clear old edge (right)
276 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
277 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
278 //and draw new one
279 PatBlt( hdc, rect->right-1, rect->top + height,
280 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
281
282 //left
283 if(oldRect.top > rect->top) {
284 y = rect->top;
285 lineheight = oldRect.top - rect->top;
286 }
287 else {
288 y = oldRect.top;
289 lineheight = rect->top - oldRect.top;
290 }
291 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT);
292
293 //bottom
294 if(oldRect.right > rect->right) {
295 x = rect->right;
296 linewidth = oldRect.right - rect->right;
297 }
298 else {
299 x = oldRect.right;
300 linewidth = rect->right - oldRect.right;
301 }
302 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
303 break;
304 }
305 oldRect = *rect;
306 }
307 else {
308 if(fRedraw) {
309 PatBlt( hdc, oldRect.left, oldRect.top,
310 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
311 PatBlt( hdc, oldRect.left, oldRect.top + height, width,
312 RECT_HEIGHT(&oldRect) - height, PATINVERT );
313 PatBlt( hdc, oldRect.left + width, oldRect.bottom - 1,
314 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
315 PatBlt( hdc, oldRect.right - 1, oldRect.top, -width,
316 RECT_HEIGHT(&oldRect) - height, PATINVERT );
317 }
318 oldRect = *rect;
319 PatBlt( hdc, rect->left, rect->top,
320 rect->right - rect->left - width, height, PATINVERT );
321 PatBlt( hdc, rect->left, rect->top + height, width,
322 rect->bottom - rect->top - height, PATINVERT );
323 PatBlt( hdc, rect->left + width, rect->bottom - 1,
324 rect->right - rect->left - width, -height, PATINVERT );
325 PatBlt( hdc, rect->right - 1, rect->top, -width,
326 rect->bottom - rect->top - height, PATINVERT );
327 }
328 SelectObject( hdc, hbrush );
329 }
330 else {
331 static RECT oldRect = {0};
332
333 if(fRedraw && EqualRect(&oldRect, rect)) {
334 return;
335 }
336
337 if(fRedraw) {
338 DrawFocusRect( hdc, &oldRect );
339 }
340 DrawFocusRect( hdc, rect );
341 oldRect = *rect;
342 }
343}
344
345
346/***********************************************************************
347 * start_size_move
348 *
349 * Initialisation of a move or resize, when initiatied from a menu choice.
350 * Return hit test code for caption or sizing border.
351 */
352static LONG start_size_move( Win32BaseWindow *win32wnd, WPARAM wParam, POINT *capturePoint, LONG style )
353{
354 HWND hwnd = win32wnd->getWindowHandle();
355 LONG hittest = 0;
356 POINT pt;
357 MSG msg;
358 RECT rectWindow;
359
360 GetWindowRect( hwnd, &rectWindow );
361
362 if ((wParam & 0xfff0) == SC_MOVE)
363 {
364 /* Move pointer at the center of the caption */
365 RECT rect;
366 win32wnd->GetInsideRect( &rect );
367 if (style & WS_SYSMENU)
368 rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
369 if (style & WS_MINIMIZEBOX)
370 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
371 if (style & WS_MAXIMIZEBOX)
372 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
373 pt.x = rectWindow.left + (rect.right - rect.left) / 2;
374 pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
375 hittest = HTCAPTION;
376 *capturePoint = pt;
377 }
378 else /* SC_SIZE */
379 {
380 while(!hittest)
381 {
382// GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST );
383 GetMessageW( &msg, 0, 0, 0 );
384 if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
385
386 switch(msg.message)
387 {
388 case WM_MOUSEMOVE:
389 hittest = win32wnd->HandleNCHitTest( msg.pt );
390// hittest = NC_HandleNCHitTest( hwnd, msg.pt );
391 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
392 hittest = 0;
393 break;
394
395 case WM_LBUTTONUP:
396 return 0;
397
398 case WM_KEYDOWN:
399 switch(msg.wParam)
400 {
401 case VK_UP:
402 hittest = HTTOP;
403 pt.x =(rectWindow.left+rectWindow.right)/2;
404 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
405 break;
406 case VK_DOWN:
407 hittest = HTBOTTOM;
408 pt.x =(rectWindow.left+rectWindow.right)/2;
409 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
410 break;
411 case VK_LEFT:
412 hittest = HTLEFT;
413 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
414 pt.y =(rectWindow.top+rectWindow.bottom)/2;
415 break;
416 case VK_RIGHT:
417 hittest = HTRIGHT;
418 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
419 pt.y =(rectWindow.top+rectWindow.bottom)/2;
420 break;
421 case VK_RETURN:
422 case VK_ESCAPE: return 0;
423 }
424 }
425 }
426 *capturePoint = pt;
427 }
428 SetCursorPos( pt.x, pt.y );
429 win32wnd->DefWindowProcA(WM_SETCURSOR, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
430// NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
431 dprintf(("start_size_move: hittest %d", hittest));
432 return hittest;
433}
434
435
436/***********************************************************************
437 * SysCommandSizeMove (X11DRV.@)
438 *
439 * Perform SC_MOVE and SC_SIZE commands.
440 */
441void Frame_SysCommandSizeMove(Win32BaseWindow *win32wnd, WPARAM wParam )
442{
443 HWND hwnd = win32wnd->getWindowHandle();
444 MSG msg;
445 RECT sizingRect, mouseRect, origRect, lastsizingRect;
446 HDC hdc;
447 HWND parent;
448 LONG hittest = (LONG)(wParam & 0x0f);
449 HCURSOR hDragCursor = 0, hOldCursor = 0;
450 POINT minTrack, maxTrack;
451 POINT capturePoint, pt;
452 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
453 LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
454 BOOL thickframe = HAS_THICKFRAME( style, exstyle );
455 BOOL iconic = style & WS_MINIMIZE;
456 BOOL moved = FALSE;
457 DWORD dwPoint = GetMessagePos ();
458 BOOL DragFullWindows = FALSE;
459 BOOL fControl = FALSE;
460 BOOL grab;
461 int iWndsLocks;
462
463 dprintf(("FrameTrackFrame %x", wParam));
464
465 SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
466
467 pt.x = SLOWORD(dwPoint);
468 pt.y = SHIWORD(dwPoint);
469 capturePoint = pt;
470
471 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
472
473 if(fOS2Look) {
474 fControl = GetAsyncKeyState(VK_CONTROL);
475 if(DragFullWindows && !fControl) {
476 //Bring window to top and activate it
477 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
478 }
479 }
480
481 if ((wParam & 0xfff0) == SC_MOVE)
482 {
483 if (!hittest) hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
484 if (!hittest) return;
485 }
486 else /* SC_SIZE */
487 {
488 if (!thickframe) return;
489 if ( hittest && hittest != HTSYSMENU ) hittest += 2;
490 else
491 {
492 SetCapture(hwnd);
493 hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
494 if (!hittest)
495 {
496 ReleaseCapture();
497 return;
498 }
499 }
500 }
501
502 /* Get min/max info */
503 win32wnd->AdjustTrackInfo(&minTrack, &maxTrack);
504 GetWindowRect( hwnd, &sizingRect );
505 if (style & WS_CHILD)
506 {
507 parent = GetParent(hwnd);
508 /* make sizing rect relative to parent */
509 MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
510 GetClientRect( parent, &mouseRect );
511 }
512 else
513 {
514 parent = GetDesktopWindow();
515 SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
516 }
517 origRect = sizingRect;
518
519 if (ON_LEFT_BORDER(hittest))
520 {
521 mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
522 mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
523 }
524 else if (ON_RIGHT_BORDER(hittest))
525 {
526 mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
527 mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
528 }
529 if (ON_TOP_BORDER(hittest))
530 {
531 mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
532 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
533 }
534 else if (ON_BOTTOM_BORDER(hittest))
535 {
536 mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
537 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
538 }
539 if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
540
541 /* Retrieve a default cache DC (without using the window style) */
542 hdc = 0;
543 if(!DragFullWindows)
544 hdc = GetDCEx( parent, 0, DCX_CACHE);
545
546 if( iconic ) /* create a cursor for dragging */
547 {
548 HICON hIcon = GetClassLongA( hwnd, GCL_HICON);
549 if(!hIcon) hIcon = (HICON)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L);
550 if( hIcon ) hDragCursor = hIcon;
551 if( !hDragCursor ) iconic = FALSE;
552 }
553
554 /* repaint the window before moving it around */
555 RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
556
557 SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
558 SetCapture( hwnd );
559
560 //prevent the app from drawing to this window (or its children)
561 if(!DragFullWindows)
562 LockWindowUpdate(hwnd);
563
564 while(1)
565 {
566 int dx = 0, dy = 0;
567
568// if (!GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST )) break;
569 if (!GetMessageW( &msg, 0, 0, 0 )) break;
570 if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
571
572 /* Exit on button-up, Return, or Esc */
573 if ((msg.message == WM_LBUTTONUP) || (msg.message == WM_RBUTTONUP) ||
574 ((msg.message == WM_KEYDOWN) &&
575 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
576
577 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) {
578 DispatchMessageA(&msg);
579 continue; /* We are not interested in other messages */
580 }
581
582 pt = msg.pt;
583
584 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
585 {
586 case VK_UP: pt.y -= 8; break;
587 case VK_DOWN: pt.y += 8; break;
588 case VK_LEFT: pt.x -= 8; break;
589 case VK_RIGHT: pt.x += 8; break;
590 }
591
592 pt.x = max( pt.x, mouseRect.left );
593 pt.x = min( pt.x, mouseRect.right );
594 pt.y = max( pt.y, mouseRect.top );
595 pt.y = min( pt.y, mouseRect.bottom );
596
597 dprintf(("mouseRect (%d,%d)(%d,%d)", mouseRect.left, mouseRect.top, mouseRect.right, mouseRect.bottom));
598 dprintf(("capturePoint (%d,%d)", capturePoint.x, capturePoint.y));
599 dx = pt.x - capturePoint.x;
600 dy = pt.y - capturePoint.y;
601
602 if (dx || dy)
603 {
604 if( !moved )
605 {
606 moved = TRUE;
607
608 if( iconic ) /* ok, no system popup tracking */
609 {
610 hOldCursor = SetCursor(hDragCursor);
611 ShowCursor( TRUE );
612// WINPOS_ShowIconTitle( hwnd, FALSE );
613 }
614 else if(!DragFullWindows)
615 draw_moving_frame( hdc, &sizingRect, thickframe, hittest, FALSE );
616 }
617
618 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
619 else
620 {
621 RECT newRect = sizingRect, tempRect;
622 WPARAM wpSizingHit = 0;
623
624 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
625
626 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
627 else
628 if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
629
630 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
631 else
632 if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
633
634 /* determine the hit location */
635 if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
636 wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
637
638 tempRect = newRect;
639
640 dprintf(("WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
641
642 //Although the docs say the app should return TRUE when processing
643 //this message, experiments show that NT checks the rectangle
644 //regardless of the return value
645 if ((wParam & 0xfff0) == SC_MOVE) {
646 SendMessageA( hwnd, WM_MOVING, wpSizingHit, (LPARAM)&newRect );
647 }
648 else SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
649
650 dprintf(("WM_MOVING/WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
651
652 dprintf(("update capture point dx %d dy %d", dx, dy));
653 capturePoint = pt;
654 sizingRect = tempRect;
655 lastsizingRect = newRect;
656
657 if (!iconic)
658 {
659 BOOL fMove = (wParam & 0xfff0) == SC_MOVE;
660
661 if(!DragFullWindows)
662 draw_moving_frame( hdc, &newRect, thickframe, hittest, TRUE );
663 else {
664 SetWindowPos( hwnd, 0, newRect.left, newRect.top,
665 newRect.right - newRect.left,
666 newRect.bottom - newRect.top,
667 ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
668 ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
669 }
670 }
671 }
672 }
673 }
674
675 //Enable window update
676 if(!DragFullWindows)
677 LockWindowUpdate(NULL);
678
679 ReleaseCapture();
680 if( iconic )
681 {
682 if( moved ) /* restore cursors, show icon title later on */
683 {
684 ShowCursor( FALSE );
685 SetCursor( hOldCursor );
686 }
687 DestroyCursor( hDragCursor );
688 }
689 else if (moved && !DragFullWindows)
690 draw_moving_frame( hdc, &lastsizingRect, thickframe, hittest, FALSE);
691
692 if(hdc) ReleaseDC( parent, hdc );
693
694 if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&lastsizingRect )) moved = FALSE;
695
696 /* window moved or resized */
697 if (moved)
698 {
699 /* if the moving/resizing isn't canceled call SetWindowPos
700 * with the new position or the new size of the window
701 */
702 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
703 {
704 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
705 if( (!DragFullWindows) || iconic)
706 SetWindowPos( hwnd, 0, lastsizingRect.left, lastsizingRect.top,
707 lastsizingRect.right - lastsizingRect.left,
708 lastsizingRect.bottom - lastsizingRect.top,
709 ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
710 ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
711 }
712 else
713 { /* restore previous size/position */
714 //SvL: TODO: should really restore z-order & activation here
715 if(DragFullWindows)
716 SetWindowPos( hwnd, 0, origRect.left, origRect.top,
717 origRect.right - origRect.left,
718 origRect.bottom - origRect.top,
719 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
720 }
721 }
722 else
723 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) {
724 //if action wasn't cancelled, ctrl wasn't pressed and we didn't
725 //activate the window before (!DragFullWindows), then activate
726 //and bring it to the top now
727 if(!fControl && !DragFullWindows) {
728 //Bring window to top and activate it
729 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
730 }
731 }
732
733 // Needs to be sent *after* changing the window position/size
734 SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
735 SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
736
737 if (IsIconic(hwnd))
738 {
739 /* Single click brings up the system menu when iconized */
740
741 if( !moved && !fOS2Look)
742 {
743 if(style & WS_SYSMENU )
744 SendMessageA( hwnd, WM_SYSCOMMAND,
745 SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
746 }
747// else WINPOS_ShowIconTitle( hwnd, TRUE );
748 }
749}
750
Note: See TracBrowser for help on using the repository browser.