-/* $Id: defwnd.c,v 1.62 2003/08/06 18:43:57 weiden Exp $
+/* $Id: defwnd.c,v 1.63 2003/08/07 04:03:24 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
/* FUNCTIONS *****************************************************************/
-BOOL IsMaxBoxActive(HWND hWnd)
+BOOL
+IsMaxBoxActive(HWND hWnd)
{
- ULONG uStyle = GetWindowLong( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
return (uStyle & WS_MAXIMIZEBOX);
}
-BOOL IsCloseBoxActive( HWND hWnd )
+BOOL
+IsCloseBoxActive( HWND hWnd )
{
- ULONG uStyle = GetWindowLong(hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW(hWnd, GWL_STYLE );
return ( uStyle & WS_SYSMENU );
}
-BOOL IsMinBoxActive( HWND hWnd )
+BOOL
+IsMinBoxActive( HWND hWnd )
{
- ULONG uStyle = GetWindowLong( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
return (uStyle & WS_MINIMIZEBOX);
}
-INT UIGetFrameSizeX( HWND hWnd )
+INT
+UIGetFrameSizeX( HWND hWnd )
{
- ULONG uStyle = GetWindowLong( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
if ( uStyle & WS_THICKFRAME )
return GetSystemMetrics( SM_CXSIZEFRAME );
return GetSystemMetrics( SM_CXFRAME );
}
-INT UIGetFrameSizeY( HWND hWnd )
+INT
+UIGetFrameSizeY( HWND hWnd )
{
- ULONG uStyle = GetWindowLong( hWnd, GWL_STYLE );
+ ULONG uStyle = GetWindowLongW( hWnd, GWL_STYLE );
if ( uStyle & WS_THICKFRAME )
return GetSystemMetrics( SM_CYSIZEFRAME );
(ExStyle & WS_EX_DLGMODALFRAME));
}
-void UserGetInsideRectNC( HWND hWnd, RECT *rect )
+void
+UserGetInsideRectNC( HWND hWnd, RECT *rect )
{
RECT WindowRect;
ULONG Style;
ULONG ExStyle;
- Style = GetWindowLong(hWnd, GWL_STYLE);
- ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
+ Style = GetWindowLongW(hWnd, GWL_STYLE);
+ ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
GetWindowRect(hWnd, &WindowRect);
rect->top = rect->left = 0;
rect->right = WindowRect.right - WindowRect.left;
}
}
-VOID UserDrawSysMenuButton( HWND hWnd, HDC hDC, BOOL down )
+VOID
+UserDrawSysMenuButton( HWND hWnd, HDC hDC, BOOL down )
{
RECT Rect;
HDC hDcMem;
HBITMAP hSavedBitmap;
- hbSysMenu = LoadBitmap(0, MAKEINTRESOURCE(OBM_CLOSE));
+ hbSysMenu = (HBITMAP)LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE));
UserGetInsideRectNC(hWnd, &Rect);
hDcMem = CreateCompatibleDC(hDC);
hSavedBitmap = SelectObject(hDcMem, hbSysMenu);
BitBlt(hDC, Rect.left + 2, Rect.top +
2, 16, 16, hDcMem,
- (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) ?
+ (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ?
GetSystemMetrics(SM_CXSIZE): 0, 0, SRCCOPY);
SelectObject(hDcMem, hSavedBitmap);
DeleteDC(hDcMem);
/* FIXME: Cache bitmaps, then just bitblt instead of calling DFC() (and
wasting precious CPU cycles) every time */
-static void UserDrawCaptionButton( HWND hWnd, HDC hDC, BOOL bDown, ULONG Type )
+static void
+UserDrawCaptionButton( HWND hWnd, HDC hDC, BOOL bDown, ULONG Type )
{
+ RECT rect;
+ INT iBmpWidth = GetSystemMetrics(SM_CXSIZE) - 2;
+ INT iBmpHeight = GetSystemMetrics(SM_CYSIZE) - 4;
- RECT rect;
- INT iBmpWidth = GetSystemMetrics(SM_CXSIZE) - 2;
- INT iBmpHeight = GetSystemMetrics(SM_CYSIZE) - 4;
-
- INT OffsetX = UIGetFrameSizeX( hWnd );
- INT OffsetY = UIGetFrameSizeY( hWnd );
+ INT OffsetX = UIGetFrameSizeX( hWnd );
+ INT OffsetY = UIGetFrameSizeY( hWnd );
- if(!(GetWindowLong( hWnd, GWL_STYLE ) & WS_SYSMENU))
- {
- return;
- }
+ if(!(GetWindowLongW( hWnd, GWL_STYLE ) & WS_SYSMENU))
+ {
+ return;
+ }
- GetWindowRect( hWnd, &rect );
-
- rect.right = rect.right - rect.left;
- rect.bottom = rect.bottom - rect.top;
- rect.left = rect.top = 0;
+ GetWindowRect( hWnd, &rect );
- switch(Type)
- {
- case DFCS_CAPTIONMIN:
- {
- if ((GetWindowLong( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
- return; /* ToolWindows don't have min/max buttons */
-
- SetRect(&rect,
- rect.right - OffsetX - (iBmpWidth*3) - 5,
- OffsetY + 2,
- rect.right - (iBmpWidth * 2) - OffsetX - 5,
- rect.top + iBmpHeight + OffsetY + 2 );
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- DFCS_CAPTIONMIN | (bDown ? DFCS_PUSHED : 0) |
- (IsMinBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
- break;
- }
- case DFCS_CAPTIONMAX:
- {
- if ((GetWindowLong( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
- return; /* ToolWindows don't have min/max buttons */
- SetRect(&rect,
- rect.right - OffsetX - (iBmpWidth*2) - 5,
- OffsetY + 2,
- rect.right - iBmpWidth - OffsetX - 5,
- rect.top + iBmpHeight + OffsetY + 2 );
-
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- (IsZoomed(hWnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX) |
- (bDown ? DFCS_PUSHED : 0) |
- (IsMaxBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
- break;
- }
- case DFCS_CAPTIONCLOSE:
- {
- SetRect(&rect,
- rect.right - OffsetX - iBmpWidth - 3,
- OffsetY + 2,
- rect.right - OffsetX - 3,
- rect.top + iBmpHeight + OffsetY + 2 );
-
- DrawFrameControl( hDC, &rect, DFC_CAPTION,
- (DFCS_CAPTIONCLOSE |
- (bDown ? DFCS_PUSHED : 0) |
- (IsCloseBoxActive(hWnd) ? 0 : DFCS_INACTIVE)) );
- }
- }
-}
+ rect.right = rect.right - rect.left;
+ rect.bottom = rect.bottom - rect.top;
+ rect.left = rect.top = 0;
-static void UserDrawCaptionNC( HDC hDC, RECT *rect, HWND hWnd,
- DWORD style, BOOL active )
-{
- RECT r = *rect;
- WCHAR buffer[256];
- /* FIXME: Implement and Use DrawCaption() */
- SelectObject( hDC, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
-
- PatBlt(hDC,rect->left + GetSystemMetrics(SM_CXFRAME), rect->top +
- GetSystemMetrics(SM_CYFRAME), rect->right - (GetSystemMetrics(SM_CXFRAME) * 2), (rect->top +
- GetSystemMetrics(SM_CYCAPTION)) - 1, PATCOPY );
-
- if (style & WS_SYSMENU)
+ switch(Type)
+ {
+ case DFCS_CAPTIONMIN:
{
- UserDrawSysMenuButton( hWnd, hDC, FALSE);
- r.left += GetSystemMetrics(SM_CXSIZE) + 1;
- UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONCLOSE);
- r.right -= GetSystemMetrics(SM_CXSMSIZE) + 1;
- UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMIN);
- UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMAX);
+ if ((GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
+ return; /* ToolWindows don't have min/max buttons */
+
+ SetRect(&rect,
+ rect.right - OffsetX - (iBmpWidth*3) - 5,
+ OffsetY + 2,
+ rect.right - (iBmpWidth * 2) - OffsetX - 5,
+ rect.top + iBmpHeight + OffsetY + 2 );
+ DrawFrameControl( hDC, &rect, DFC_CAPTION,
+ DFCS_CAPTIONMIN | (bDown ? DFCS_PUSHED : 0) |
+ (IsMinBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
+ break;
}
- if (GetWindowTextW( hWnd, buffer, sizeof(buffer)/sizeof(buffer[0]) ))
+ case DFCS_CAPTIONMAX:
{
- NONCLIENTMETRICSW nclm;
- HFONT hFont, hOldFont;
-
- nclm.cbSize = sizeof(nclm);
- SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
- SetTextColor(hDC, SysColours[ active ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT]);
- SetBkMode( hDC, TRANSPARENT );
- if (style & WS_EX_TOOLWINDOW)
- hFont = CreateFontIndirectW(&nclm.lfSmCaptionFont);
- else
- hFont = CreateFontIndirectW(&nclm.lfCaptionFont);
- hOldFont = SelectObject(hDC, hFont);
- TextOutW(hDC, r.left + (GetSystemMetrics(SM_CXDLGFRAME) * 2), rect->top + (nclm.lfCaptionFont.lfHeight / 2), buffer, wcslen(buffer));
- DeleteObject (SelectObject (hDC, hOldFont));
+ if ((GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW) == TRUE)
+ return; /* ToolWindows don't have min/max buttons */
+ SetRect(&rect,
+ rect.right - OffsetX - (iBmpWidth*2) - 5,
+ OffsetY + 2,
+ rect.right - iBmpWidth - OffsetX - 5,
+ rect.top + iBmpHeight + OffsetY + 2 );
+
+ DrawFrameControl( hDC, &rect, DFC_CAPTION,
+ (IsZoomed(hWnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX) |
+ (bDown ? DFCS_PUSHED : 0) |
+ (IsMaxBoxActive(hWnd) ? 0 : DFCS_INACTIVE) );
+ break;
}
+ case DFCS_CAPTIONCLOSE:
+ {
+ SetRect(&rect,
+ rect.right - OffsetX - iBmpWidth - 3,
+ OffsetY + 2,
+ rect.right - OffsetX - 3,
+ rect.top + iBmpHeight + OffsetY + 2 );
+
+ DrawFrameControl( hDC, &rect, DFC_CAPTION,
+ (DFCS_CAPTIONCLOSE |
+ (bDown ? DFCS_PUSHED : 0) |
+ (IsCloseBoxActive(hWnd) ? 0 : DFCS_INACTIVE)) );
+ }
+ }
+}
+
+static void
+UserDrawCaptionNC (
+ HDC hDC,
+ RECT *rect,
+ HWND hWnd,
+ DWORD style,
+ BOOL active )
+{
+ RECT r = *rect;
+ WCHAR buffer[256];
+ /* FIXME: Implement and Use DrawCaption() */
+ SelectObject( hDC, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
+
+ PatBlt(hDC,rect->left + GetSystemMetrics(SM_CXFRAME), rect->top +
+ GetSystemMetrics(SM_CYFRAME), rect->right - (GetSystemMetrics(SM_CXFRAME) * 2), (rect->top +
+ GetSystemMetrics(SM_CYCAPTION)) - 1, PATCOPY );
+
+ if (style & WS_SYSMENU)
+ {
+ UserDrawSysMenuButton( hWnd, hDC, FALSE);
+ r.left += GetSystemMetrics(SM_CXSIZE) + 1;
+ UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONCLOSE);
+ r.right -= GetSystemMetrics(SM_CXSMSIZE) + 1;
+ UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMIN);
+ UserDrawCaptionButton( hWnd, hDC, FALSE, DFCS_CAPTIONMAX);
+ }
+ if (GetWindowTextW( hWnd, buffer, sizeof(buffer)/sizeof(buffer[0]) ))
+ {
+ NONCLIENTMETRICSW nclm;
+ HFONT hFont, hOldFont;
+
+ nclm.cbSize = sizeof(nclm);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
+ SetTextColor(hDC, SysColours[ active ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT]);
+ SetBkMode( hDC, TRANSPARENT );
+ if (style & WS_EX_TOOLWINDOW)
+ hFont = CreateFontIndirectW(&nclm.lfSmCaptionFont);
+ else
+ hFont = CreateFontIndirectW(&nclm.lfCaptionFont);
+ hOldFont = SelectObject(hDC, hFont);
+ TextOutW(hDC, r.left + (GetSystemMetrics(SM_CXDLGFRAME) * 2), rect->top + (nclm.lfCaptionFont.lfHeight / 2), buffer, wcslen(buffer));
+ DeleteObject (SelectObject (hDC, hOldFont));
+ }
}
}
-void SCROLL_DrawScrollBar (HWND hWnd, HDC hDC, INT nBar, BOOL arrows, BOOL interior);
+void
+SCROLL_DrawScrollBar (HWND hWnd, HDC hDC, INT nBar, BOOL arrows, BOOL interior);
VOID
DefWndDoPaintNC(HWND hWnd, HRGN clip)
int wFrame = 0;
Active = GetWindowLongW(hWnd, GWL_STYLE) & WIN_NCACTIVATED;
- Style = GetWindowLong(hWnd, GWL_STYLE);
- ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
+ Style = GetWindowLongW(hWnd, GWL_STYLE);
+ ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
hDC = GetDCEx(hWnd, (clip > (HRGN)1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
((clip > (HRGN)1) ? (DCX_INTERSECTRGN | DCX_KEEPCLIPRGN) : 0));
DefWndHitTestNC(HWND hWnd, POINT Point)
{
RECT WindowRect;
- ULONG Style = GetWindowLong(hWnd, GWL_STYLE);
- ULONG ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
+ ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
+ ULONG ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
GetWindowRect(hWnd, &WindowRect);
if (!PtInRect(&WindowRect, Point))
}
case HTSYSMENU:
{
- if (GetWindowLong(hWnd, GWL_STYLE) & WS_SYSMENU)
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_SYSMENU)
{
- if (!(GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE))
+ if (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
{
HDC hDC = GetWindowDC(hWnd);
UserDrawSysMenuButton(hWnd, hDC, TRUE);
case HTCLIENT:
{
- HICON hCursor = (HICON)GetClassLong(hWnd, GCL_HCURSOR);
+ HICON hCursor = (HICON)GetClassLongW(hWnd, GCL_HCURSOR);
if (hCursor)
{
SetCursor(hCursor);
POINT pt;
MSG msg;
RECT rectWindow;
- ULONG Style = GetWindowLong(hWnd, GWL_STYLE);
+ ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
GetWindowRect(hWnd, &rectWindow);
{
while(!hittest)
{
- GetMessage(&msg, NULL, 0, 0);
+ GetMessageW(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_MOUSEMOVE:
HCURSOR hDragCursor = 0, hOldCursor = 0;
POINT minTrack, maxTrack;
POINT capturePoint, pt;
- ULONG Style = GetWindowLong(hwnd, GWL_STYLE);
- ULONG ExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
+ ULONG Style = GetWindowLongW(hwnd, GWL_STYLE);
+ ULONG ExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
BOOL thickframe = UserHasThickFrameStyle(Style, ExStyle);
BOOL iconic = Style & WS_MINIMIZE;
BOOL moved = FALSE;
if( iconic ) /* create a cursor for dragging */
{
- HICON hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
- if(!hIcon) hIcon = (HICON)SendMessage( hwnd, WM_QUERYDRAGICON, 0, 0L);
+ HICON hIcon = (HICON)GetClassLongW(hwnd, GCL_HICON);
+ if(!hIcon) hIcon = (HICON)SendMessageW( hwnd, WM_QUERYDRAGICON, 0, 0L);
if( hIcon ) hDragCursor = CursorIconToCursor( hIcon, TRUE );
if( !hDragCursor ) iconic = FALSE;
}
{
int dx = 0, dy = 0;
- GetMessage(&msg, 0, 0, 0);
+ GetMessageW(&msg, 0, 0, 0);
/* Exit on button-up, Return, or Esc */
if ((msg.message == WM_LBUTTONUP) ||
Result |= WVR_HREDRAW;
}
- if (!(GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE))
+ if (!(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
{
- DefWndAdjustRect(&TmpRect, GetWindowLong(hWnd, GWL_STYLE),
- FALSE, GetWindowLong(hWnd, GWL_EXSTYLE));
+ DefWndAdjustRect(&TmpRect, GetWindowLongW(hWnd, GWL_STYLE),
+ FALSE, GetWindowLongW(hWnd, GWL_EXSTYLE));
Rect->left -= TmpRect.left;
Rect->top -= TmpRect.top;
Rect->right -= TmpRect.right;
Rect->bottom -= TmpRect.bottom;
- if (UserHasMenu(hWnd, GetWindowLong(hWnd, GWL_EXSTYLE)))
+ if (UserHasMenu(hWnd, GetWindowLongW(hWnd, GWL_EXSTYLE)))
{
Rect->top += MenuGetMenuBarHeight(hWnd,
Rect->right - Rect->left,
case WM_CONTEXTMENU:
{
- if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
{
if (bUnicode)
{
Pt.x = SLOWORD(lParam);
Pt.y = SHIWORD(lParam);
- if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
{
ScreenToClient(GetParent(hWnd), &Pt);
}
GetSystemMetrics(SM_CYICON)) / 2;
DrawIcon(hDC, x, y, hIcon);
}
- if (GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_CLIENTEDGE)
+ if (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_CLIENTEDGE)
{
RECT WindowRect;
GetClientRect(hWnd, &WindowRect);
case WM_MOUSEACTIVATE:
{
- if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
{
LONG Ret;
if (bUnicode)
{
/* Check if the window is minimized. */
if (LOWORD(lParam) != WA_INACTIVE &&
- !(GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE))
+ !(GetWindowLongW(hWnd, GWL_STYLE) & WS_MINIMIZE))
{
SetFocus(hWnd);
}
case WM_MOUSEWHEEL:
{
- if (GetWindowLong(hWnd, GWL_STYLE & WS_CHILD))
+ if (GetWindowLongW(hWnd, GWL_STYLE & WS_CHILD))
{
if (bUnicode)
{
case WM_SETCURSOR:
{
- if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
+ if (GetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD)
{
if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
{
}
for (Len = 1; Len < 64; Len++)
{
- if ((hIcon = LoadIconW(NULL, MAKEINTRESOURCE(Len))) != NULL)
+ if ((hIcon = LoadIconW(NULL, MAKEINTRESOURCEW(Len))) != NULL)
{
return((LRESULT)hIcon);
}
if (WindowTextAtom != 0)
{
WindowTextAtom =
- (LPWSTR)(DWORD)GlobalAddAtom(L"USER32!WindowTextAtomW");
+ (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW");
}
if (WindowTextAtom != 0 &&
(WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL)