/* INCLUDES ******************************************************************/
-#include "user32.h"
-#include <windowsx.h>
-#include <window.h>
-#include <user32/wininternal.h>
-#include <string.h>
-#include <cursor.h>
-#include <menu.h>
-#include <scroll.h>
-#include <winpos.h>
-
+#include <user32.h>
#define NDEBUG
#include <debug.h>
{
return SysColors[nIndex];
}
-
+
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
ChangeSysColors.Elements = (INT*)lpaElements;
ChangeSysColors.Colors = (COLORREF*)lpaRgbValues;
-
+
if(cElements > 0)
{
Ret = NtUserSetSysColors(&ChangeSysColors, cElements);
SetLastError(ERROR_INVALID_PARAMETER);
Ret = FALSE;
}
-
+
return Ret;
}
return((LRESULT)SetCursor(LoadCursorW(0, IDC_ARROW)));
}
-static LONG
+static LONG
DefWndStartSizeMove(HWND hWnd, WPARAM wParam, POINT *capturePoint)
{
LONG hittest = 0;
POINT pt;
MSG msg;
RECT rectWindow;
- ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
-
+ ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
+
GetWindowRect(hWnd, &rectWindow);
if ((wParam & 0xfff0) == SC_MOVE)
}
else /* SC_SIZE */
{
+ pt.x = pt.y = 0;
while(!hittest)
{
if (GetMessageW(&msg, NULL, 0, 0) <= 0)
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
hittest = 0;
break;
-
+
case WM_LBUTTONUP:
return 0;
-
+
case WM_KEYDOWN:
switch(msg.wParam)
{
#define ON_BOTTOM_BORDER(hit) \
(((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
-VOID STATIC
+VOID STATIC
UserDrawWindowFrame(HDC hdc, const RECT *rect,
ULONG width, ULONG height)
{
static HBRUSH hDraggingRectBrush = NULL;
-
+ HBRUSH hbrush;
+
if(!hDraggingRectBrush)
{
static HBITMAP hDraggingPattern = NULL;
const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
-
+
hDraggingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
hDraggingRectBrush = CreatePatternBrush(hDraggingPattern);
}
-
- HBRUSH hbrush = SelectObject( hdc, hDraggingRectBrush );
+
+ hbrush = SelectObject( hdc, hDraggingRectBrush );
PatBlt( hdc, rect->left, rect->top,
rect->right - rect->left - width, height, PATINVERT );
PatBlt( hdc, rect->left, rect->top + height, width,
POINT minTrack, maxTrack;
POINT capturePoint, pt;
ULONG Style = GetWindowLongW(hwnd, GWL_STYLE);
- ULONG ExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
+ ULONG ExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
BOOL thickframe;
BOOL iconic = Style & WS_MINIMIZE;
BOOL moved = FALSE;
HWND hWndParent = NULL;
SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
-
+
pt.x = GET_X_LPARAM(dwPoint);
pt.y = GET_Y_LPARAM(dwPoint);
capturePoint = pt;
-
+
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd))
{
return;
}
-
+
thickframe = UserHasThickFrameStyle(Style, ExStyle) && !(Style & WS_MINIMIZE);
if ((wParam & 0xfff0) == SC_MOVE)
{
- if (!hittest)
+ if (!hittest)
{
hittest = DefWndStartSizeMove(hwnd, wParam, &capturePoint);
}
}
}
- if (Style & WS_CHILD)
- {
- hWndParent = GetParent(hwnd);
- }
-
/* Get min/max info */
-
+
WinPosGetMinMaxInfo(hwnd, NULL, NULL, &minTrack, &maxTrack);
GetWindowRect(hwnd, &sizingRect);
- unmodRect = sizingRect;
if (Style & WS_CHILD)
{
+ hWndParent = GetParent(hwnd);
MapWindowPoints( 0, hWndParent, (LPPOINT)&sizingRect, 2 );
+ unmodRect = sizingRect;
GetClientRect(hWndParent, &mouseRect );
clipRect = mouseRect;
MapWindowPoints(hWndParent, HWND_DESKTOP, (LPPOINT)&clipRect, 2);
}
- else
+ else
{
if(!(ExStyle & WS_EX_TOPMOST))
{
SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
clipRect = mouseRect;
}
+ unmodRect = sizingRect;
}
ClipCursor(&clipRect);
-
+
origRect = sizingRect;
if (ON_LEFT_BORDER(hittest))
{
mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
}
if (Style & WS_CHILD)
- {
+ {
MapWindowPoints( hWndParent, 0, (LPPOINT)&mouseRect, 2 );
}
-
+
SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
NtUserSetGUIThreadHandle(MSQ_STATE_MOVESIZE, hwnd);
- if (GetCapture() != hwnd) SetCapture( hwnd );
-
+ if (GetCapture() != hwnd) SetCapture( hwnd );
+
if (Style & WS_CHILD)
{
/* Retrieve a default cache DC (without using the window style) */
hdc = GetDC( 0 );
DesktopRgn = CreateRectRgnIndirect(&clipRect);
}
-
+
SelectObject(hdc, DesktopRgn);
-
+
if( iconic ) /* create a cursor for dragging */
{
HICON hIcon = (HICON)GetClassLongW(hwnd, GCL_HICON);
if( hIcon ) hDragCursor = CursorIconToCursor( hIcon, TRUE );
if( !hDragCursor ) iconic = FALSE;
}
-
+
/* invert frame if WIN31_LOOK to indicate mouse click on caption */
if( !iconic && !DragFullWindows)
{
UserDrawMovingFrame( hdc, &sizingRect, thickframe);
}
-
+
for(;;)
{
int dx = 0, dy = 0;
if (GetMessageW(&msg, 0, 0, 0) <= 0)
break;
-
+
/* Exit on button-up, Return, or Esc */
if ((msg.message == WM_LBUTTONUP) ||
- ((msg.message == WM_KEYDOWN) &&
+ ((msg.message == WM_KEYDOWN) &&
((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
-
+
if (msg.message == WM_PAINT)
{
if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
continue;
}
-
+
if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
continue; /* We are not interested in other messages */
-
+
pt = msg.pt;
-
+
if (msg.message == WM_KEYDOWN) switch(msg.wParam)
{
case VK_UP: pt.y -= 8; break;
case VK_DOWN: pt.y += 8; break;
case VK_LEFT: pt.x -= 8; break;
- case VK_RIGHT: pt.x += 8; break;
+ case VK_RIGHT: pt.x += 8; break;
}
-
+
pt.x = max( pt.x, mouseRect.left );
pt.x = min( pt.x, mouseRect.right );
pt.y = max( pt.y, mouseRect.top );
pt.y = min( pt.y, mouseRect.bottom );
-
+
dx = pt.x - capturePoint.x;
dy = pt.y - capturePoint.y;
-
+
if (dx || dy)
{
if( !moved )
{
moved = TRUE;
-
+
if( iconic ) /* ok, no system popup tracking */
{
hOldCursor = SetCursor(hDragCursor);
ShowCursor( TRUE );
- }
+ }
}
-
+
if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
else
{
RECT newRect = unmodRect;
WPARAM wpSizingHit = 0;
-
+
if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
capturePoint = pt;
-
+
/* determine the hit location */
if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
unmodRect = newRect;
SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
-
+
if (!iconic)
{
if(!DragFullWindows)
}
}
}
-
+
ReleaseCapture();
ClipCursor(NULL);
if( iconic )
}
else if(!DragFullWindows)
UserDrawMovingFrame( hdc, &sizingRect, thickframe );
-
+
if (Style & WS_CHILD)
ReleaseDC( hWndParent, hdc );
else
NtUserSetGUIThreadHandle(MSQ_STATE_MOVESIZE, NULL);
SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
-
+
/* window moved or resized */
if (moved)
{
origRect.right - origRect.left,
origRect.bottom - origRect.top,
( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
- }
+ }
}
-
+
if( IsWindow(hwnd) )
if( Style & WS_MINIMIZE )
{
/* Single click brings up the system menu when iconized */
-
- if( !moved )
+
+ if( !moved )
{
- if( Style & WS_SYSMENU )
+ if( Style & WS_SYSMENU )
SendMessageA( hwnd, WM_SYSCOMMAND,
SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
}
DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, POINT Pt)
{
WINDOWPLACEMENT wp;
-
+
switch (wParam & 0xfff0)
{
case SC_MOVE:
LRESULT
DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos)
{
- POINT maxSize, minTrack;
+ POINT maxTrack, minTrack;
LONG style = GetWindowLongA(hWnd, GWL_STYLE);
if (Pos->flags & SWP_NOSIZE) return 0;
if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0))
{
- WinPosGetMinMaxInfo(hWnd, &maxSize, NULL, &minTrack, NULL);
- Pos->cx = min(Pos->cx, maxSize.x);
- Pos->cy = min(Pos->cy, maxSize.y);
+ WinPosGetMinMaxInfo(hWnd, NULL, NULL, &minTrack, &maxTrack);
+ Pos->cx = min(Pos->cx, maxTrack.x);
+ Pos->cy = min(Pos->cy, maxTrack.y);
if (!(style & WS_MINIMIZE))
{
if (Pos->cx < minTrack.x) Pos->cx = minTrack.x;
VOID FASTCALL
DefWndScreenshot(HWND hWnd)
{
-
+
}
LRESULT STDCALL
POINT Pt;
DWORD Style;
LONG HitCode;
-
+
Style = GetWindowLongW(hWnd, GWL_STYLE);
-
+
Pt.x = GET_X_LPARAM(lParam);
Pt.y = GET_Y_LPARAM(lParam);
if (Style & WS_CHILD)
{
HMENU SystemMenu;
UINT Flags;
-
+
if((SystemMenu = GetSystemMenu(hWnd, FALSE)))
{
MenuInitSysMenuPopup(SystemMenu, GetWindowLongW(hWnd, GWL_STYLE),
GetClassLongW(hWnd, GCL_STYLE), HitCode);
-
+
if(HitCode == HTCAPTION)
Flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON;
else
Flags = TPM_LEFTBUTTON;
-
+
TrackPopupMenu(SystemMenu, Flags,
Pt.x, Pt.y, 0, hWnd, NULL);
}
}
break;
}
-
+
case WM_PRINT:
{
/* FIXME: Implement. */
PAINTSTRUCT Ps;
HDC hDC = BeginPaint(hWnd, &Ps);
if (hDC)
- {
+ {
HICON hIcon;
if (GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE &&
(hIcon = (HICON)GetClassLongW(hWnd, GCL_HICON)) != NULL)
y = (ClientRect.bottom - ClientRect.top -
GetSystemMetrics(SM_CYICON)) / 2;
DrawIcon(hDC, x, y, hIcon);
- }
+ }
EndPaint(hWnd, &Ps);
}
return (0);
FillRect((HDC)wParam, &Rect, hBrush);
return (1);
}
-
+
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_SETCURSOR:
{
ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
-
+
if (Style & WS_CHILD)
{
if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
}
break;
}
-
+
case WM_SHOWWINDOW:
{
LONG Style;
if (!lParam)
return 0;
Style = GetWindowLongW(hWnd, GWL_STYLE);
- if (!(Style & WS_POPUP))
- return 0;
+// if (!(Style & WS_POPUP))
+// return 0;
if ((Style & WS_VISIBLE) && wParam)
return 0;
if (!(Style & WS_VISIBLE) && !wParam)
return 0;
if (!GetWindow(hWnd, GW_OWNER))
return 0;
+ NtUserCallTwoParam((DWORD) hWnd, (DWORD) wParam, TWOPARAM_ROUTINE_ROS_SHOWWINDOW);
ShowWindow(hWnd, wParam ? SW_SHOWNA : SW_HIDE);
break;
}
return (-1);
/*
case WM_DROPOBJECT:
-
+
break;
*/
case WM_QUERYDROPOBJECT:
}
break;
}
-
+
case WM_SYSTIMER:
{
THRDCARETINFO CaretInfo;
{
ANSI_STRING AnsiString;
UNICODE_STRING UnicodeString;
-
+
if(lParam)
{
RtlInitAnsiString(&AnsiString, (LPSTR)lParam);
}
else
NtUserDefSetText(hWnd, NULL);
-
+
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
DefWndNCPaint(hWnd, (HRGN)1, -1);
if(lParam)
RtlInitUnicodeString(&UnicodeString, (LPWSTR)lParam);
-
+
NtUserDefSetText(hWnd, (lParam ? &UnicodeString : NULL));
-
+
if ((GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
{
DefWndNCPaint(hWnd, (HRGN)1, -1);