winemac: Use unixlib interface for dragdrop.c calls.
[wine.git] / dlls / user32 / winpos.c
blobd38a3df18da33b50a53d98ed06b7300204c42556
1 /*
2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996, 1999 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <string.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "user_private.h"
26 #include "winerror.h"
27 #include "controls.h"
28 #include "win.h"
29 #include "wine/server.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(win);
34 #define HAS_THICKFRAME(style) \
35 (((style) & WS_THICKFRAME) && \
36 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
38 #define ON_LEFT_BORDER(hit) \
39 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
40 #define ON_RIGHT_BORDER(hit) \
41 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
42 #define ON_TOP_BORDER(hit) \
43 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
44 #define ON_BOTTOM_BORDER(hit) \
45 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
48 /***********************************************************************
49 * SwitchToThisWindow (USER32.@)
51 void WINAPI SwitchToThisWindow( HWND hwnd, BOOL alt_tab )
53 if (IsIconic( hwnd )) NtUserShowWindow( hwnd, SW_RESTORE );
54 else BringWindowToTop( hwnd );
58 /***********************************************************************
59 * GetWindowRect (USER32.@)
61 BOOL WINAPI GetWindowRect( HWND hwnd, LPRECT rect )
63 BOOL ret = NtUserGetWindowRect( hwnd, rect );
64 if (ret) TRACE( "hwnd %p %s\n", hwnd, wine_dbgstr_rect(rect) );
65 return ret;
69 /***********************************************************************
70 * GetWindowRgn (USER32.@)
72 int WINAPI GetWindowRgn( HWND hwnd, HRGN hrgn )
74 return NtUserGetWindowRgnEx( hwnd, hrgn, 0 );
77 /***********************************************************************
78 * GetWindowRgnBox (USER32.@)
80 int WINAPI GetWindowRgnBox( HWND hwnd, LPRECT prect )
82 int ret = ERROR;
83 HRGN hrgn;
85 if (!prect)
86 return ERROR;
88 if ((hrgn = CreateRectRgn(0, 0, 0, 0)))
90 if ((ret = GetWindowRgn( hwnd, hrgn )) != ERROR )
91 ret = GetRgnBox( hrgn, prect );
92 DeleteObject(hrgn);
95 return ret;
99 /***********************************************************************
100 * GetClientRect (USER32.@)
102 BOOL WINAPI GetClientRect( HWND hwnd, LPRECT rect )
104 return NtUserGetClientRect( hwnd, rect );
108 /*******************************************************************
109 * WindowFromPoint (USER32.@)
111 HWND WINAPI WindowFromPoint( POINT pt )
113 return NtUserWindowFromPoint( pt.x, pt.y );
117 /*******************************************************************
118 * ChildWindowFromPoint (USER32.@)
120 HWND WINAPI ChildWindowFromPoint( HWND parent, POINT pt )
122 return NtUserChildWindowFromPointEx( parent, pt.x, pt.y, CWP_ALL );
125 /*******************************************************************
126 * RealChildWindowFromPoint (USER32.@)
128 HWND WINAPI RealChildWindowFromPoint( HWND parent, POINT pt )
130 return NtUserChildWindowFromPointEx( parent, pt.x, pt.y,
131 CWP_SKIPTRANSPARENT | CWP_SKIPINVISIBLE );
134 /*******************************************************************
135 * ChildWindowFromPointEx (USER32.@)
137 HWND WINAPI ChildWindowFromPointEx( HWND parent, POINT pt, UINT flags )
139 return NtUserChildWindowFromPointEx( parent, pt.x, pt.y, flags );
143 /*******************************************************************
144 * MapWindowPoints (USER32.@)
146 INT WINAPI MapWindowPoints( HWND hwnd_from, HWND hwnd_to, POINT *points, UINT count )
148 return NtUserMapWindowPoints( hwnd_from, hwnd_to, points, count );
152 /*******************************************************************
153 * ClientToScreen (USER32.@)
155 BOOL WINAPI ClientToScreen( HWND hwnd, POINT *pt )
157 return NtUserClientToScreen( hwnd, pt );
161 /*******************************************************************
162 * ScreenToClient (USER32.@)
164 BOOL WINAPI ScreenToClient( HWND hwnd, POINT *pt )
166 return NtUserScreenToClient( hwnd, pt );
170 /***********************************************************************
171 * IsIconic (USER32.@)
173 BOOL WINAPI IsIconic(HWND hWnd)
175 return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MINIMIZE) != 0;
179 /***********************************************************************
180 * IsZoomed (USER32.@)
182 BOOL WINAPI IsZoomed(HWND hWnd)
184 return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MAXIMIZE) != 0;
188 /*******************************************************************
189 * AllowSetForegroundWindow (USER32.@)
191 BOOL WINAPI AllowSetForegroundWindow( DWORD procid )
193 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
194 * implemented, then fix this function. */
195 return TRUE;
199 /*******************************************************************
200 * LockSetForegroundWindow (USER32.@)
202 BOOL WINAPI LockSetForegroundWindow( UINT lockcode )
204 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
205 * implemented, then fix this function. */
206 return TRUE;
210 /***********************************************************************
211 * BringWindowToTop (USER32.@)
213 BOOL WINAPI BringWindowToTop( HWND hwnd )
215 return NtUserSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
219 /***********************************************************************
220 * GetInternalWindowPos (USER32.@)
222 UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd,
223 LPPOINT ptIcon )
225 WINDOWPLACEMENT wndpl;
227 wndpl.length = sizeof(wndpl);
228 if (NtUserGetWindowPlacement( hwnd, &wndpl ))
230 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
231 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
232 return wndpl.showCmd;
234 return 0;
238 /***********************************************************************
239 * AnimateWindow (USER32.@)
240 * Shows/Hides a window with an animation
241 * NO ANIMATION YET
243 BOOL WINAPI AnimateWindow(HWND hwnd, DWORD dwTime, DWORD dwFlags)
245 FIXME("partial stub\n");
247 /* If trying to show/hide and it's already *
248 * shown/hidden or invalid window, fail with *
249 * invalid parameter */
250 if(!IsWindow(hwnd) ||
251 (IsWindowVisible(hwnd) && !(dwFlags & AW_HIDE)) ||
252 (!IsWindowVisible(hwnd) && (dwFlags & AW_HIDE)))
254 SetLastError(ERROR_INVALID_PARAMETER);
255 return FALSE;
258 NtUserShowWindow( hwnd, (dwFlags & AW_HIDE) ? SW_HIDE : ((dwFlags & AW_ACTIVATE) ? SW_SHOW : SW_SHOWNA) );
260 return TRUE;
264 /*******************************************************************
265 * can_activate_window
267 * Check if we can activate the specified window.
269 static BOOL can_activate_window( HWND hwnd )
271 LONG style;
273 if (!hwnd) return FALSE;
274 style = GetWindowLongW( hwnd, GWL_STYLE );
275 if (!(style & WS_VISIBLE)) return FALSE;
276 if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
277 return !(style & WS_DISABLED);
281 /*******************************************************************
282 * WINPOS_ActivateOtherWindow
284 * Activates window other than pWnd.
286 void WINPOS_ActivateOtherWindow(HWND hwnd)
288 HWND hwndTo, fg;
290 if ((GetWindowLongW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER )))
292 hwndTo = NtUserGetAncestor( hwndTo, GA_ROOT );
293 if (can_activate_window( hwndTo )) goto done;
296 hwndTo = hwnd;
297 for (;;)
299 if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break;
300 if (can_activate_window( hwndTo )) goto done;
303 hwndTo = GetTopWindow( 0 );
304 for (;;)
306 if (hwndTo == hwnd)
308 hwndTo = 0;
309 break;
311 if (can_activate_window( hwndTo )) goto done;
312 if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break;
315 done:
316 fg = NtUserGetForegroundWindow();
317 TRACE("win = %p fg = %p\n", hwndTo, fg);
318 if (!fg || (hwnd == fg))
320 if (SetForegroundWindow( hwndTo )) return;
322 if (!NtUserSetActiveWindow( hwndTo )) NtUserSetActiveWindow( 0 );
326 /***********************************************************************
327 * BeginDeferWindowPos (USER32.@)
329 HDWP WINAPI BeginDeferWindowPos( INT count )
331 return NtUserBeginDeferWindowPos( count );
335 /***********************************************************************
336 * DeferWindowPos (USER32.@)
338 HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND after, INT x, INT y,
339 INT cx, INT cy, UINT flags )
341 return NtUserDeferWindowPosAndBand( hdwp, hwnd, after, x, y, cx, cy, flags, 0, 0 );
345 /***********************************************************************
346 * EndDeferWindowPos (USER32.@)
348 BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
350 return NtUserEndDeferWindowPosEx( hdwp, FALSE );
354 /***********************************************************************
355 * ArrangeIconicWindows (USER32.@)
357 UINT WINAPI ArrangeIconicWindows( HWND parent )
359 return NtUserArrangeIconicWindows( parent );
363 /***********************************************************************
364 * draw_moving_frame
366 * Draw the frame used when moving or resizing window.
368 static void draw_moving_frame( HWND parent, HDC hdc, RECT *screen_rect, BOOL thickframe )
370 RECT rect = *screen_rect;
372 if (parent) MapWindowPoints( 0, parent, (POINT *)&rect, 2 );
373 if (thickframe)
375 const int width = GetSystemMetrics(SM_CXFRAME);
376 const int height = GetSystemMetrics(SM_CYFRAME);
378 HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
379 PatBlt( hdc, rect.left, rect.top,
380 rect.right - rect.left - width, height, PATINVERT );
381 PatBlt( hdc, rect.left, rect.top + height, width,
382 rect.bottom - rect.top - height, PATINVERT );
383 PatBlt( hdc, rect.left + width, rect.bottom - 1,
384 rect.right - rect.left - width, -height, PATINVERT );
385 PatBlt( hdc, rect.right - 1, rect.top, -width,
386 rect.bottom - rect.top - height, PATINVERT );
387 SelectObject( hdc, hbrush );
389 else DrawFocusRect( hdc, &rect );
393 /***********************************************************************
394 * start_size_move
396 * Initialization of a move or resize, when initiated from a menu choice.
397 * Return hit test code for caption or sizing border.
399 static LONG start_size_move( HWND hwnd, WPARAM wParam, POINT *capturePoint, LONG style )
401 LONG hittest = 0;
402 POINT pt;
403 MSG msg;
404 RECT rectWindow;
406 GetWindowRect( hwnd, &rectWindow );
408 if ((wParam & 0xfff0) == SC_MOVE)
410 /* Move pointer at the center of the caption */
411 RECT rect = rectWindow;
412 /* Note: to be exactly centered we should take the different types
413 * of border into account, but it shouldn't make more than a few pixels
414 * of difference so let's not bother with that */
415 rect.top += GetSystemMetrics(SM_CYBORDER);
416 if (style & WS_SYSMENU)
417 rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
418 if (style & WS_MINIMIZEBOX)
419 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
420 if (style & WS_MAXIMIZEBOX)
421 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
422 pt.x = (rect.right + rect.left) / 2;
423 pt.y = rect.top + GetSystemMetrics(SM_CYSIZE)/2;
424 hittest = HTCAPTION;
425 *capturePoint = pt;
427 else /* SC_SIZE */
429 NtUserSetCursor( LoadCursorW( 0, (LPWSTR)IDC_SIZEALL ) );
430 pt.x = pt.y = 0;
431 while(!hittest)
433 if (!GetMessageW( &msg, 0, 0, 0 )) return 0;
434 if (NtUserCallMsgFilter( &msg, MSGF_SIZE )) continue;
436 switch(msg.message)
438 case WM_MOUSEMOVE:
439 pt.x = min( max( msg.pt.x, rectWindow.left ), rectWindow.right - 1 );
440 pt.y = min( max( msg.pt.y, rectWindow.top ), rectWindow.bottom - 1 );
441 hittest = SendMessageW( hwnd, WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) );
442 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) hittest = 0;
443 break;
445 case WM_LBUTTONUP:
446 return 0;
448 case WM_KEYDOWN:
449 switch(msg.wParam)
451 case VK_UP:
452 hittest = HTTOP;
453 pt.x =(rectWindow.left+rectWindow.right)/2;
454 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
455 break;
456 case VK_DOWN:
457 hittest = HTBOTTOM;
458 pt.x =(rectWindow.left+rectWindow.right)/2;
459 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
460 break;
461 case VK_LEFT:
462 hittest = HTLEFT;
463 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
464 pt.y =(rectWindow.top+rectWindow.bottom)/2;
465 break;
466 case VK_RIGHT:
467 hittest = HTRIGHT;
468 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
469 pt.y =(rectWindow.top+rectWindow.bottom)/2;
470 break;
471 case VK_RETURN:
472 case VK_ESCAPE:
473 return 0;
475 break;
476 default:
477 TranslateMessage( &msg );
478 DispatchMessageW( &msg );
479 break;
482 *capturePoint = pt;
484 NtUserSetCursorPos( pt.x, pt.y );
485 SendMessageW( hwnd, WM_SETCURSOR, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
486 return hittest;
490 /***********************************************************************
491 * WINPOS_SysCommandSizeMove
493 * Perform SC_MOVE and SC_SIZE commands.
495 void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
497 MSG msg;
498 RECT sizingRect, mouseRect, origRect;
499 HDC hdc;
500 HWND parent;
501 LONG hittest = (LONG)(wParam & 0x0f);
502 WPARAM syscommand = wParam & 0xfff0;
503 MINMAXINFO minmax;
504 POINT capturePoint, pt;
505 LONG style = GetWindowLongW( hwnd, GWL_STYLE );
506 BOOL thickframe = HAS_THICKFRAME( style );
507 BOOL moved = FALSE;
508 DWORD dwPoint = GetMessagePos ();
509 BOOL DragFullWindows = TRUE;
510 HMONITOR mon = 0;
512 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
514 pt.x = (short)LOWORD(dwPoint);
515 pt.y = (short)HIWORD(dwPoint);
516 capturePoint = pt;
517 NtUserClipCursor( NULL );
519 TRACE("hwnd %p command %04Ix, hittest %ld, pos %ld,%ld\n",
520 hwnd, syscommand, hittest, pt.x, pt.y);
522 if (syscommand == SC_MOVE)
524 if (!hittest) hittest = start_size_move( hwnd, wParam, &capturePoint, style );
525 if (!hittest) return;
527 else /* SC_SIZE */
529 if ( hittest && (syscommand != SC_MOUSEMENU) )
530 hittest += (HTLEFT - WMSZ_LEFT);
531 else
533 set_capture_window( hwnd, GUI_INMOVESIZE, NULL );
534 hittest = start_size_move( hwnd, wParam, &capturePoint, style );
535 if (!hittest)
537 set_capture_window( 0, GUI_INMOVESIZE, NULL );
538 return;
543 /* Get min/max info */
545 minmax = NtUserGetMinMaxInfo( hwnd );
546 WIN_GetRectangles( hwnd, COORDS_PARENT, &sizingRect, NULL );
547 origRect = sizingRect;
548 if (style & WS_CHILD)
550 parent = GetParent(hwnd);
551 GetClientRect( parent, &mouseRect );
552 MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
553 MapWindowPoints( parent, 0, (LPPOINT)&sizingRect, 2 );
555 else
557 parent = 0;
558 mouseRect = get_virtual_screen_rect();
559 mon = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST );
562 if (ON_LEFT_BORDER(hittest))
564 mouseRect.left = max( mouseRect.left, sizingRect.right-minmax.ptMaxTrackSize.x+capturePoint.x-sizingRect.left );
565 mouseRect.right = min( mouseRect.right, sizingRect.right-minmax.ptMinTrackSize.x+capturePoint.x-sizingRect.left );
567 else if (ON_RIGHT_BORDER(hittest))
569 mouseRect.left = max( mouseRect.left, sizingRect.left+minmax.ptMinTrackSize.x+capturePoint.x-sizingRect.right );
570 mouseRect.right = min( mouseRect.right, sizingRect.left+minmax.ptMaxTrackSize.x+capturePoint.x-sizingRect.right );
572 if (ON_TOP_BORDER(hittest))
574 mouseRect.top = max( mouseRect.top, sizingRect.bottom-minmax.ptMaxTrackSize.y+capturePoint.y-sizingRect.top );
575 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minmax.ptMinTrackSize.y+capturePoint.y-sizingRect.top);
577 else if (ON_BOTTOM_BORDER(hittest))
579 mouseRect.top = max( mouseRect.top, sizingRect.top+minmax.ptMinTrackSize.y+capturePoint.y-sizingRect.bottom );
580 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+minmax.ptMaxTrackSize.y+capturePoint.y-sizingRect.bottom );
583 /* Retrieve a default cache DC (without using the window style) */
584 hdc = NtUserGetDCEx( parent, 0, DCX_CACHE );
586 /* we only allow disabling the full window drag for child windows */
587 if (parent) SystemParametersInfoW( SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0 );
589 /* repaint the window before moving it around */
590 NtUserRedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
592 SendMessageW( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
593 set_capture_window( hwnd, GUI_INMOVESIZE, NULL );
595 while(1)
597 int dx = 0, dy = 0;
599 if (!GetMessageW( &msg, 0, 0, 0 )) break;
600 if (NtUserCallMsgFilter( &msg, MSGF_SIZE )) continue;
602 /* Exit on button-up, Return, or Esc */
603 if ((msg.message == WM_LBUTTONUP) ||
604 ((msg.message == WM_KEYDOWN) &&
605 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
607 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
609 TranslateMessage( &msg );
610 DispatchMessageW( &msg );
611 continue; /* We are not interested in other messages */
614 pt = msg.pt;
616 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
618 case VK_UP: pt.y -= 8; break;
619 case VK_DOWN: pt.y += 8; break;
620 case VK_LEFT: pt.x -= 8; break;
621 case VK_RIGHT: pt.x += 8; break;
624 pt.x = max( pt.x, mouseRect.left );
625 pt.x = min( pt.x, mouseRect.right - 1 );
626 pt.y = max( pt.y, mouseRect.top );
627 pt.y = min( pt.y, mouseRect.bottom - 1 );
629 if (!parent)
631 HMONITOR newmon;
632 MONITORINFO info;
634 if ((newmon = MonitorFromPoint( pt, MONITOR_DEFAULTTONULL )))
635 mon = newmon;
637 info.cbSize = sizeof(info);
638 if (mon && GetMonitorInfoW( mon, &info ))
640 pt.x = max( pt.x, info.rcWork.left );
641 pt.x = min( pt.x, info.rcWork.right - 1 );
642 pt.y = max( pt.y, info.rcWork.top );
643 pt.y = min( pt.y, info.rcWork.bottom - 1 );
647 dx = pt.x - capturePoint.x;
648 dy = pt.y - capturePoint.y;
650 if (dx || dy)
652 if( !moved )
654 moved = TRUE;
655 if (!DragFullWindows)
656 draw_moving_frame( parent, hdc, &sizingRect, thickframe );
659 if (msg.message == WM_KEYDOWN) NtUserSetCursorPos( pt.x, pt.y );
660 else
662 if (!DragFullWindows) draw_moving_frame( parent, hdc, &sizingRect, thickframe );
663 if (hittest == HTCAPTION || hittest == HTBORDER) OffsetRect( &sizingRect, dx, dy );
664 if (ON_LEFT_BORDER(hittest)) sizingRect.left += dx;
665 else if (ON_RIGHT_BORDER(hittest)) sizingRect.right += dx;
666 if (ON_TOP_BORDER(hittest)) sizingRect.top += dy;
667 else if (ON_BOTTOM_BORDER(hittest)) sizingRect.bottom += dy;
668 capturePoint = pt;
670 /* determine the hit location */
671 if (syscommand == SC_SIZE && hittest != HTBORDER)
673 WPARAM wpSizingHit = 0;
675 if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
676 wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
677 SendMessageW( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&sizingRect );
679 else
680 SendMessageW( hwnd, WM_MOVING, 0, (LPARAM)&sizingRect );
682 if (!DragFullWindows)
683 draw_moving_frame( parent, hdc, &sizingRect, thickframe );
684 else
686 RECT rect = sizingRect;
687 MapWindowPoints( 0, parent, (POINT *)&rect, 2 );
688 NtUserSetWindowPos( hwnd, 0, rect.left, rect.top,
689 rect.right - rect.left, rect.bottom - rect.top,
690 (hittest == HTCAPTION) ? SWP_NOSIZE : 0 );
696 if (moved && !DragFullWindows)
698 draw_moving_frame( parent, hdc, &sizingRect, thickframe );
701 set_capture_window( 0, GUI_INMOVESIZE, NULL );
702 NtUserReleaseDC( parent, hdc );
703 if (parent) MapWindowPoints( 0, parent, (POINT *)&sizingRect, 2 );
705 if (HOOK_CallHooks( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&sizingRect, TRUE ))
706 moved = FALSE;
708 SendMessageW( hwnd, WM_EXITSIZEMOVE, 0, 0 );
709 SendMessageW( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
711 /* window moved or resized */
712 if (moved)
714 /* if the moving/resizing isn't canceled call SetWindowPos
715 * with the new position or the new size of the window
717 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
719 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
720 if (!DragFullWindows)
721 NtUserSetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
722 sizingRect.right - sizingRect.left,
723 sizingRect.bottom - sizingRect.top,
724 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
726 else
727 { /* restore previous size/position */
728 if(DragFullWindows)
729 NtUserSetWindowPos( hwnd, 0, origRect.left, origRect.top,
730 origRect.right - origRect.left,
731 origRect.bottom - origRect.top,
732 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
736 if (IsIconic(hwnd))
738 /* Single click brings up the system menu when iconized */
740 if( !moved )
742 if(style & WS_SYSMENU )
743 SendMessageW( hwnd, WM_SYSCOMMAND,
744 SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));