From 67ad8387f3563a4bb4ef29f0b1b77f3e3f6a8702 Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Wed, 1 Dec 1999 22:30:48 +0000 Subject: [PATCH] fixed some prototypes by adding stdcall attribute svn path=/trunk/; revision=812 --- reactos/lib/user32/controls/icontitle.c | 17 +- reactos/lib/user32/graphics/draw.c | 22 +- reactos/lib/user32/graphics/fill.c | 23 +- reactos/lib/user32/graphics/icon.c | 40 +- reactos/lib/user32/internal/dce.c | 52 +- reactos/lib/user32/internal/defwnd.c | 11 +- reactos/lib/user32/internal/dialog.c | 169 ++- reactos/lib/user32/internal/nc.c | 79 +- reactos/lib/user32/internal/paint.c | 7 +- reactos/lib/user32/internal/property.c | 5 +- reactos/lib/user32/internal/region.c | 33 - reactos/lib/user32/internal/win.c | 76 +- reactos/lib/user32/makefile.main | 2 +- reactos/lib/user32/makefile_rex | 6 +- reactos/lib/user32/misc/bitmap.c | 10 +- reactos/lib/user32/misc/main.c | 22 +- reactos/lib/user32/misc/string.c | 3 +- reactos/lib/user32/misc/vk.c | 48 +- reactos/lib/user32/user32.rc | 8 +- reactos/lib/user32/windows/class.c | 72 +- reactos/lib/user32/windows/dc.c | 127 +-- reactos/lib/user32/windows/defdlg.c | 1 + reactos/lib/user32/windows/hook.c | 8 +- reactos/lib/user32/windows/message.c | 138 --- reactos/lib/user32/windows/scroll.c | 40 +- reactos/lib/user32/windows/timer.c | 2 +- reactos/lib/user32/windows/win.c | 118 +-- reactos/lib/user32/windows/winpos.c | 1259 +++-------------------- 28 files changed, 643 insertions(+), 1755 deletions(-) delete mode 100644 reactos/lib/user32/windows/message.c diff --git a/reactos/lib/user32/controls/icontitle.c b/reactos/lib/user32/controls/icontitle.c index 496d24a7a0f..6c3745205c3 100644 --- a/reactos/lib/user32/controls/icontitle.c +++ b/reactos/lib/user32/controls/icontitle.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -39,14 +39,21 @@ HWND ICONTITLE_Create( WND* wnd ) WND* wndPtr; HWND hWnd; - if( wnd->dwStyle & WS_CHILD ) - hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_NAME, NULL, + + + if( wnd->dwStyle & WS_CHILD ) { + + hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_NAME_A, NULL, WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 1, 1, wnd->parent->hwndSelf, 0, wnd->hInstance, NULL ); - else - hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_NAME, NULL, + } + else { + + hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_NAME_A, NULL, WS_CLIPSIBLINGS, 0, 0, 1, 1, wnd->hwndSelf, 0, wnd->hInstance, NULL ); + + } wndPtr = WIN_FindWndPtr( hWnd ); if( wndPtr ) { diff --git a/reactos/lib/user32/graphics/draw.c b/reactos/lib/user32/graphics/draw.c index d6f73a4ceb2..acb1182d8ec 100644 --- a/reactos/lib/user32/graphics/draw.c +++ b/reactos/lib/user32/graphics/draw.c @@ -1,4 +1,5 @@ #include +//#include #include WINBOOL STDCALL DrawEdge( HDC hdc, LPRECT rc, UINT edge, UINT flags ) @@ -11,24 +12,3 @@ WINBOOL STDCALL DrawEdge( HDC hdc, LPRECT rc, UINT edge, UINT flags ) else return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags); } -WINBOOL DrawIcon(HDC hDC, int xLeft, int yTop, HICON hIcon - ) -{ - return FALSE; -} - -WINBOOL -STDCALL -DrawIconEx(HDC hdc, int xLeft, int yTop, - HICON hIcon, int cxWidth, int cyWidth, - UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags) -{ -} - -WINBOOL -STDCALL -DrawFocusRect( - HDC hDC, - CONST RECT * lprc) -{ -} \ No newline at end of file diff --git a/reactos/lib/user32/graphics/fill.c b/reactos/lib/user32/graphics/fill.c index e00ee6feacc..140f5e16df4 100644 --- a/reactos/lib/user32/graphics/fill.c +++ b/reactos/lib/user32/graphics/fill.c @@ -1,14 +1,12 @@ #include #include +#include + -/*********************************************************************** - * FillWindow (USER.324) - */ void FillWindow( HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush ) { RECT rect; GetClientRect( hwnd, &rect ); - // DPtoLP16( hdc, (LPPOINT16)&rect, 2 ); PaintRect( hwndParent, hwnd, hdc, hbrush, &rect ); } @@ -34,23 +32,8 @@ void PaintRect( HWND hwndParent, HWND hwnd, HDC hdc, } -/*********************************************************************** - * GetControlBrush (USER.326) - */ -HBRUSH STDCALL GetControlBrush( HWND hwnd, HDC hdc, UINT ctlType ) -{ - WND* wndPtr = WIN_FindWndPtr( hwnd ); - if((ctlType <= CTLCOLOR_MAX) && wndPtr ) - { - WND* parent; - if( wndPtr->dwStyle & WS_POPUP ) parent = wndPtr->owner; - else parent = wndPtr->parent; - if( !parent ) parent = wndPtr; - return (HBRUSH)PAINT_GetControlBrush( parent->hwndSelf, hwnd, hdc, ctlType ); - } - return (HBRUSH)0; -} + INT STDCALL FrameRect( HDC hdc, const RECT *rect, HBRUSH hbrush ) { diff --git a/reactos/lib/user32/graphics/icon.c b/reactos/lib/user32/graphics/icon.c index d6111b68c32..cad871185c9 100644 --- a/reactos/lib/user32/graphics/icon.c +++ b/reactos/lib/user32/graphics/icon.c @@ -82,12 +82,16 @@ GetIconInfo( HICON hIcon, PICONINFO piconinfo) { + + return TRUE; } -HICON LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName ) +HICON +STDCALL +LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName ) { HRSRC hrsrc; ICONINFO *IconInfo; @@ -96,7 +100,7 @@ HICON LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName ) return LoadStandardIcon((UINT)lpIconName); } //RT_GROUP_ICON -hrsrc = FindResourceExA(hInstance,RT_GROUP_ICON, lpIconName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)); + hrsrc = FindResourceExA(hInstance,RT_GROUP_ICON, lpIconName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)); if ( hrsrc == NULL ) return NULL; @@ -108,7 +112,9 @@ hrsrc = FindResourceExA(hInstance,RT_GROUP_ICON, lpIconName, MAKELANGID(LANG_NEU return CreateIconIndirect(IconInfo); } -HICON LoadIconW(HINSTANCE hInstance,LPCWSTR lpIconName ) +HICON +STDCALL +LoadIconW(HINSTANCE hInstance,LPCWSTR lpIconName ) { HRSRC hrsrc; ICONINFO *IconInfo; @@ -164,4 +170,32 @@ HICON LoadStandardIcon(UINT IconId) } return NULL; +} + +WINBOOL STDCALL DrawIcon(HDC hDC, int xLeft, int yTop, HICON hIcon ) +{ + + return DrawIconEx( hDC, xLeft, yTop,hIcon, -1, -1,0,NULL, DI_DEFAULTSIZE); +} + +WINBOOL +STDCALL +DrawIconEx(HDC hdc, int xLeft, int yTop, + HICON hIcon, int cxWidth, int cyWidth, + UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags) +{ + //ICONINFO IconInfo; + //SIZE Size;; + //GetIconInfo(hIcon,&IconInfo); + //GetBitmapDimensionEx(IconInfo.hbmMask,&Size); + return FALSE; +} + +WINBOOL +STDCALL +DrawFocusRect( + HDC hDC, + CONST RECT * lprc) +{ + return FALSE; } \ No newline at end of file diff --git a/reactos/lib/user32/internal/dce.c b/reactos/lib/user32/internal/dce.c index 25b8e63f421..33ef045e1e7 100644 --- a/reactos/lib/user32/internal/dce.c +++ b/reactos/lib/user32/internal/dce.c @@ -7,44 +7,70 @@ DCE *firstDCE = 0; HDC defaultDCstate = 0; +/*********************************************************************** + * REGION_UnionRectWithRgn + * Adds a rectangle to a HRGN32 + * A helper used by scroll.c + */ +WINBOOL REGION_UnionRectWithRgn( HRGN hrgn, const RECT *lpRect ) +{ + + HRGN hRgn; + hRgn = CreateRectRgn(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + + CombineRgn(hrgn,hrgn,hRgn, RGN_DIFF); + + return TRUE; +} + + /*********************************************************************** * DCE_AllocDCE * * Allocate a new DCE. */ -DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type ) +DCE *DCE_AllocDCE( struct tagWND * wndPtr, DCE_TYPE type ) { DCE * dce; + + if (!(dce = HeapAlloc( GetProcessHeap(), 0, sizeof(DCE) ))) return NULL; - if (!(dce->hDC = CreateDC( "DISPLAY", NULL, NULL, NULL ))) + if (!(dce->hDC = CreateDC( "DISPLAY", NULL, NULL, NULL))) { HeapFree( GetProcessHeap(), 0, dce ); return 0; } - /* store DCE handle in DC hook data field */ - - //SetDCHook( dce->hDC, (FARPROC)DCHook, (DWORD)dce ); - - dce->hwndCurrent = hWnd; + + /* store DCE handle in DC hook data field */ + if ( wndPtr != NULL ) { + OffsetWindowOrgEx(dce->hDC,-wndPtr->rectWindow.left, -wndPtr->rectWindow.top, NULL ); + dce->hwndCurrent = wndPtr->hwndSelf; + } + else + dce->hwndCurrent = NULL; dce->hClipRgn = 0; dce->next = firstDCE; firstDCE = dce; + + FillRect(dce->hDC,&(wndPtr->rectWindow),GetStockObject(GRAY_BRUSH)); + +#if 0 if( type != DCE_CACHE_DC ) /* owned or class DC */ { dce->DCXflags = DCX_DCEBUSY; - if( hWnd ) + if( wndPtr != NULL ) { - WND* wnd = WIN_FindWndPtr(hWnd); + - if( wnd->dwStyle & WS_CLIPCHILDREN ) dce->DCXflags |= DCX_CLIPCHILDREN; - if( wnd->dwStyle & WS_CLIPSIBLINGS ) dce->DCXflags |= DCX_CLIPSIBLINGS; + if( wndPtr->dwStyle & WS_CLIPCHILDREN ) dce->DCXflags |= DCX_CLIPCHILDREN; + if( wndPtr->dwStyle & WS_CLIPSIBLINGS ) dce->DCXflags |= DCX_CLIPSIBLINGS; } //SetHookFlags(dce->hDC,DCHF_INVALIDATEVISRGN); } else dce->DCXflags = DCX_CACHE | DCX_DCEEMPTY; - +#endif return dce; } @@ -86,7 +112,7 @@ void DCE_DeleteClipRgn( DCE* dce ) //DPRINT("\trestoring VisRgn\n"); - RestoreVisRgn(dce->hDC); + SelectClipRgn(dce->hDC,NULL); } diff --git a/reactos/lib/user32/internal/defwnd.c b/reactos/lib/user32/internal/defwnd.c index 206060c80a9..96ed48c7ddd 100644 --- a/reactos/lib/user32/internal/defwnd.c +++ b/reactos/lib/user32/internal/defwnd.c @@ -18,7 +18,6 @@ #include -void FillWindow( HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush ); #define WM_CTLCOLOR 0x0019 #define WM_ISACTIVEICON 0x0035 @@ -80,8 +79,11 @@ void DEFWND_SetTextA( WND *wndPtr, LPCSTR text ) { if (!text) text = ""; if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text ); - wndPtr->text = (void *)HEAP_strdupA( GetProcessHeap(), 0, text ); - NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */ + wndPtr->text = (void *)HEAP_strdupA( GetProcessHeap(), 0, text ); + if ( wndPtr->dwStyle & WS_CAPTION ) + NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */ + + } @@ -90,7 +92,8 @@ void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text ) if (!text) text = L""; if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text ); wndPtr->text = (void *)HEAP_strdupW( GetProcessHeap(), 0, text ); - NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */ + if ( wndPtr->dwStyle & WS_CAPTION ) + NC_HandleNCPaint( wndPtr->hwndSelf , (HRGN)1 ); /* Repaint caption */ } /*********************************************************************** diff --git a/reactos/lib/user32/internal/dialog.c b/reactos/lib/user32/internal/dialog.c index 6fff013ada0..d693885b787 100644 --- a/reactos/lib/user32/internal/dialog.c +++ b/reactos/lib/user32/internal/dialog.c @@ -4,6 +4,19 @@ * Copyright 1993, 1994, 1996 Alexandre Julliard */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/user32/internal/dialog.c + * PURPOSE: Reads resources and creates dialogs + * PROGRAMER: Boudewijn Dekker + * UPDATE HISTORY: + * 09/09/99: Modified + * TODO Fixup fonts and fonts and text metrics + Warnings + references to libc + */ + #include #include #include @@ -48,8 +61,6 @@ WINBOOL DIALOG_Init(void) if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH)) xBaseUnit = xBaseUnit * 5 / 4; - DPRINT( "base units = %d,%d\n", - xBaseUnit, yBaseUnit ); return TRUE; } @@ -110,7 +121,9 @@ LPCDLGITEMTEMPLATE DIALOG_ParseTemplate( LPCDLGTEMPLATE DlgTemplate, DLG_TEMPLA result->cx = DlgTemplate->cx; result->cy = DlgTemplate->cy; + printf("%d %d %d %d\n",result->x, result->y, result->cx, result->cy); + p = &(DlgTemplate->cy); p++; @@ -160,11 +173,14 @@ LPCDLGITEMTEMPLATE DIALOG_ParseTemplate( LPCDLGTEMPLATE DlgTemplate, DLG_TEMPLA break; } + result->caption = L""; + /* Get the window caption */ if ( *p != 0 ) { result->caption = (LPCWSTR)p; p += lstrlenW( (LPCWSTR)p ) + 1; - + + /* Get the font name */ if (result->style & DS_SETFONT) @@ -174,7 +190,7 @@ LPCDLGITEMTEMPLATE DIALOG_ParseTemplate( LPCDLGTEMPLATE DlgTemplate, DLG_TEMPLA if (result->dialogEx) { result->weight = *p; p++; - result->italic = *p; p++; + result->italic = LOBYTE(*p); p++; } else { @@ -182,13 +198,35 @@ LPCDLGITEMTEMPLATE DIALOG_ParseTemplate( LPCDLGTEMPLATE DlgTemplate, DLG_TEMPLA result->italic = FALSE; } result->faceName = (LPCWSTR)p; - p += lstrlenW( (LPCWSTR)p ); - p++; + p += lstrlenW( (LPCWSTR)p ) + 1; } - } else { - result->caption = L""; - } + } + else if ( *(p+1) != 0 ) { + p++; + + /* Get the font name */ + + if (result->style & DS_SETFONT) + { + result->pointSize = *p; + p++; + if (result->dialogEx) + { + result->weight = *p; p++; + result->italic = LOBYTE(*p); p++; + } + else + { + result->weight = FW_DONTCARE; + result->italic = FALSE; + } + result->faceName = (LPCWSTR)p; + p += lstrlenW( (LPCWSTR)p ) + 1; + + } + } + @@ -264,11 +302,39 @@ LPCDLGITEMTEMPLATEEX DIALOG_ParseTemplateEx( LPCDLGTEMPLATEEX DlgTemplate, DLG_ break; } + + result->caption = L""; + /* Get the window caption */ if ( *p != 0 ) { result->caption = (LPCWSTR)p; p += lstrlenW( (LPCWSTR)p ) + 1; - + + + /* Get the font name */ + + if (result->style & DS_SETFONT) + { + result->pointSize = *p; + p++; + if (result->dialogEx) + { + result->weight = *p; p++; + result->italic = LOBYTE(*p); p++; + } + else + { + result->weight = FW_DONTCARE; + result->italic = FALSE; + } + result->faceName = (LPCWSTR)p; + p += lstrlenW( (LPCWSTR)p ) + 1; + + } + } + else if ( *(p+1) != 0 ) { + p++; + /* Get the font name */ if (result->style & DS_SETFONT) @@ -289,8 +355,7 @@ LPCDLGITEMTEMPLATEEX DIALOG_ParseTemplateEx( LPCDLGTEMPLATEEX DlgTemplate, DLG_ p += lstrlenW( (LPCWSTR)p ) + 1; } - } else - result->caption = L""; + } /* First control is on dword boundary */ @@ -318,7 +383,7 @@ LPCDLGITEMTEMPLATE DIALOG_GetControl( LPCDLGITEMTEMPLATE DlgItemTemplate, DLG_CO info->cx = DlgItemTemplate->cx; info->cy = DlgItemTemplate->cy; - + info->id = DlgItemTemplate->id; @@ -343,9 +408,6 @@ LPCDLGITEMTEMPLATE DIALOG_GetControl( LPCDLGITEMTEMPLATE DlgItemTemplate, DLG_CO info->className = (LPCSTR)HEAP_strdupW(GetProcessHeap(),0,class_names[id - 0x80]); else info->className = NULL; - - printf("%S\n",info->className); - p++; } else @@ -415,12 +477,12 @@ LPCDLGITEMTEMPLATEEX DIALOG_GetControlEx( LPCDLGITEMTEMPLATEEX DlgItemTemplate, static const WCHAR class_names[6][10] = { - { L"Button" }, /* 0x80 */ - { L"Edit"}, /* 0x81 */ - { L"Static" }, /* 0x82 */ - { L"ListBox"}, /* 0x83 */ - { L"ScrollBar" }, /* 0x84 */ - { L"ComboBox" } /* 0x85 */ + { BUTTON_CLASS_NAME }, /* 0x80 */ + { EDIT_CLASS_NAME }, /* 0x81 */ + { STATIC_CLASS_NAME }, /* 0x82 */ + { LISTBOX_CLASS_NAME}, /* 0x83 */ + { SCROLLBAR_CLASS_NAME }, /* 0x84 */ + { COMBOBOX_CLASS_NAME } /* 0x85 */ }; p++; id = (WORD)*(p); @@ -488,14 +550,16 @@ WINBOOL DIALOG_CreateControls( HANDLE hWndDialog, DIALOGINFO *dlgInfo , else template = (void *)DIALOG_GetControl( (LPDLGITEMTEMPLATE)template, &info ); + + hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY, (LPCWSTR)info.className, (LPCWSTR)info.windowName, - info.style | WS_CHILD | WS_THICKFRAME | WS_VISIBLE, - info.x * dlgInfo->xBaseUnit / 4, - info.y * dlgInfo->yBaseUnit / 8, - info.cx * dlgInfo->xBaseUnit / 4 , - info.cy * dlgInfo->yBaseUnit / 8, + info.style | WS_CHILD | WS_VISIBLE , + info.x * dlgInfo->xBaseUnit / 4, + info.y * dlgInfo->yBaseUnit / 4, + info.cx * dlgInfo->xBaseUnit / 4, + info.cy * dlgInfo->yBaseUnit / 4, hWndDialog, (HMENU)info.id, hInst, info.data ); @@ -514,6 +578,8 @@ WINBOOL DIALOG_CreateControls( HANDLE hWndDialog, DIALOGINFO *dlgInfo , hwndDefButton = hwndCtrl; dlgInfo->idResult = GetWindowLong( hwndCtrl, GWL_ID ); } + + } } return TRUE; @@ -549,6 +615,8 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, xUnit = xBaseUnit; yUnit = yBaseUnit; + + /* Parse dialog template */ @@ -576,22 +644,27 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, FALSE, DEFAULT_CHARSET, 0, 0, PROOF_QUALITY, FF_DONTCARE, (LPCWSTR)template.faceName ); + if (hFont) { TEXTMETRIC tm; HFONT oldFont; + HDC hdc; + /* Calculate the dialog base units */ - HDC hdc = GetDC(0); - oldFont = SelectObject( hdc, hFont ); - GetTextMetrics( hdc, &tm ); - SelectObject( hdc, oldFont ); - ReleaseDC( 0, hdc ); + hdc = CreateDC( L"DISPLAY", NULL, NULL, NULL ); + SelectObject( hdc, hFont ); + GetTextMetrics( hdc, &tm ); + DeleteDC( hdc ); + + xUnit = tm.tmAveCharWidth; yUnit = tm.tmHeight; if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH)) xBaseUnit = xBaseUnit * 5 / 4; /* See DIALOG_Init() */ } + } @@ -600,6 +673,13 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, rect.left = rect.top = 0; rect.right = template.cx * xUnit / 4; rect.bottom = template.cy * yUnit / 8; + + //rect.left = template.x; + //rect.top = template.y; + + //rect.right = template.cx + template.x; + //rect.bottom = template.cy + template.y; + if (template.style & DS_MODALFRAME) template.exStyle |= WS_EX_DLGMODALFRAME; AdjustWindowRectEx( &rect, template.style, @@ -607,6 +687,7 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, rect.right -= rect.left; rect.bottom -= rect.top; + if ((INT)template.x == CW_USEDEFAULT) { rect.left = rect.top = CW_USEDEFAULT; @@ -616,7 +697,7 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, if (template.style & DS_CENTER) { rect.left = (SYSMETRICS_CXSCREEN - rect.right) / 2; - rect.top = (SYSMETRICS_CYSCREEN - rect.bottom) / 2; + rect.top = (SYSMETRICS_CYSCREEN - rect.bottom) / 3; } else { @@ -644,11 +725,12 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, void *dlgTemplate, HWND owner, // template.style & ~WS_VISIBLE -template.style |= WS_VISIBLE; -template.style |= WS_THICKFRAME; +//template.style |= WS_VISIBLE; +//template.style |= WS_THICKFRAME; +//template.style |= WS_SYSMENU; hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className, (LPCWSTR)template.caption, - template.style , + template.style & ~WS_VISIBLE , rect.left, rect.top, rect.right, rect.bottom , owner, hMenu, hInst, NULL ); @@ -669,7 +751,9 @@ template.style |= WS_THICKFRAME; dlgInfo = (DIALOGINFO *)wndPtr->wExtra; dlgInfo->dlgProc = dlgProc; - dlgInfo->hUserFont = hFont; + //dlgInfo->hUserFont = hFont; + dlgInfo->hUserFont = NULL; + dlgInfo->hMenu = hMenu; dlgInfo->xBaseUnit = xUnit; dlgInfo->yBaseUnit = yUnit; @@ -701,17 +785,14 @@ template.style |= WS_THICKFRAME; if (MSG_SendMessage( wndPtr, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param)) SetFocus( dlgInfo->hwndFocus ); + - //if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE)) - //{ + if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE)) + { ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */ UpdateWindow( hwnd ); - // } + } - - PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, - RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 ); return hwnd; } diff --git a/reactos/lib/user32/internal/nc.c b/reactos/lib/user32/internal/nc.c index d63c977ba2f..2551bedb9cc 100644 --- a/reactos/lib/user32/internal/nc.c +++ b/reactos/lib/user32/internal/nc.c @@ -278,8 +278,8 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect ) rect->top = rect->left = 0; rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; - - if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) return; +// || (wndPtr->flags & WIN_MANAGED) + if ((wndPtr->dwStyle & WS_ICONIC) ) return; /* Remove frame from rectangle */ if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) @@ -317,7 +317,8 @@ NC_GetInsideRect95 (HWND hwnd, RECT *rect) rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; - if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->flags & WIN_MANAGED)) return; +// || (wndPtr->flags & WIN_MANAGED) + if ((wndPtr->dwStyle & WS_ICONIC) ) return; /* Remove frame from rectangle */ if (HAS_FIXEDFRAME (wndPtr->dwStyle, wndPtr->dwExStyle )) @@ -362,7 +363,7 @@ LONG NC_DoNCHitTest (WND *wndPtr, POINT pt ) if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; - if (!(wndPtr->flags & WIN_MANAGED)) +// if (!(wndPtr->flags & WIN_MANAGED)) { /* Check borders */ if (HAS_THICKFRAME( wndPtr->dwStyle )) @@ -498,7 +499,7 @@ NC_DoNCHitTest95 (WND *wndPtr, POINT pt ) if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; - if (!(wndPtr->flags & WIN_MANAGED)) +// if (!(wndPtr->flags & WIN_MANAGED)) { /* Check borders */ if (HAS_SIZEFRAME( wndPtr->dwStyle )) @@ -654,7 +655,7 @@ void NC_DrawSysButton( HWND hwnd, HDC hdc, WINBOOL down ) HBITMAP hbitmap; WND *wndPtr = WIN_FindWndPtr( hwnd ); - if( !(wndPtr->flags & WIN_MANAGED) ) +// if( !(wndPtr->flags & WIN_MANAGED) ) { NC_GetInsideRect( hwnd, &rect ); hdcMem = CreateCompatibleDC( hdc ); @@ -677,7 +678,7 @@ static void NC_DrawMaxButton( HWND hwnd, HDC hdc, WINBOOL down ) WND *wndPtr = WIN_FindWndPtr( hwnd ); HDC hdcMem; - if( !(wndPtr->flags & WIN_MANAGED) ) +// if( !(wndPtr->flags & WIN_MANAGED) ) { NC_GetInsideRect( hwnd, &rect ); hdcMem = CreateCompatibleDC( hdc ); @@ -701,7 +702,7 @@ static void NC_DrawMinButton( HWND hwnd, HDC hdc, WINBOOL down ) WND *wndPtr = WIN_FindWndPtr( hwnd ); HDC hdcMem; - if( !(wndPtr->flags & WIN_MANAGED) ) +// if( !(wndPtr->flags & WIN_MANAGED) ) { NC_GetInsideRect( hwnd, &rect ); hdcMem = CreateCompatibleDC( hdc ); @@ -737,7 +738,7 @@ NC_DrawSysButton95 (HWND hwnd, HDC hdc, WINBOOL down) { WND *wndPtr = WIN_FindWndPtr( hwnd ); - if( !(wndPtr->flags & WIN_MANAGED) ) +// if( !(wndPtr->flags & WIN_MANAGED) ) { HICON hIcon = 0; RECT rect; @@ -783,7 +784,7 @@ NC_DrawCloseButton95 (HWND hwnd, HDC hdc, WINBOOL down) HDC hdcMem; WND *wndPtr = WIN_FindWndPtr( hwnd ); - if( !(wndPtr->flags & WIN_MANAGED) ) +// if( !(wndPtr->flags & WIN_MANAGED) ) { BITMAP bmp; HBITMAP hBmp, hOldBmp; @@ -837,7 +838,8 @@ static void NC_DrawMaxButton95( HDC hdcMem; - if( !(wndPtr->flags & WIN_MANAGED) ) { +// if( !(wndPtr->flags & WIN_MANAGED) ) + { GetBitmapDimensionEx((bm = IsZoomed(hwnd) ? (down ? hbitmapRestoreD : hbitmapRestore ) : (down ? hbitmapMaximizeD : hbitmapMaximize)), @@ -896,9 +898,8 @@ static void NC_DrawMinButton95( SIZE bmsz; HBITMAP bm; HDC hdcMem; - - if( !(wndPtr->flags & WIN_MANAGED) && - GetBitmapDimensionEx((bm = down ? hbitmapMinimizeD : +// !(wndPtr->flags & WIN_MANAGED) && + if( GetBitmapDimensionEx((bm = down ? hbitmapMinimizeD : hbitmapMinimize), &bmsz)) { NC_GetInsideRect95( hwnd, &rect ); @@ -1099,7 +1100,7 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, WND * wndPtr = WIN_FindWndPtr( hwnd ); char buffer[256]; - if (wndPtr->flags & WIN_MANAGED) return; +// if (wndPtr->flags & WIN_MANAGED) return; if (!hbitmapClose) { @@ -1156,6 +1157,8 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, SetBkMode( hdc, TRANSPARENT ); DrawTextA( hdc, buffer, -1, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX ); + + } } @@ -1196,15 +1199,15 @@ void NC_DrawCaption95( WND *wndPtr = WIN_FindWndPtr( hwnd ); char buffer[256]; HPEN hPrevPen; - int txt; + int txtlen; - if (wndPtr->flags & WIN_MANAGED) return; +// if (wndPtr->flags & WIN_MANAGED) return; hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) ); MoveToEx( hdc, r.left, r.bottom - 1, NULL ); LineTo( hdc, r.right, r.bottom - 1 ); SelectObject( hdc, hPrevPen ); - // r.bottom - 2; + r.bottom - 2; FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : @@ -1239,12 +1242,12 @@ void NC_DrawCaption95( } if ( wndPtr->class->bUnicode ) - txt = GetWindowTextW( hwnd, buffer, sizeof(buffer) ); + txtlen = GetWindowTextW( hwnd, buffer, sizeof(buffer) ); else - txt = GetWindowTextA( hwnd, buffer, sizeof(buffer) ); + txtlen = GetWindowTextA( hwnd, buffer, sizeof(buffer) ); - if (txt) { + if (txtlen > 0 && txtlen < sizeof(buffer) ) { NONCLIENTMETRICS nclm; HFONT hFont, hOldFont; nclm.cbSize = sizeof(NONCLIENTMETRICS); @@ -1261,9 +1264,10 @@ void NC_DrawCaption95( if ( wndPtr->class->bUnicode ) DrawTextW( hdc, buffer, -1, &r, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT ); - else + else { DrawTextA( hdc, buffer, -1, &r, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT ); + } DeleteObject(SelectObject (hdc, hOldFont)); } } @@ -1291,7 +1295,7 @@ void NC_DoNCPaint( WND* wndPtr, HRGN clip, WINBOOL suppress_menupaint ) if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return; - if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left, + if (ExcludeClipRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left, wndPtr->rectClient.top-wndPtr->rectWindow.top, wndPtr->rectClient.right-wndPtr->rectWindow.left, wndPtr->rectClient.bottom-wndPtr->rectWindow.top ) @@ -1305,15 +1309,16 @@ void NC_DoNCPaint( WND* wndPtr, HRGN clip, WINBOOL suppress_menupaint ) rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; + SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) ); - if (!(wndPtr->flags & WIN_MANAGED)) +// if (!(wndPtr->flags & WIN_MANAGED)) { if ((wndPtr->dwStyle & WS_BORDER) || (wndPtr->dwStyle & WS_DLGFRAME) || (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)) { SelectObject( hdc, GetStockObject(NULL_BRUSH) ); - Rectangle( hdc, 0, 0, rect.right, rect.bottom ); + Rectangle( hdc, rect.top, rect.left, rect.right, rect.bottom ); InflateRect( &rect, -1, -1 ); } @@ -1404,7 +1409,7 @@ void NC_DoNCPaint95( if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return; - if (ExcludeVisRect( hdc, wndPtr->rectClient.left -wndPtr->rectWindow.left, + if (ExcludeClipRect( hdc, wndPtr->rectClient.left -wndPtr->rectWindow.left, wndPtr->rectClient.top -wndPtr->rectWindow.top, wndPtr->rectClient.right -wndPtr->rectWindow.left, wndPtr->rectClient.bottom -wndPtr->rectWindow.top ) @@ -1414,13 +1419,20 @@ void NC_DoNCPaint95( return; } + + rect.top = rect.left = 0; rect.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; rect.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; + //rect = wndPtr->rectWindow; + + printf("::%d %d\n", rect.right, rect.bottom); + + SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) ); - if(!(wndPtr->flags & WIN_MANAGED)) { + //if((wndPtr->flags & WIN_MANAGED)) { if ((wndPtr->dwStyle & WS_BORDER) && ((wndPtr->dwStyle & WS_DLGFRAME) || (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) || (wndPtr->dwStyle & WS_THICKFRAME))) { DrawEdge(hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST); @@ -1445,7 +1457,7 @@ void NC_DoNCPaint95( NC_DrawCaption95 (hdc, &r, hwnd, wndPtr->dwStyle, wndPtr->dwExStyle, active); } - } + //} if (HAS_MENU(wndPtr)) { @@ -1499,7 +1511,7 @@ LONG NC_HandleNCPaint( HWND hwnd , HRGN clip) { WND* wndPtr = WIN_FindWndPtr( hwnd ); - if( wndPtr && wndPtr->dwStyle & WS_VISIBLE ) + //if( wndPtr && wndPtr->dwStyle & WS_VISIBLE ) { if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_RedrawIconTitle( hwnd ); @@ -1733,8 +1745,9 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam ) capturePoint = pt = *(POINT*)&dwPoint; - if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || - (wndPtr->flags & WIN_MANAGED)) return; +// || (wndPtr->flags & WIN_MANAGED) + if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) ) + return; if ((wParam & 0xfff0) == SC_MOVE) { @@ -1910,11 +1923,11 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam ) if (HOOK_IsHooked( WH_CBT )) { if ( wndPtr->class->bUnicode == FALSE ) { - if( HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd,(LPARAM)&sizingRect) ) + if( HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE,(WPARAM) hwnd,(LPARAM)&sizingRect) ) sizingRect = wndPtr->rectWindow; } else { - if( HOOK_CallHooksW( WH_CBT, HCBT_MOVESIZE, hwnd,(LPARAM)&sizingRect) ) + if( HOOK_CallHooksW( WH_CBT, HCBT_MOVESIZE, (WPARAM) hwnd,(LPARAM)&sizingRect) ) sizingRect = wndPtr->rectWindow; } } diff --git a/reactos/lib/user32/internal/paint.c b/reactos/lib/user32/internal/paint.c index 2cb97fbdb68..7ddc03d1d30 100644 --- a/reactos/lib/user32/internal/paint.c +++ b/reactos/lib/user32/internal/paint.c @@ -56,6 +56,8 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate, GetClientRect( hwnd, &rectClient ); + OffsetRect(&rectClient,5,16); + if (flags & RDW_INVALIDATE) /* Invalidate */ { int rgnNotEmpty = COMPLEXREGION; @@ -160,7 +162,8 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate, if (wndPtr->hrgnUpdate) /* wm_painticon wparam is 1 */ SendMessageA( hwnd, (bIcon) ? WM_PAINTICON : WM_PAINT, bIcon, 0 ); } - else if (flags & RDW_ERASENOW) + else +//if (flags & RDW_ERASENOW) { //if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, FALSE); @@ -243,6 +246,8 @@ WINBOOL PAINT_RedrawWindow( HWND hwnd, const RECT *rectUpdate, return TRUE; } + + /*********************************************************************** * GetControlBrush Not A Win32 API */ diff --git a/reactos/lib/user32/internal/property.c b/reactos/lib/user32/internal/property.c index 84744fe122d..179eaa69d19 100644 --- a/reactos/lib/user32/internal/property.c +++ b/reactos/lib/user32/internal/property.c @@ -97,7 +97,7 @@ void PROPERTY_RemoveWindowProps( HANDLE hwnd ) if (!pWnd) - return (HANDLE)0; + return; @@ -115,8 +115,7 @@ WINBOOL PROPERTY_EnumPropEx(HWND hwnd, PROPVALUE **pv , int maxsize, int *size ) { PROPERTY *prop, *next; WND *pWnd; - INT ret = -1; - int i; + int i = 0; if (!(pWnd = WIN_FindWndPtr( hwnd ))) return FALSE; diff --git a/reactos/lib/user32/internal/region.c b/reactos/lib/user32/internal/region.c index f323b16990e..fc16830c96b 100644 --- a/reactos/lib/user32/internal/region.c +++ b/reactos/lib/user32/internal/region.c @@ -1,37 +1,4 @@ #include -INT SelectVisRgn(HDC hdc,HRGN hrgn) -{ - return SelectClipRgn(hdc,hrgn); -} - -INT RestoreVisRgn(HDC hdc) -{ - return SelectClipRgn(hdc,NULL); -} - -INT ExcludeVisRect(HDC hDC,INT nLeftRect,INT nTopRect,INT nRightRect,INT nBottomRect) -{ - return ExcludeClipRect(hDC, nLeftRect, nTopRect,nRightRect,nBottomRect ); -} -HRGN InquireVisRgn(HDC hdc) -{ - return hdc; -} -HRGN SaveVisRgn(HDC hdc) -{ - return NULL; -} - -/*********************************************************************** - * REGION_UnionRectWithRgn - * Adds a rectangle to a HRGN32 - * A helper used by scroll.c - */ -WINBOOL REGION_UnionRectWithRgn( HRGN hrgn, const RECT *lpRect ) -{ - - return TRUE; -} \ No newline at end of file diff --git a/reactos/lib/user32/internal/win.c b/reactos/lib/user32/internal/win.c index 191ef9d079e..2034df7623f 100644 --- a/reactos/lib/user32/internal/win.c +++ b/reactos/lib/user32/internal/win.c @@ -64,6 +64,12 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) wndPtr->parent = WIN_FindWndPtr( cs->hWndParent ); wndPtr->owner = NULL; } + else { + wndPtr->owner = NULL; + wndPtr->parent = NULL; + } + +/* else { wndPtr->parent = pWndDesktop; @@ -72,7 +78,7 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) else wndPtr->owner = WIN_GetTopParentPtr(WIN_FindWndPtr(cs->hWndParent)); } - + */ wndPtr->winproc = classPtr->winproc; wndPtr->dwMagic = WND_MAGIC; @@ -134,14 +140,8 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) - /* Get class or window DC if needed */ - - if (classPtr->style & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hWnd,DCE_WINDOW_DC); - else if (classPtr->style & CS_CLASSDC) wndPtr->dce = classPtr->dce; - else wndPtr->dce = DCE_AllocDCE(hWnd,DCE_WINDOW_DC);; - GetStartupInfoW((STARTUPINFO *)&StartupInfo); if (cs->x == CW_USEDEFAULT) { @@ -168,25 +168,31 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) } else { - cs->cx = 600; /* FIXME */ - cs->cy = 400; + cs->cx = SYSMETRICS_CXSCREEN; + cs->cy = SYSMETRICS_CYSCREEN; } } - /* Send the WM_GETMINMAXINFO message and fix the size if needed */ + /* Send the WM_GETMINMAXINFO message and fix the size if needed and appropriate */ + + if ( !(cs->style & (WS_POPUP | WS_CHILD) )) { + + if ((cs->style & WS_THICKFRAME) ) + { + + WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack); + if (maxSize.x < cs->cx) cs->cx = maxSize.x; + if (maxSize.y < cs->cy) cs->cy = maxSize.y; + if (cs->cx < minTrack.x ) cs->cx = minTrack.x; + if (cs->cy < minTrack.y ) cs->cy = minTrack.y; + + } + - if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) - { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack); - if (maxSize.x < cs->cx) cs->cx = maxSize.x; - if (maxSize.y < cs->cy) cs->cy = maxSize.y; - if (cs->cx < minTrack.x ) cs->cx = minTrack.x; - if (cs->cy < minTrack.y ) cs->cy = minTrack.y; } - if(cs->style & WS_CHILD) { if(cs->cx < 0) cs->cx = 0; @@ -203,8 +209,26 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) wndPtr->rectWindow.right = cs->x + cs->cx; wndPtr->rectWindow.bottom = cs->y + cs->cy; + wndPtr->rectClient= wndPtr->rectWindow; - wndPtr->rectClient = wndPtr->rectWindow; + + printf(":%d %d %d %d\n", wndPtr->rectWindow.left, wndPtr->rectWindow.top, + wndPtr->rectWindow.right, wndPtr->rectWindow.bottom); + + /* Get class or window DC if needed */ + + if (classPtr->style & CS_OWNDC) + wndPtr->dce = DCE_AllocDCE(wndPtr,DCE_WINDOW_DC); + else if (classPtr->style & CS_CLASSDC) + wndPtr->dce = classPtr->dce; + else if ( classPtr->style & CS_PARENTDC) + wndPtr->dce = wndPtr->parent->dce; + else wndPtr->dce = DCE_AllocDCE(wndPtr,DCE_WINDOW_DC);; + + + //wndPtr->rectClient.top = wndPtr->rectClient.left = 0; + //wndPtr->rectClient.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; + //wndPtr->rectClient.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; /* Set the window menu */ @@ -307,7 +331,6 @@ HANDLE WIN_CreateWindowEx( CREATESTRUCTW *cs, ATOM classAtom) if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner) HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWCREATED, (INT)hWnd, 0L, classPtr->bUnicode); - return hWnd; @@ -928,6 +951,19 @@ WINBOOL STDCALL WIN_IsDialogMessage( HWND hwndDlg, LPMSG msg ) } +WINBOOL WIN_GetClientRect(WND *wndPtr, LPRECT lpRect ) +{ + if ( lpRect == NULL ) + return FALSE; + lpRect->left = lpRect->top = lpRect->right = lpRect->bottom = 0; + if (wndPtr) + { + lpRect->right = wndPtr->rectClient.right - wndPtr->rectClient.left; + lpRect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top; + } + return TRUE; +} + /******************************************************************* * GetSysModalWindow16 (USER.52) diff --git a/reactos/lib/user32/makefile.main b/reactos/lib/user32/makefile.main index 3f0c10f2467..a6bd93c2b59 100644 --- a/reactos/lib/user32/makefile.main +++ b/reactos/lib/user32/makefile.main @@ -4,7 +4,7 @@ INTERNAL_OBJECTS = internal/property.o internal/menu.o internal/heapdup.o intern internal/win.o internal/dce.o internal/msg.o internal/queue.o\ internal/signal.o internal/event.o internal/timer.o internal/region.o\ internal/text.o internal/defwnd.o internal/paint.o internal/uitools.o\ - internal/dialog.o + internal/dialog.o internal/winpos.o MISC_OBJECTS = misc/sprintf.o misc/dllmain.o misc/string.o misc/sysmetr.o\ misc/main.o misc/bitmap.o misc/cursor.o misc/vk.o diff --git a/reactos/lib/user32/makefile_rex b/reactos/lib/user32/makefile_rex index 8ffebdc5fc8..b702730c588 100644 --- a/reactos/lib/user32/makefile_rex +++ b/reactos/lib/user32/makefile_rex @@ -1,4 +1,4 @@ -# $Id: makefile_rex,v 1.7 1999/08/29 13:44:58 dwelch Exp $ +# $Id: makefile_rex,v 1.8 1999/12/01 22:30:45 ariadne Exp $ # # ReactOS Operating System # @@ -23,11 +23,11 @@ endif all: $(DLLTARGET) -MISC_OBJECTS = misc/sprintf.o misc/exitwin.o misc/dllmain.o #misc/string.o +MISC_OBJECTS = misc/sprintf.o misc/exitwin.o misc/dllmain.o misc/string.o misc/sysmetr.o #RESOURCE_OBJECT = $(TARGET).coff -WINDOWS_OBJECTS = windows/message.o windows/wndproc.o windows/win.o windows/hook.o windows/spy.o\ +WINDOWS_OBJECTS = windows/msg.o windows/wndproc.o windows/win.o windows/hook.o windows/spy.o\ #windows/queue.o OBJECTS = $(MISC_OBJECTS) $(WINDOWS_OBJECTS) diff --git a/reactos/lib/user32/misc/bitmap.c b/reactos/lib/user32/misc/bitmap.c index 1473443334d..39047f605a2 100644 --- a/reactos/lib/user32/misc/bitmap.c +++ b/reactos/lib/user32/misc/bitmap.c @@ -2,12 +2,18 @@ HBITMAP BITMAP_LoadBitmapW(HINSTANCE instance,LPCWSTR name, UINT loadflags); -HBITMAP LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName) + + +HBITMAP +STDCALL +LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName) { return BITMAP_LoadBitmapW(hInstance, lpBitmapName, 0); } -HBITMAP LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName) +HBITMAP +STDCALL +LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName) { return CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), diff --git a/reactos/lib/user32/misc/main.c b/reactos/lib/user32/misc/main.c index 50b6bc00bc3..e43a864a308 100644 --- a/reactos/lib/user32/misc/main.c +++ b/reactos/lib/user32/misc/main.c @@ -22,8 +22,8 @@ int i; int main(int argc, char **argv) { - WIDGETS_Init(); -#if 0 + + HWND hwnd; HWND User32hWnd; HMENU hmenu; @@ -37,6 +37,8 @@ int main(int argc, char **argv) HANDLE hMod, hrsrc; RECT rect, cl; + WIDGETS_Init(); + wc1.hInstance = hInst; wc1.lpszClassName = szName; wc1.lpfnWndProc = WindowFunc; @@ -59,24 +61,26 @@ int main(int argc, char **argv) hwnd = CreateWindowEx (0, szName, "test2", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, + CW_USEDEFAULT,CW_USEDEFAULT,100,100, NULL,NULL,hInst, NULL); - MessageBox(NULL,"Hallo","Hallo",MB_OK); + ShowWindow(hwnd,nWinMode); UpdateWindow(hwnd); -#endif - MessageBox(NULL,"xxx","yyyy",MB_OK); -#if 0 + + + + MessageBox(hwnd,"xxx","yyyy",MB_OK); + GetWindowRect(hwnd,&rect); GetClientRect(hwnd,&cl); printf("%d\n",(rect.left - rect.right) - (cl.left - cl.right)); SetWindowText(hwnd,"Hallo3"); - DrawMenuBar(hwnd); +// DrawMenuBar(hwnd); // SendMessage( hwnd, WM_MOVE, 0,MAKELONG(0,0)); // SendMessage( hwnd, WM_PAINT, GetWindowDC(hwnd),0); while(GetMessage(&msg,NULL, 0, 0)) @@ -86,7 +90,7 @@ int main(int argc, char **argv) } Sleep(10000); return msg.wParam; -#endif + } diff --git a/reactos/lib/user32/misc/string.c b/reactos/lib/user32/misc/string.c index f38e6a0ff87..4110db78901 100644 --- a/reactos/lib/user32/misc/string.c +++ b/reactos/lib/user32/misc/string.c @@ -5,11 +5,12 @@ * Copyright 1996 Marcus Meissner */ +#include #include #include #include #include -#include + /* Funny to divide them between user and kernel. */ diff --git a/reactos/lib/user32/misc/vk.c b/reactos/lib/user32/misc/vk.c index e13d833f5d3..008912d98a4 100644 --- a/reactos/lib/user32/misc/vk.c +++ b/reactos/lib/user32/misc/vk.c @@ -1,10 +1,56 @@ #include -SHORT GetKeyState( int nVirtKey ) +SHORT +STDCALL +GetKeyState( int nVirtKey ) { return 0; } +UINT +STDCALL +GetKBCodePage( + VOID) +{ + return 0; +} + +SHORT +STDCALL +GetAsyncKeyState( + int vKey) +{ + return 0; +} + + +WINBOOL +STDCALL +GetKeyboardState( + PBYTE lpKeyState) +{ + return FALSE; +} + + +WINBOOL +STDCALL +SetKeyboardState( + LPBYTE lpKeyState) +{ + return FALSE; +} + + +int +STDCALL +GetKeyboardType( + int nTypeFlag) +{ + return 0; +} + + int STDCALL ToAscii( diff --git a/reactos/lib/user32/user32.rc b/reactos/lib/user32/user32.rc index d31d64f0faf..f7d34665e7a 100644 --- a/reactos/lib/user32/user32.rc +++ b/reactos/lib/user32/user32.rc @@ -4,7 +4,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,13,RES_UINT_FILE_VERSION + FILEVERSION 0,0,13,0 PRODUCTVERSION 0,0,13,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG @@ -27,7 +27,7 @@ BEGIN VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT VALUE "OriginalFilename", "user32.dll\0" VALUE "ProductName", RES_STR_PRODUCT_NAME - VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + END END BLOCK "VarFileInfo" @@ -47,12 +47,12 @@ STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | FONT 8, "MS Sans Serif" BEGIN ICON "", 1088, 9, 20, 16, 16, WS_CHILD | WS_VISIBLE - LTEXT "", 100, 32, 4, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP + LTEXT "", 100, 48, 16, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP PUSHBUTTON "&OK", 1, 16, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "&Cancel", 2, 64, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "&Abort", 3, 112, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "&Retry", 4, 160, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "&Ignore", 5, 208, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP - PUSHBUTTON "&Yes", 6, 256, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "&Yes", 6, 206, 26, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "&No", 7, 304, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP END \ No newline at end of file diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c index c0fc57990fc..de2af13af10 100644 --- a/reactos/lib/user32/windows/class.c +++ b/reactos/lib/user32/windows/class.c @@ -217,7 +217,7 @@ ATOM STDCALL RegisterClassExW( const WNDCLASSEX* wc ) return atom; } -WINBOOL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance ) +WINBOOL STDCALL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance ) { CLASS *classPtr; classPtr = CLASS_FindClassByAtom( STRING2ATOMA(lpClassName), hInstance ); @@ -233,7 +233,7 @@ WINBOOL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance ) -WINBOOL UnregisterClassW(LPCWSTR lpClassName, HINSTANCE hInstance ) +WINBOOL STDCALL UnregisterClassW(LPCWSTR lpClassName, HINSTANCE hInstance ) { CLASS *classPtr; classPtr = CLASS_FindClassByAtom( STRING2ATOMW(lpClassName), hInstance ); @@ -247,14 +247,35 @@ WINBOOL UnregisterClassW(LPCWSTR lpClassName, HINSTANCE hInstance ) } -WINBOOL GetClassInfoA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASS lpWndClass ) +WINBOOL STDCALL GetClassInfoA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASS lpWndClass ) { - return FALSE; + CLASS *classPtr; + ATOM a; + + if ( HIWORD(lpClassName) != 0 ) + a = FindAtomA(lpClassName); + else + a = lpClassName; + + classPtr = CLASS_FindClassByAtom( a, hInstance ); + if ( classPtr == NULL ) + return FALSE; + + + lpWndClass->style = classPtr->style; + lpWndClass->lpfnWndProc = classPtr->winproc; + lpWndClass->cbClsExtra = classPtr->cbWndExtra; + lpWndClass->cbClsExtra = classPtr->cbClsExtra; + lpWndClass->hInstance = classPtr->hInstance; + lpWndClass->hIcon = classPtr->hIcon; + lpWndClass->hCursor = classPtr->hCursor; + lpWndClass->hbrBackground = classPtr->hbrBackground; + return TRUE; } -WINBOOL GetClassInfoW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASS lpWndClass ) +WINBOOL STDCALL GetClassInfoW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASS lpWndClass ) { CLASS *classPtr; ATOM a; @@ -281,13 +302,40 @@ WINBOOL GetClassInfoW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASS l } -WINBOOL GetClassInfoExA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASSEX lpWndClass ) +WINBOOL STDCALL GetClassInfoExA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASSEX lpWndClassEx ) { - return FALSE; + CLASS *classPtr; + ATOM a; + + if ( HIWORD(lpClassName) != 0 ) + a = FindAtomA(lpClassName); + else + a = (ATOM)lpClassName; + + classPtr = CLASS_FindClassByAtom( a, hInstance ); + if ( classPtr == NULL ) + return FALSE; + + + if ( lpWndClassEx ->cbSize != sizeof(WNDCLASSEX) ) + return FALSE; + + + lpWndClassEx->style = classPtr->style; + lpWndClassEx->lpfnWndProc = classPtr->winproc; + lpWndClassEx->cbClsExtra = classPtr->cbWndExtra; + lpWndClassEx->cbClsExtra = classPtr->cbClsExtra; + lpWndClassEx->hInstance = classPtr->hInstance; + lpWndClassEx->hIcon = classPtr->hIcon; + lpWndClassEx->hCursor = classPtr->hCursor; + lpWndClassEx->hbrBackground = classPtr->hbrBackground; + + + return TRUE; } -WINBOOL GetClassInfoExW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASSEX lpWndClassEx ) +WINBOOL STDCALL GetClassInfoExW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASSEX lpWndClassEx ) { CLASS *classPtr; @@ -320,7 +368,7 @@ WINBOOL GetClassInfoExW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASSE return TRUE; } -int GetClassNameA(HWND hWnd, LPSTR lpClassName, int nMaxCount ) +int STDCALL GetClassNameA(HWND hWnd, LPSTR lpClassName, int nMaxCount ) { WND *wndPtr = WIN_FindWndPtr(hWnd); @@ -334,7 +382,7 @@ int GetClassNameA(HWND hWnd, LPSTR lpClassName, int nMaxCount ) } -int GetClassNameW(HWND hWnd, LPWSTR lpClassName, int nMaxCount ) +int STDCALL GetClassNameW(HWND hWnd, LPWSTR lpClassName, int nMaxCount ) { WND *wndPtr = WIN_FindWndPtr(hWnd); @@ -349,7 +397,7 @@ int GetClassNameW(HWND hWnd, LPWSTR lpClassName, int nMaxCount ) } -DWORD GetClassLongA(HWND hWnd, int nIndex ) +DWORD STDCALL GetClassLongA(HWND hWnd, int nIndex ) { WND * wndPtr; @@ -380,7 +428,7 @@ DWORD GetClassLongA(HWND hWnd, int nIndex ) return 0; } -DWORD GetClassLongW(HWND hWnd, int nIndex ) +DWORD STDCALL GetClassLongW(HWND hWnd, int nIndex ) { WND * wndPtr; diff --git a/reactos/lib/user32/windows/dc.c b/reactos/lib/user32/windows/dc.c index ffea62b3d87..35c337aa561 100644 --- a/reactos/lib/user32/windows/dc.c +++ b/reactos/lib/user32/windows/dc.c @@ -32,9 +32,6 @@ extern DCE *firstDCE; -INT SelectVisRgn(HDC hdc,HRGN hrgn); -INT ExcludeVisRect(HDC hDC,INT nLeftRect,INT nTopRect,INT nRightRect,INT nBottomRect); -INT RestoreVisRgn(HDC hdc); HDC STDCALL GetDC( HWND hWnd ) @@ -56,7 +53,7 @@ HDC STDCALL GetDC( HWND hWnd ) */ -HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) +HDC STDCALL GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) { HRGN hrgnVisible = 0; HDC hdc = 0; @@ -74,40 +71,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) /* fixup flags */ -#if 0 - if (!(wndPtr->class->style & (CS_OWNDC | CS_CLASSDC))) - flags |= DCX_CACHE; - - if (flags & DCX_USESTYLE) - { - flags &= ~( DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP); - - if( wndPtr->dwStyle & WS_CLIPSIBLINGS ) - flags |= DCX_CLIPSIBLINGS; - - if ( !(flags & DCX_WINDOW) ) - { - if (wndPtr->class->style & CS_PARENTDC) flags |= DCX_PARENTCLIP; - - if (wndPtr->dwStyle & WS_CLIPCHILDREN && - !(wndPtr->dwStyle & WS_MINIMIZE) ) flags |= DCX_CLIPCHILDREN; - } - else flags |= DCX_CACHE; - } - - - if( flags & DCX_NOCLIPCHILDREN ) - { - flags |= DCX_CACHE; - flags &= ~(DCX_PARENTCLIP | DCX_CLIPCHILDREN); - } - - - if (flags & DCX_WINDOW) - flags = (flags & ~DCX_CLIPCHILDREN) | DCX_CACHE; - -#endif if (!(wndPtr->dwStyle & WS_CHILD) || !wndPtr->parent ) flags &= ~DCX_PARENTCLIP; @@ -128,88 +92,18 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) dcxFlags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_CACHE | DCX_WINDOW); -#if 0 - if (flags & DCX_CACHE) - { - DCE* dceEmpty; - DCE* dceUnused; - dceEmpty = dceUnused = NULL; - - /* Strategy: First, we attempt to find a non-empty but unused DCE with - * compatible flags. Next, we look for an empty entry. If the cache is - * full we have to purge one of the unused entries. - */ - - for (dce = firstDCE; (dce); dce = dce->next) - { - if ((dce->DCXflags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE ) - { - dceUnused = dce; - - if (dce->DCXflags & DCX_DCEEMPTY) - dceEmpty = dce; - else - if ((dce->hwndCurrent == hwnd) - && ((dce->DCXflags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | - DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)) == dcxFlags)) - { - DPRINT("\tfound valid %08x dce [%04x], flags %08x\n", - (unsigned)dce, hwnd, (unsigned)dcxFlags ); - bUpdateVisRgn = FALSE; - bUpdateClipOrigin = TRUE; - break; - } - } - } - if (!dce) dce = (dceEmpty) ? dceEmpty : dceUnused; - } - else - { - if (wndPtr->class->style & CS_OWNDC) - dce = wndPtr->dce; - else if ( wndPtr->class->style & CS_CLASSDC) - dce = wndPtr->class->dce; - else - return 0; - - if( dce->hwndCurrent == hwnd ) - { - DPRINT("\tskipping hVisRgn update\n"); - bUpdateVisRgn = FALSE; /* updated automatically, via DCHook() */ - - if( (dce->DCXflags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && - (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) ) - { - /* This is likely to be a nested BeginPaint(). */ - - if( dce->hClipRgn != hrgnClip ) - { - DPRINT("fixme new hrgnClip[%04x] smashes the previous[%04x]\n", - hrgnClip, dce->hClipRgn ); - DCE_DeleteClipRgn( dce ); - } - else - RestoreVisRgn(dce->hDC); - } - } - } - if (!dce) return 0; - -#endif dce = wndPtr->dce; dce->hwndCurrent = hwnd; dce->hClipRgn = 0; dce->DCXflags = dcxFlags | (flags & DCX_WINDOWPAINT) | DCX_DCEBUSY; hdc = dce->hDC; - - //if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; - //bUpdateVisRgn = bUpdateVisRgn || (dc->w.flags & DC_DIRTY); + /* recompute visible region */ - //wndPtr->pDriver->pSetDrawable( wndPtr, dc, flags, bUpdateClipOrigin ); + if( bUpdateVisRgn ) { DPRINT("updating visrgn for %08x dce, hwnd [%04x]\n", (unsigned)dce, hwnd); @@ -241,7 +135,6 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) if ((hwnd == GetDesktopWindow())) { hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN ); -// (rootWindow == DefaultRootWindow(display)) } else { @@ -251,7 +144,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) //dc->w.flags &= ~DC_DIRTY; dce->DCXflags &= ~DCX_DCEDIRTY; - SelectVisRgn( hdc, hrgnVisible ); + SelectClipRgn( hdc, hrgnVisible ); } else DPRINT("no visrgn update %08x dce, hwnd [%04x]\n", (unsigned)dce, hwnd); @@ -260,19 +153,19 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) if( flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ) { - if( !hrgnVisible ) hrgnVisible = CreateRectRgn( 0, 0, 0, 0 ); + if( !hrgnVisible ) + hrgnVisible = CreateRectRgn( 0, 0, 0, 0 ); dce->DCXflags |= flags & (DCX_KEEPCLIPRGN | DCX_INTERSECTRGN | DCX_EXCLUDERGN); dce->hClipRgn = hrgnClip; DPRINT( "\tsaved VisRgn, clipRgn = %04x\n", hrgnClip); - SaveVisRgn( hdc ); + CombineRgn( hrgnVisible, hrgnClip, 0, RGN_COPY ); DCE_OffsetVisRgn( hdc, hrgnVisible ); - CombineRgn( hrgnVisible, InquireVisRgn( hdc ), hrgnVisible, - (flags & DCX_INTERSECTRGN) ? RGN_AND : RGN_DIFF ); - SelectVisRgn( hdc, hrgnVisible ); + + SelectClipRgn( hdc, hrgnVisible ); } if( hrgnVisible ) DeleteObject( hrgnVisible ); @@ -287,7 +180,7 @@ int STDCALL ReleaseDC(HWND hWnd,HDC hDC ) return 0; } -HDC GetWindowDC(HWND hWnd ) +HDC STDCALL GetWindowDC(HWND hWnd ) { if (!hWnd) hWnd = GetDesktopWindow(); return GetDCEx( hWnd, 0, DCX_USESTYLE | DCX_WINDOW ); diff --git a/reactos/lib/user32/windows/defdlg.c b/reactos/lib/user32/windows/defdlg.c index 46cbfe896fb..4ec8a1ae91c 100644 --- a/reactos/lib/user32/windows/defdlg.c +++ b/reactos/lib/user32/windows/defdlg.c @@ -9,6 +9,7 @@ #include #include #include +#include diff --git a/reactos/lib/user32/windows/hook.c b/reactos/lib/user32/windows/hook.c index 7e2266611fe..c52d730aee5 100644 --- a/reactos/lib/user32/windows/hook.c +++ b/reactos/lib/user32/windows/hook.c @@ -19,7 +19,7 @@ HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { NULL, }; * * FIXME: I don't know if this is correct */ -HHOOK SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) +HHOOK STDCALL SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) { return HOOK_SetHook( idHook, lpfn, HOOK_WINA, hMod, dwThreadId ); @@ -31,9 +31,9 @@ HHOOK SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwT * * FIXME: I don't know if this is correct */ -HHOOK SetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) +HHOOK STDCALL SetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) { - return HOOK_SetHook( idHook, lpfn, HOOK_WIN32W, hMod, dwThreadId ); + return HOOK_SetHook( idHook, lpfn, HOOK_WINW, hMod, dwThreadId ); } @@ -224,7 +224,7 @@ HANDLE HOOK_SetHook( INT id, LPVOID proc, INT type, WINBOOL HOOK_RemoveHook( HANDLE hook ) { HOOKDATA *data; - HANDLE *prevHook; + HANDLE *prevHook = NULL; diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c deleted file mode 100644 index 28185ccec36..00000000000 --- a/reactos/lib/user32/windows/message.c +++ /dev/null @@ -1,138 +0,0 @@ -#include -#include -#include -#include -#include -#include - - -/*********************************************************************** - * SendMessage Send Window Message - * - * Sends a message to the window procedure of the specified window. - * SendMessage() will not return until the called window procedure - * either returns or calls ReplyMessage(). - * - * Use PostMessage() to send message and return immediately. A window - * procedure may use InSendMessage() to detect - * SendMessage()-originated messages. - * - * Applications which communicate via HWND_BROADCAST may use - * RegisterWindowMessage() to obtain a unique message to avoid conflicts - * with other applications. - * - * CONFORMANCE - * - * ECMA-234, Win - */ - - -#if 0 -LRESULT STDCALL SendMessageA( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - return MSG_SendMessage( hwnd, msg, wParam, lParam, FALSE ); -} - - - -LRESULT STDCALL SendMessageW( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - return MSG_SendMessage( hwnd, msg, wParam, lParam, TRUE ); -} -#endif - - -/*********************************************************************** - * MSG_SendMessage - * - * Implementation of an inter-task SendMessage. - */ -LRESULT MSG_SendMessage( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, WINBOOL bUnicode ) -{ - WND * wndPtr; - LRESULT ret; - MSG msg; - - -// SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam ); -#if 0 - WND **list, **ppWnd; - if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST) - { - if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) - return TRUE; - for (ppWnd = list; *ppWnd; ppWnd++) - { - wndPtr = *ppWnd; - if (!WIN_IsWindow(wndPtr->hwndSelf)) - continue; - if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) - MSG_SendMessage( wndPtr->hwndSelf, message, wParam, lParam, bUnicode ); - } - WIN_DestroyList( list ); - return TRUE; - } -#endif - - if (HOOK_IsHooked( WH_CALLWNDPROC )) - MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE); - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) - { - return 0; - } - - - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wParam; - msg.lParam = lParam; - msg.time = 0; - msg.pt.x = 0; - msg.pt.y = 0; - - - // SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, ret ); - return ret; -} - - - -/************************************************************************ - * MSG_CallWndProcHook - */ -void MSG_CallWndProcHook( LPMSG pmsg, WINBOOL bUnicode ) -{ - CWPSTRUCT cwp; - - cwp.lParam = pmsg->lParam; - cwp.wParam = pmsg->wParam; - cwp.message = pmsg->message; - cwp.hwnd = pmsg->hwnd; - - if (bUnicode) - HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); - else - HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp ); - - pmsg->lParam = cwp.lParam; - pmsg->wParam = cwp.wParam; - pmsg->message = cwp.message; - pmsg->hwnd = cwp.hwnd; -} - - -/*********************************************************************** - * MSG_InternalGetMessage - * - * GetMessage() function for internal use. Behave like GetMessage(), - * but also call message filters and optionally send WM_ENTERIDLE messages. - * 'hwnd' must be the handle of the dialog or menu window. - * 'code' is the message filter value (MSGF_??? codes). - */ -WINBOOL MSG_InternalGetMessage( MSG *msg, HWND hwnd, HWND hwndOwner, - WPARAM code, WORD flags, WINBOOL sendIdle ) -{ -} \ No newline at end of file diff --git a/reactos/lib/user32/windows/scroll.c b/reactos/lib/user32/windows/scroll.c index 62f2366ccd0..1ff13bae374 100644 --- a/reactos/lib/user32/windows/scroll.c +++ b/reactos/lib/user32/windows/scroll.c @@ -109,14 +109,20 @@ WINBOOL STDCALL ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc, const RECT *prLClip, HRGN hrgnUpdate, LPRECT rcUpdate ) { -#if 0 + + RECT rClip; POINT src, dest; INT ldx, ldy; - + SIZE vportExt; + SIZE wndExt; + POINT DCOrg; if (!hdc ) return FALSE; - + + GetViewportExtEx( hdc,&vportExt); + GetWindowExtEx(hdc, &wndExt); + GetDCOrgEx(hdc,&DCOrg); /* compute device clipping region */ @@ -133,15 +139,16 @@ WINBOOL STDCALL ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc, return FALSE; } - SaveVisRgn( hdc ); - IntersectVisRect( hdc, rClip.left, rClip.top, - rClip.right, rClip.bottom ); + + /// IntersectVisRect( hdc, rClip.left, rClip.top, + // rClip.right, rClip.bottom ); /* translate coordinates */ - ldx = dx * dc->wndExtX / dc->vportExtX; - ldy = dy * dc->wndExtY / dc->vportExtY; + + ldx = dx * wndExt.cx / vportExt.cx; + ldy = dy * wndExt.cy / vportExt.cy; if (dx > 0) dest.x = (src.x = rClip.left) + ldx; @@ -170,32 +177,33 @@ WINBOOL STDCALL ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc, /* restore clipping region */ - RestoreVisRgn( hdc ); + SelectClipRgn( hdc,NULL ); /* compute update areas */ - if ( (hrgnUpdate || rcUpdate) && dc->w.hVisRgn ) + //&& dc->w.hVisRgn + if ( (hrgnUpdate || rcUpdate) ) { HRGN hrgn = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 ); HRGN hrgnClip; - LPtoDP( hdc, (LPPOINT)&rClip, 2 ); - OffsetRect( &rClip, dc->w.DCOrgX, dc->w.DCOrgY ); + //LPtoDP( hdc, (LPPOINT)&rClip, 2 ); + OffsetRect( &rClip, DCOrg.x, DCOrg.y ); hrgnClip = CreateRectRgnIndirect( &rClip ); - CombineRgn( hrgn, dc->w.hVisRgn, hrgnClip, RGN_AND ); + //CombineRgn( hrgn, dc->w.hVisRgn, hrgnClip, RGN_AND ); OffsetRgn( hrgn, dx, dy ); - CombineRgn( hrgn, dc->w.hVisRgn, hrgn, RGN_DIFF ); + //CombineRgn( hrgn, dc->w.hVisRgn, hrgn, RGN_DIFF ); CombineRgn( hrgn, hrgn, hrgnClip, RGN_AND ); - OffsetRgn( hrgn, -dc->w.DCOrgX, -dc->w.DCOrgY ); + OffsetRgn( hrgn, -DCOrg.x, -DCOrg.y ); if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate ); if (!hrgnUpdate) DeleteObject( hrgn ); DeleteObject( hrgnClip ); } -#endif + return TRUE; } diff --git a/reactos/lib/user32/windows/timer.c b/reactos/lib/user32/windows/timer.c index 1fefab29184..6d204d31ba7 100644 --- a/reactos/lib/user32/windows/timer.c +++ b/reactos/lib/user32/windows/timer.c @@ -1,6 +1,6 @@ #include -UINT SetTimer( HWND hWnd,UINT nIDEvent, +UINT STDCALL SetTimer( HWND hWnd,UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc ) { diff --git a/reactos/lib/user32/windows/win.c b/reactos/lib/user32/windows/win.c index feb1ffafa62..4614372df68 100644 --- a/reactos/lib/user32/windows/win.c +++ b/reactos/lib/user32/windows/win.c @@ -527,7 +527,7 @@ WINBOOL STDCALL IsChild( HWND parent, HWND child ) return FALSE; } -WINBOOL IsWindow(HANDLE hWnd) +WINBOOL STDCALL IsWindow(HANDLE hWnd) { if (WIN_FindWndPtr( hWnd ) == NULL) return FALSE; return TRUE; @@ -552,7 +552,6 @@ WINBOOL STDCALL IsWindowEnabled(HWND hWnd) WINBOOL STDCALL IsWindowUnicode( HWND hWnd ) { WND * wndPtr; -// What if handle is invalid ?? if (!(wndPtr = WIN_FindWndPtr(hWnd))) return FALSE; @@ -572,122 +571,7 @@ WINBOOL STDCALL IsWindowVisible( HWND hwnd ) } -/*********************************************************************** - * ShowWindow (USER32.534) - */ -WINBOOL STDCALL ShowWindow( HWND hwnd, INT cmd ) -{ - WND* wndPtr = WIN_FindWndPtr( hwnd ); - WINBOOL wasVisible = FALSE, showFlag; - RECT newPos = {0, 0, 0, 0}; - int swp = 0; - if (!wndPtr) return FALSE; - -// DPRINT("hwnd=%04x, cmd=%d\n", hwnd, cmd); -#ifdef OPTIMIZATION - - wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0; -#endif - - switch(cmd) - { - case SW_HIDE: - if (!wasVisible) return FALSE; - swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER; - break; - - case SW_SHOWMINNOACTIVE: - swp |= SWP_NOACTIVATE | SWP_NOZORDER; - /* fall through */ - case SW_SHOWMINIMIZED: - swp |= SWP_SHOWWINDOW; - /* fall through */ - case SW_MINIMIZE: - swp |= SWP_FRAMECHANGED; - if( !(wndPtr->dwStyle & WS_MINIMIZE) ) - swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos ); - else swp |= SWP_NOSIZE | SWP_NOMOVE; - break; - - case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */ - swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; - if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) - swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos ); - else swp |= SWP_NOSIZE | SWP_NOMOVE; - break; - - case SW_SHOWNA: - swp |= SWP_NOACTIVATE | SWP_NOZORDER; - /* fall through */ - case SW_SHOW: - swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; - break; - - case SW_SHOWNOACTIVATE: - swp |= SWP_NOZORDER; - if (GetActiveWindow()) swp |= SWP_NOACTIVATE; - /* fall through */ - case SW_SHOWNORMAL: /* same as SW_NORMAL: */ - case SW_SHOWDEFAULT: /* FIXME: should have its own handler */ - case SW_RESTORE: - swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; - - if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) ) - swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos ); - else swp |= SWP_NOSIZE | SWP_NOMOVE; - break; - } - - showFlag = (cmd != SW_HIDE); - if (showFlag != wasVisible) - { - SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 ); - if (!IsWindow( hwnd )) return wasVisible; - } - - if ((wndPtr->dwStyle & WS_CHILD) && - !IsWindowVisible( wndPtr->parent->hwndSelf ) && - (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) ) - { - /* Don't call SetWindowPos() on invisible child windows */ - if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE; - else wndPtr->dwStyle |= WS_VISIBLE; - } - else - { - /* We can't activate a child window */ - if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER; - SetWindowPos( hwnd, HWND_TOP, - newPos.left, newPos.top, newPos.right, newPos.bottom, swp ); - if (!IsWindow( hwnd )) return wasVisible; - else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE ); - } - - if (wndPtr->flags & WIN_NEED_SIZE) - { - /* should happen only in CreateWindowEx() */ - int wParam = SIZE_RESTORED; - - wndPtr->flags &= ~WIN_NEED_SIZE; - if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED; - else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED; - SendMessageW( hwnd, WM_SIZE, wParam, - MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left, - wndPtr->rectClient.bottom-wndPtr->rectClient.top)); - SendMessageW( hwnd, WM_MOVE, 0, - MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) ); - } - - - // SendMessage(hwnd, WM_NCACTIVATE,TRUE,0); - // SendMessage(hwnd, WM_NCPAINT,CreateRectRgn(100,100,100, 100) ,0); - - - - return wasVisible; -} /******************************************************************* diff --git a/reactos/lib/user32/windows/winpos.c b/reactos/lib/user32/windows/winpos.c index 453dbfcbd45..5c7add02d2e 100644 --- a/reactos/lib/user32/windows/winpos.c +++ b/reactos/lib/user32/windows/winpos.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -16,18 +17,9 @@ #include #include -HWND ICONTITLE_Create( WND *pWnd ); HWND GetSysModalWindow(void); -/* ----- internal variables ----- */ - -static HWND hwndActive = 0; /* Currently active window */ -static HWND hwndPrevActive = 0; /* Previously active window */ -//static HWND hGlobalShellWindow=0; /*the shell*/ - -static LPCSTR atomInternalPos; - extern MESSAGEQUEUE* pActiveQueue; @@ -159,11 +151,11 @@ WINBOOL STDCALL IsZoomed(HWND hWnd) HWND STDCALL GetActiveWindow(void) -{ - return hwndActive; +{ + return WINPOS_GetActiveWindow(); } -HWND SetActiveWindow(HWND hWnd ) +HWND STDCALL SetActiveWindow(HWND hWnd ) { HWND hPrev; hPrev = GetActiveWindow(); @@ -172,10 +164,129 @@ HWND SetActiveWindow(HWND hWnd ) return NULL; } -WINBOOL -STDCALL -SetWindowPos( - HWND hWnd, HWND hWndInsertAfter , + +/*********************************************************************** + * ShowWindow (USER32.534) + */ +WINBOOL STDCALL ShowWindow( HWND hwnd, INT cmd ) +{ + WND* wndPtr = WIN_FindWndPtr( hwnd ); + WINBOOL wasVisible = FALSE, showFlag; + RECT newPos = {0, 0, 100, 100}; + int swp = 0; + + if (!wndPtr) return FALSE; + +#ifdef OPTIMIZATION + + wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0; +#endif + + switch(cmd) + { + case SW_HIDE: + if (!wasVisible) return FALSE; + swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER; + break; + + case SW_SHOWMINNOACTIVE: + swp |= SWP_NOACTIVATE | SWP_NOZORDER; + /* fall through */ + case SW_SHOWMINIMIZED: + swp |= SWP_SHOWWINDOW; + /* fall through */ + case SW_MINIMIZE: + swp |= SWP_FRAMECHANGED; + if( !(wndPtr->dwStyle & WS_MINIMIZE) ) + swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos ); + else swp |= SWP_NOSIZE | SWP_NOMOVE; + break; + + case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */ + swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; + if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) + swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos ); + else swp |= SWP_NOSIZE | SWP_NOMOVE; + break; + + case SW_SHOWNA: + swp |= SWP_NOACTIVATE | SWP_NOZORDER; + /* fall through */ + case SW_SHOW: + swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; + break; + + case SW_SHOWNOACTIVATE: + swp |= SWP_NOZORDER; + if (GetActiveWindow()) swp |= SWP_NOACTIVATE; + /* fall through */ + case SW_SHOWNORMAL: /* same as SW_NORMAL: */ + case SW_SHOWDEFAULT: /* FIXME: should have its own handler */ + case SW_RESTORE: + swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; + + if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) ) + swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos ); + else swp |= SWP_NOSIZE | SWP_NOMOVE; + break; + } + + showFlag = (cmd != SW_HIDE); + if (showFlag != wasVisible) + { + SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 ); + if (!IsWindow( hwnd )) return wasVisible; + } + + if ((wndPtr->dwStyle & WS_CHILD) && + !IsWindowVisible( wndPtr->parent->hwndSelf ) && + (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) ) + { + /* Don't call SetWindowPos() on invisible child windows */ + if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE; + else wndPtr->dwStyle |= WS_VISIBLE; + } + else + { + /* We can't activate a child window */ + if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER; + SetWindowPos( hwnd, HWND_TOP, + newPos.left, newPos.top, newPos.right, newPos.bottom, swp ); + if (!IsWindow( hwnd )) return wasVisible; + else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE ); + } + + if (wndPtr->flags & WIN_NEED_SIZE) + { + /* should happen only in CreateWindowEx() */ + int wParam = SIZE_RESTORED; + + wndPtr->flags &= ~WIN_NEED_SIZE; + if (wndPtr->dwStyle & WS_MAXIMIZE) + wParam = SIZE_MAXIMIZED; + else if (wndPtr->dwStyle & WS_MINIMIZE) + wParam = SIZE_MINIMIZED; + SendMessageW( hwnd, WM_SIZE, wParam, + MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left, + wndPtr->rectClient.bottom-wndPtr->rectClient.top)); + SendMessageW( hwnd, WM_MOVE, 0, + MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) ); + } + + SetWindowPos( hwnd, HWND_TOP, + newPos.left, newPos.top, newPos.right, newPos.bottom, swp ); + + // SendMessage(hwnd, WM_NCACTIVATE,TRUE,0); + // SendMessage(hwnd, WM_NCPAINT,CreateRectRgn(100,100,100, 100) ,0); + + + + return wasVisible; +} + + +WINBOOL STDCALL SetWindowPos( HWND hWnd, HWND hWndInsertAfter , int X, int Y, int cx, int cy, UINT flags) @@ -351,6 +462,7 @@ SetWindowPos( * TODO: Optimize conditions that trigger DCE update. */ +#if 0 if( (((winpos.flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) && wndPtr->dwStyle & WS_VISIBLE) || (flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) ) @@ -395,7 +507,7 @@ SetWindowPos( } DeleteObject(visRgn); } - +#endif if (flags & SWP_SHOWWINDOW) { wndPtr->dwStyle |= WS_VISIBLE; @@ -429,7 +541,7 @@ SetWindowPos( } if (hWnd == CARET_GetHwnd()) DestroyCaret(); - if (winpos.hwnd == hwndActive) + if (winpos.hwnd == GetActiveWindow()) WINPOS_ActivateOtherWindow( wndPtr ); } @@ -469,1117 +581,6 @@ SetWindowPos( -/*********************************************************************** - * WINPOS_CreateInternalPosAtom - */ -WINBOOL WINPOS_CreateInternalPosAtom() -{ - LPSTR str = "SysIP"; - atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtomA(str); - return (atomInternalPos) ? TRUE : FALSE; -} - -/*********************************************************************** - * WINPOS_CheckInternalPos - * - * Called when a window is destroyed. - */ -void WINPOS_CheckInternalPos( HWND hwnd ) -{ - LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( hwnd, atomInternalPos ); - - if( hwnd == hwndPrevActive ) hwndPrevActive = 0; - if( hwnd == hwndActive ) - { - hwndActive = 0; - DPRINT("\tattempt to activate destroyed window!\n"); - } - - if( lpPos ) - { - //if( IsWindow(lpPos->hwndIconTitle) ) - // DestroyWindow( lpPos->hwndIconTitle ); - //HeapFree( GetProcessHeap(), 0, lpPos ); - } -} - -/*********************************************************************** - * WINPOS_FindIconPos - * - * Find a suitable place for an iconic window. - */ -static POINT WINPOS_FindIconPos( WND* wndPtr, POINT pt ) -{ - RECT rectParent; - short x, y, xspacing, yspacing; - - if ( wndPtr->parent != NULL ) { - GetClientRect( wndPtr->parent->hwndSelf, &rectParent ); - } - else { - - rectParent.left = 0; - rectParent.right = SYSMETRICS_CXFULLSCREEN; - - rectParent.top = 0; - rectParent.right = SYSMETRICS_CYFULLSCREEN; - } - - if ((pt.x >= rectParent.left) && (pt.x + SYSMETRICS_CXICON < rectParent.right) && - (pt.y >= rectParent.top) && (pt.y + SYSMETRICS_CYICON < rectParent.bottom)) - return pt; /* The icon already has a suitable position */ - - xspacing = SYSMETRICS_CXICONSPACING; - yspacing = SYSMETRICS_CYICONSPACING; - - y = rectParent.bottom; - for (;;) - { - for (x = rectParent.left; x <= rectParent.right-xspacing; x += xspacing) - { - /* Check if another icon already occupies this spot */ - WND *childPtr = NULL; - if ( wndPtr->parent ) - childPtr = wndPtr->parent->child; - while (childPtr) - { - if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr)) - { - if ((childPtr->rectWindow.left < x + xspacing) && - (childPtr->rectWindow.right >= x) && - (childPtr->rectWindow.top <= y) && - (childPtr->rectWindow.bottom > y - yspacing)) - break; /* There's a window in there */ - } - childPtr = childPtr->next; - } - if (!childPtr) /* No window was found, so it's OK for us */ - { - pt.x = x + (xspacing - SYSMETRICS_CXICON) / 2; - pt.y = y - (yspacing + SYSMETRICS_CYICON) / 2; - return pt; - } - } - y -= yspacing; - } -} - -/*********************************************************************** - * WINPOS_WindowFromPoint - * - * Find the window and hittest for a given point. - */ -INT WINPOS_WindowFromPoint( WND* wndScope, POINT pt, WND **ppWnd ) -{ - WND *wndPtr; - INT hittest = HTERROR; - POINT xy = pt; - - *ppWnd = NULL; - wndPtr = wndScope->child; - if( wndScope->flags & WIN_MANAGED ) - { - /* this prevents mouse clicks from going "through" scrollbars in managed mode */ - if( pt.x < wndScope->rectClient.left || pt.x >= wndScope->rectClient.right || - pt.y < wndScope->rectClient.top || pt.y >= wndScope->rectClient.bottom ) - goto hittest; - } - MapWindowPoints( GetDesktopWindow(), wndScope->hwndSelf, &xy, 1 ); - - for (;;) - { - while (wndPtr) - { - /* If point is in window, and window is visible, and it */ - /* is enabled (or it's a top-level window), then explore */ - /* its children. Otherwise, go to the next window. */ - - if ((wndPtr->dwStyle & WS_VISIBLE) && - (!(wndPtr->dwStyle & WS_DISABLED) || - ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) && - (xy.x >= wndPtr->rectWindow.left) && - (xy.x < wndPtr->rectWindow.right) && - (xy.y >= wndPtr->rectWindow.top) && - (xy.y < wndPtr->rectWindow.bottom)) - { - *ppWnd = wndPtr; /* Got a suitable window */ - - /* If window is minimized or disabled, return at once */ - if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; - if (wndPtr->dwStyle & WS_DISABLED) return HTERROR; - - /* If point is not in client area, ignore the children */ - if ((xy.x < wndPtr->rectClient.left) || - (xy.x >= wndPtr->rectClient.right) || - (xy.y < wndPtr->rectClient.top) || - (xy.y >= wndPtr->rectClient.bottom)) break; - - xy.x -= wndPtr->rectClient.left; - xy.y -= wndPtr->rectClient.top; - wndPtr = wndPtr->child; - } - else wndPtr = wndPtr->next; - } - -hittest: - /* If nothing found, try the scope window */ - if (!*ppWnd) *ppWnd = wndScope; - - /* Send the WM_NCHITTEST message (only if to the same task) */ - if ((*ppWnd)->hmemTaskQ == GetFastQueue()) - { - hittest = (INT)SendMessageA( (*ppWnd)->hwndSelf, WM_NCHITTEST, - 0, MAKELONG( pt.x, pt.y ) ); - if (hittest != HTTRANSPARENT) return hittest; /* Found the window */ - } - else return HTCLIENT; - - /* If no children found in last search, make point relative to parent */ - if (!wndPtr) - { - xy.x += (*ppWnd)->rectClient.left; - xy.y += (*ppWnd)->rectClient.top; - } - - /* Restart the search from the next sibling */ - wndPtr = (*ppWnd)->next; - *ppWnd = (*ppWnd)->parent; - } -} - -/******************************************************************* - * WINPOS_GetWinOffset - * - * Calculate the offset between the origin of the two windows. Used - * to implement MapWindowPoints. - */ -void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, - POINT *offset ) -{ - WND * wndPtr; - - offset->x = offset->y = 0; - if (hwndFrom == hwndTo ) return; - - /* Translate source window origin to screen coords */ - if (hwndFrom) - { - if (!(wndPtr = WIN_FindWndPtr( hwndFrom ))) - { - //ERR(win,"bad hwndFrom = %04x\n",hwndFrom); - return; - } - while (wndPtr->parent) - { - offset->x += wndPtr->rectClient.left; - offset->y += wndPtr->rectClient.top; - wndPtr = wndPtr->parent; - } - } - - /* Translate origin to destination window coords */ - if (hwndTo) - { - if (!(wndPtr = WIN_FindWndPtr( hwndTo ))) - { - //ERR(win,"bad hwndTo = %04x\n", hwndTo ); - return; - } - while (wndPtr->parent) - { - offset->x -= wndPtr->rectClient.left; - offset->y -= wndPtr->rectClient.top; - wndPtr = wndPtr->parent; - } - } -} - -/******************************************************************* - * WINPOS_CanActivate - */ -WINBOOL WINPOS_CanActivate(WND* pWnd) -{ - if( pWnd && ((pWnd->dwStyle & (WS_DISABLED | WS_VISIBLE | WS_CHILD)) - == WS_VISIBLE) ) return TRUE; - return FALSE; -} - -/*********************************************************************** - * WINPOS_InitInternalPos - */ -LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt, - LPRECT restoreRect ) -{ - LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( wnd->hwndSelf, - atomInternalPos ); - if( !lpPos ) - { - /* this happens when the window is minimized/maximized - * for the first time (rectWindow is not adjusted yet) */ - - lpPos = HeapAlloc( GetProcessHeap(), 0, sizeof(INTERNALPOS) ); - if( !lpPos ) return NULL; - - SetPropA( wnd->hwndSelf, atomInternalPos, (HANDLE)lpPos ); - lpPos->hwndIconTitle = 0; /* defer until needs to be shown */ - memcpy( &lpPos->rectNormal, &wnd->rectWindow ,sizeof(RECT)); - *(UINT*)&lpPos->ptIconPos = *(UINT*)&lpPos->ptMaxPos = 0xFFFFFFFF; - } - - - if( wnd->dwStyle & WS_MINIMIZE ) - memcpy( &lpPos->ptIconPos, &pt,sizeof(POINT) ); - else if( wnd->dwStyle & WS_MAXIMIZE ) - memcpy( &lpPos->ptMaxPos, &pt,sizeof(POINT) ); - else if( restoreRect ) - memcpy( &lpPos->rectNormal, restoreRect, sizeof(RECT) ); - - return lpPos; -} - -/*********************************************************************** - * WINPOS_RedrawIconTitle - */ -WINBOOL WINPOS_RedrawIconTitle( HWND hWnd ) -{ - LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( hWnd, atomInternalPos ); - if( lpPos ) - { - if( lpPos->hwndIconTitle ) - { - SendMessageA( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0); - InvalidateRect( lpPos->hwndIconTitle, NULL, TRUE ); - return TRUE; - } - } - return FALSE; -} - -/*********************************************************************** - * WINPOS_ShowIconTitle - */ -WINBOOL WINPOS_ShowIconTitle( WND* pWnd, WINBOOL bShow ) -{ - LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( pWnd->hwndSelf, atomInternalPos ); - - if( lpPos && !(pWnd->flags & WIN_MANAGED)) - { - HWND hWnd = lpPos->hwndIconTitle; - - //DPRINT("0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) ); - -// if( !hWnd ) -// lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd ); - if( bShow ) - { - pWnd = WIN_FindWndPtr(hWnd); - - if( !(pWnd->dwStyle & WS_VISIBLE) ) - { - SendMessageA( hWnd, WM_SHOWWINDOW, TRUE, 0 ); - SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ); - } - } - else ShowWindow( hWnd, SW_HIDE ); - } - return FALSE; -} - -/******************************************************************* - * WINPOS_GetMinMaxInfo - * - * Get the minimized and maximized information for a window. - */ -void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos, - POINT *minTrack, POINT *maxTrack ) -{ - LPINTERNALPOS lpPos; - MINMAXINFO MinMax; - INT xinc, yinc; - - /* Compute default values */ - - MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN; - MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN; - MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK; - MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK; - MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN; - MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN; - - if (wndPtr->flags & WIN_MANAGED) xinc = yinc = 0; - else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) - { - xinc = SYSMETRICS_CXDLGFRAME; - yinc = SYSMETRICS_CYDLGFRAME; - } - else - { - xinc = yinc = 0; - if (HAS_THICKFRAME(wndPtr->dwStyle)) - { - xinc += SYSMETRICS_CXFRAME; - yinc += SYSMETRICS_CYFRAME; - } - if (wndPtr->dwStyle & WS_BORDER) - { - xinc += SYSMETRICS_CXBORDER; - yinc += SYSMETRICS_CYBORDER; - } - } - MinMax.ptMaxSize.x += 2 * xinc; - MinMax.ptMaxSize.y += 2 * yinc; - - lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos ); - if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) - memcpy( &MinMax.ptMaxPosition, &lpPos->ptMaxPos,sizeof(POINT) ); - else - { - MinMax.ptMaxPosition.x = -xinc; - MinMax.ptMaxPosition.y = -yinc; - } - - MSG_SendMessage( wndPtr, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax ); - - /* Some sanity checks */ - - - MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x, - MinMax.ptMinTrackSize.x ); - MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y, - MinMax.ptMinTrackSize.y ); - - if (maxSize) *maxSize = MinMax.ptMaxSize; - if (maxPos) *maxPos = MinMax.ptMaxPosition; - if (minTrack) *minTrack = MinMax.ptMinTrackSize; - if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize; -} - -/*********************************************************************** - * WINPOS_MinMaximize - * - * Fill in lpRect and return additional flags to be used with SetWindowPos(). - * This function assumes that 'cmd' is different from the current window - * state. - */ -UINT WINPOS_MinMaximize( WND* wndPtr, UINT cmd, LPRECT lpRect ) -{ - UINT swpFlags = 0; - POINT size = { wndPtr->rectWindow.left, wndPtr->rectWindow.top }; - LPINTERNALPOS lpPos = WINPOS_InitInternalPos( wndPtr, size, - &wndPtr->rectWindow ); - - - //DPRINT("0x%04x %u\n", wndPtr->hwndSelf, cmd ); - - - if (HOOK_CallHooks(WH_CBT, HCBT_MINMAX, (INT)wndPtr->hwndSelf, cmd, wndPtr->class->bUnicode )) { - swpFlags |= SWP_NOSIZE | SWP_NOMOVE; - return swpFlags; - } - - - - if (lpPos) - { - if( wndPtr->dwStyle & WS_MINIMIZE ) - { - if( !MSG_SendMessage( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) ) - return (SWP_NOSIZE | SWP_NOMOVE); - swpFlags |= SWP_NOCOPYBITS; - } - switch( cmd ) - { - case SW_MINIMIZE: - if( wndPtr->dwStyle & WS_MAXIMIZE) - { - wndPtr->flags |= WIN_RESTORE_MAX; - wndPtr->dwStyle &= ~WS_MAXIMIZE; - } - else - wndPtr->flags &= ~WIN_RESTORE_MAX; - wndPtr->dwStyle |= WS_MINIMIZE; - - lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos ); - - SetRect( lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y, - SYSMETRICS_CXICON, SYSMETRICS_CYICON ); - swpFlags |= SWP_NOCOPYBITS; - break; - - case SW_MAXIMIZE: - - WINPOS_GetMinMaxInfo( wndPtr, &size, &lpPos->ptMaxPos, NULL, NULL ); - - if( wndPtr->dwStyle & WS_MINIMIZE ) - { - WINPOS_ShowIconTitle( wndPtr, FALSE ); - wndPtr->dwStyle &= ~WS_MINIMIZE; - } - wndPtr->dwStyle |= WS_MAXIMIZE; - - SetRect( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, - size.x, size.y ); - break; - - case SW_RESTORE: - if( wndPtr->dwStyle & WS_MINIMIZE ) - { - wndPtr->dwStyle &= ~WS_MINIMIZE; - WINPOS_ShowIconTitle( wndPtr, FALSE ); - if( wndPtr->flags & WIN_RESTORE_MAX) - { - /* Restore to maximized position */ - WINPOS_GetMinMaxInfo( wndPtr, &size,&lpPos->ptMaxPos, NULL, NULL); - wndPtr->dwStyle |= WS_MAXIMIZE; - SetRect( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y ); - break; - } - } - else - if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) return (UINT)(-1); - else wndPtr->dwStyle &= ~WS_MAXIMIZE; - - /* Restore to normal position */ - - *lpRect = lpPos->rectNormal; - lpRect->right -= lpRect->left; - lpRect->bottom -= lpRect->top; - - break; - } - } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE; - return swpFlags; -} - -/*********************************************************************** - * WINPOS_SetPlacement - */ -WINBOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, - UINT flags ) -{ - WND *pWnd = WIN_FindWndPtr( hwnd ); - if( pWnd ) - { - LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd, - *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow ); - - if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition; - if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition; - if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition; - - if( pWnd->dwStyle & WS_MINIMIZE ) - { - WINPOS_ShowIconTitle( pWnd, FALSE ); - if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos)) - SetWindowPos( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y, - 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - } - else if( pWnd->dwStyle & WS_MAXIMIZE ) - { - if( !EMPTYPOINT(lpPos->ptMaxPos) ) - SetWindowPos( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, - 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); - } - else if( flags & PLACE_RECT ) - SetWindowPos( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top, - lpPos->rectNormal.right - lpPos->rectNormal.left, - lpPos->rectNormal.bottom - lpPos->rectNormal.top, - SWP_NOZORDER | SWP_NOACTIVATE ); - - ShowWindow( hwnd, wndpl->showCmd ); - if( IsWindow(hwnd) && pWnd->dwStyle & WS_MINIMIZE ) - { - if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE ); - - /* SDK: ...valid only the next time... */ - if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX; - } - return TRUE; - } - return FALSE; -} - -/******************************************************************* - * WINPOS_SetActiveWindow - * - * SetActiveWindow() back-end. This is the only function that - * can assign active status to a window. It must be called only - * for the top level windows. - */ -WINBOOL WINPOS_SetActiveWindow( HWND hWnd, WINBOOL fMouse, WINBOOL fChangeFocus) -{ - CBTACTIVATESTRUCT* cbtStruct; - WND* wndPtr, *wndTemp; - //HQUEUE hOldActiveQueue, hNewActiveQueue; - WORD wIconized = 0; - - /* paranoid checks */ - if( hWnd == GetDesktopWindow || hWnd == hwndActive ) return 0; - -/* if (wndPtr && (GetFastQueue() != wndPtr->hmemTaskQ)) - * return 0; - */ - wndPtr = WIN_FindWndPtr(hWnd); - //hOldActiveQueue = (pActiveQueue)?pActiveQueue->self : 0; - - if( (wndTemp = WIN_FindWndPtr(hwndActive)) ) - wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE); - - -#if 0 - /* call CBT hook chain */ - if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16))) - { - LRESULT wRet; - cbtStruct->fMouse = fMouse; - cbtStruct->hWndActive = hwndActive; - wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd, - (LPARAM)SEGPTR_GET(cbtStruct) ); - SEGPTR_FREE(cbtStruct); - if (wRet) return wRet; - } -#endif - - /* set prev active wnd to current active wnd and send notification */ - if ((hwndPrevActive = hwndActive) && IsWindow(hwndPrevActive)) - { - if (!SendMessageA( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 )) - { - //if (GetSysModalWindow16() != hWnd) return 0; - /* disregard refusal if hWnd is sysmodal */ - } - - - SendMessageA( hwndPrevActive, WM_ACTIVATE, - MAKEWPARAM( WA_INACTIVE, wIconized ), - (LPARAM)hWnd ); - - - /* check if something happened during message processing */ - if( hwndPrevActive != hwndActive ) return 0; - } - - /* set active wnd */ - hwndActive = hWnd; - - /* send palette messages */ - if (hWnd && SendMessage( hWnd, WM_QUERYNEWPALETTE, 0, 0L)) - SendMessage((HWND)-1, WM_PALETTEISCHANGING, (WPARAM)hWnd, 0L ); - - /* if prev wnd is minimized redraw icon title */ - if( IsIconic( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive); - -#if DESKTOP - /* managed windows will get ConfigureNotify event */ - if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED)) - { - /* check Z-order and bring hWnd to the top */ - for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next) - if (wndTemp->dwStyle & WS_VISIBLE) break; - - if( wndTemp != wndPtr ) - SetWindowPos(hWnd, HWND_TOP, 0,0,0,0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE ); - if (!IsWindow(hWnd)) return 0; - } - -#endif - -#if 0 - hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0; - - /* send WM_ACTIVATEAPP if necessary */ - if (hOldActiveQueue != hNewActiveQueue) - { - WND **list, **ppWnd; - - if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) - { - for (ppWnd = list; *ppWnd; ppWnd++) - { - if (!IsWindow( (*ppWnd)->hwndSelf )) continue; - - if ((*ppWnd)->hmemTaskQ == hOldActiveQueue) - SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, - 0, QUEUE_GetQueueTask(hNewActiveQueue) ); - } - HeapFree( SystemHeap, 0, list ); - } - - pActiveQueue = (hNewActiveQueue) - ? (MESSAGEQUEUE*) GlobalLock16(hNewActiveQueue) : NULL; - - if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) - { - for (ppWnd = list; *ppWnd; ppWnd++) - { - if (!IsWindow( (*ppWnd)->hwndSelf )) continue; - - if ((*ppWnd)->hmemTaskQ == hNewActiveQueue) - SendMessage( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP, - 1, QUEUE_GetQueueTask( hOldActiveQueue ) ); - } - HeapFree( SystemHeap, 0, list ); - } - if (!IsWindow(hWnd)) return 0; - } - -#endif - if (hWnd) - { - /* walk up to the first unowned window */ - wndTemp = wndPtr; - while (wndTemp->owner) wndTemp = wndTemp->owner; - /* and set last active owned popup */ - wndTemp->hwndLastActive = hWnd; - - wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE); - SendMessageA( hWnd, WM_NCACTIVATE, TRUE, 0 ); - - SendMessageA( hWnd, WM_ACTIVATE, - MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized), - (LPARAM)hwndPrevActive ); - - - if( !IsWindow(hWnd) ) return 0; - } -#if 0 - /* change focus if possible */ - if( fChangeFocus && GetFocus() ) - if( WIN_GetTopParent(GetFocus()) != hwndActive ) - FOCUS_SwitchFocus( GetFocus(), - (wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))? - 0: - hwndActive - ); -#endif - - /* if active wnd is minimized redraw icon title */ - if( IsIconic(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive); - - return (hWnd == hwndActive); -} - -/******************************************************************* - * WINPOS_ActivateOtherWindow - * - * Activates window other than pWnd. - */ -WINBOOL WINPOS_ActivateOtherWindow(WND* pWnd) -{ - WINBOOL bRet = 0; - WND* pWndTo = NULL; - - if( pWnd->hwndSelf == hwndPrevActive ) - hwndPrevActive = 0; - - if( hwndActive != pWnd->hwndSelf && - ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) ) - return 0; - - if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) || - !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) ) - { - WND* pWndPtr = WIN_GetTopParentPtr(pWnd); - - pWndTo = WIN_FindWndPtr(hwndPrevActive); - - while( !WINPOS_CanActivate(pWndTo) ) - { - /* by now owned windows should've been taken care of */ - - pWndTo = pWndPtr->next; - pWndPtr = pWndTo; - if( !pWndTo ) break; - } - } - - bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : NULL, FALSE, TRUE ); - - /* switch desktop queue to current active */ - if( pWndTo ) WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ; - - hwndPrevActive = 0; - return bRet; -} - -/******************************************************************* - * WINPOS_ChangeActiveWindow - * - */ -WINBOOL WINPOS_ChangeActiveWindow( HWND hWnd, WINBOOL mouseMsg ) -{ - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if (!hWnd) return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE ); - - if( !wndPtr ) return FALSE; - - /* child windows get WM_CHILDACTIVATE message */ - if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD ) - return MSG_SendMessage(wndPtr, WM_CHILDACTIVATE, 0, 0L); - - /* owned popups imply owner activation - not sure */ - if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner && - (wndPtr->owner->dwStyle & WS_VISIBLE ) && - !(wndPtr->owner->dwStyle & WS_DISABLED )) - { - if (!(wndPtr = wndPtr->owner)) return FALSE; - hWnd = wndPtr->hwndSelf; - } - - if( hWnd == hwndActive ) return FALSE; - - if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) ) - return FALSE; - -#if DESKTOP - /* switch desktop queue to current active */ - if( wndPtr->parent == WIN_GetDesktop()) - WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ; -#endif - return TRUE; -} - - -/*********************************************************************** - * WINPOS_SendNCCalcSize - * - * Send a WM_NCCALCSIZE message to a window. - * All parameters are read-only except newClientRect. - * oldWindowRect, oldClientRect and winpos must be non-NULL only - * when calcValidRect is TRUE. - */ -LONG WINPOS_SendNCCalcSize( HWND hwnd, WINBOOL calcValidRect, - RECT *newWindowRect, RECT *oldWindowRect, - RECT *oldClientRect, WINDOWPOS *winpos, - RECT *newClientRect ) -{ - NCCALCSIZE_PARAMS params; - WINDOWPOS winposCopy; - LONG result; - - params.rgrc[0] = *newWindowRect; - if (calcValidRect) - { - winposCopy = *winpos; - params.rgrc[1] = *oldWindowRect; - params.rgrc[2] = *oldClientRect; - params.lppos = &winposCopy; - } - result = SendMessageA( hwnd, WM_NCCALCSIZE, calcValidRect, - (LPARAM)¶ms ); - - *newClientRect = params.rgrc[0]; - return result; -} - - -/*********************************************************************** - * WINPOS_HandleWindowPosChanging - * - * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). - */ -LONG WINPOS_HandleWindowPosChangingA( WND *wndPtr, WINDOWPOS *winpos ) -{ - POINT maxSize, minTrack; - if (winpos->flags & SWP_NOSIZE) return 0; - if ((wndPtr->dwStyle & WS_THICKFRAME) || - ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0)) - { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL ); - if (maxSize.x < winpos->cx) winpos->cx = maxSize.x; - if (maxSize.y < winpos->cy) winpos->cy = maxSize.y; - if (!(wndPtr->dwStyle & WS_MINIMIZE)) - { - if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x; - if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y; - } - } - return 0; -} - - -/*********************************************************************** - * WINPOS_HandleWindowPosChanging - * - * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). - */ -LONG WINPOS_HandleWindowPosChanging( WND *wndPtr, WINDOWPOS *winpos ) -{ - POINT maxSize; - if (winpos->flags & SWP_NOSIZE) return 0; - if ((wndPtr->dwStyle & WS_THICKFRAME) || - ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0)) - { - WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL ); - winpos->cx = min( winpos->cx, maxSize.x ); - winpos->cy = min( winpos->cy, maxSize.y ); - } - return 0; -} - - -/*********************************************************************** - * WINPOS_MoveWindowZOrder - * - * Move a window in Z order, invalidating everything that needs it. - * Only necessary for windows without associated X window. - */ -void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter ) -{ - WINBOOL movingUp; - WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd ); - - /* We have two possible cases: - * - The window is moving up: we have to invalidate all areas - * of the window that were covered by other windows - * - The window is moving down: we have to invalidate areas - * of other windows covered by this one. - */ - - if (hwndAfter == HWND_TOP) - { - movingUp = TRUE; - } - else if (hwndAfter == HWND_BOTTOM) - { - if (!wndPtr->next) return; /* Already at the bottom */ - movingUp = FALSE; - } - else - { - if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return; - if (wndPtr->next == pWndAfter) return; /* Already placed right */ - - /* Determine which window we encounter first in Z-order */ - pWndCur = wndPtr->parent->child; - while ((pWndCur != wndPtr) && (pWndCur != pWndAfter)) - pWndCur = pWndCur->next; - movingUp = (pWndCur == pWndAfter); - } - - if (movingUp) - { - WND *pWndPrevAfter = wndPtr->next; - WIN_UnlinkWindow( hwnd ); - WIN_LinkWindow( hwnd, hwndAfter ); - pWndCur = wndPtr->next; - while (pWndCur != pWndPrevAfter) - { - RECT rect = { pWndCur->rectWindow.left, - pWndCur->rectWindow.top, - pWndCur->rectWindow.right, - pWndCur->rectWindow.bottom }; - OffsetRect( &rect, -wndPtr->rectClient.left, - -wndPtr->rectClient.top ); - PAINT_RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | RDW_ERASE, 0 ); - pWndCur = pWndCur->next; - } - } - else /* Moving down */ - { - pWndCur = wndPtr->next; - WIN_UnlinkWindow( hwnd ); - WIN_LinkWindow( hwnd, hwndAfter ); - while (pWndCur != wndPtr) - { - RECT rect = { pWndCur->rectWindow.left, - pWndCur->rectWindow.top, - pWndCur->rectWindow.right, - pWndCur->rectWindow.bottom }; - OffsetRect( &rect, -pWndCur->rectClient.left, - -pWndCur->rectClient.top ); - PAINT_RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE | - RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 ); - pWndCur = pWndCur->next; - } - } -} - -/*********************************************************************** - * WINPOS_ReorderOwnedPopups - * - * fix Z order taking into account owned popups - - * basically we need to maintain them above the window that owns them - */ -HWND WINPOS_ReorderOwnedPopups(HWND hwndInsertAfter,WND* wndPtr,WORD flags) -{ - WND* w = WIN_GetDesktop()->child; - - if( wndPtr->dwStyle & WS_POPUP && wndPtr->owner ) - { - /* implement "local z-order" between the top and owner window */ - - HWND hwndLocalPrev = HWND_TOP; - - if( hwndInsertAfter != HWND_TOP ) - { - while( w != wndPtr->owner ) - { - if (w != wndPtr) hwndLocalPrev = w->hwndSelf; - if( hwndLocalPrev == hwndInsertAfter ) break; - w = w->next; - } - hwndInsertAfter = hwndLocalPrev; - } - - } - else if( wndPtr->dwStyle & WS_CHILD ) return hwndInsertAfter; - - w = WIN_GetDesktop()->child; - while( w ) - { - if( w == wndPtr ) break; - - if( w->dwStyle & WS_POPUP && w->owner == wndPtr ) - { - SetWindowPos(w->hwndSelf, hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | - SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE); - hwndInsertAfter = w->hwndSelf; - } - w = w->next; - } - - return hwndInsertAfter; -} - -/*********************************************************************** - * WINPOS_SizeMoveClean - * - * Make window look nice without excessive repainting - * - * the pain: - * - * visible regions are in window coordinates - * update regions are in window client coordinates - * client and window rectangles are in parent client coordinates - * - * FIXME: Move visible and update regions to the same coordinate system - * (either parent client or window). This is a lot of work though. - */ -UINT WINPOS_SizeMoveClean( WND* Wnd, HRGN oldVisRgn, - LPRECT lpOldWndRect, - LPRECT lpOldClientRect, UINT uFlags ) -{ - HRGN newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS); - HRGN dirtyRgn = CreateRectRgn(0,0,0,0); - int other, my; - - - - if( (lpOldWndRect->right - lpOldWndRect->left) != (Wnd->rectWindow.right - Wnd->rectWindow.left) || - (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) ) - uFlags |= SMC_DRAWFRAME; - - CombineRgn( dirtyRgn, newVisRgn, 0, RGN_COPY); - - if( !(uFlags & SMC_NOCOPY) ) - CombineRgn( newVisRgn, newVisRgn, oldVisRgn, RGN_AND ); - - /* map regions to the parent client area */ - - OffsetRgn( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top ); - OffsetRgn( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top ); - - /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */ - - other = CombineRgn(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF); - - /* map visible region to the Wnd client area */ - - OffsetRgn( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left, - Wnd->rectWindow.top - Wnd->rectClient.top ); - - /* substract previously invalidated region from the Wnd visible region */ - - my = (Wnd->hrgnUpdate > 1) ? CombineRgn( newVisRgn, newVisRgn, - Wnd->hrgnUpdate, RGN_DIFF) - : COMPLEXREGION; - - if( uFlags & SMC_NOCOPY ) /* invalidate Wnd visible region */ - { - if (my != NULLREGION) - PAINT_RedrawWindow( Wnd->hwndSelf, NULL, newVisRgn, RDW_INVALIDATE | - RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN ); - else if(uFlags & SMC_DRAWFRAME) - Wnd->flags |= WIN_NEEDS_NCPAINT; - } - else /* bitblt old client area */ - { - HDC hDC; - int update; - HRGN updateRgn; - int xfrom,yfrom,xto,yto,width,height; - - if( uFlags & SMC_DRAWFRAME ) - { - /* copy only client area, frame will be redrawn anyway */ - - xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top; - xto = Wnd->rectClient.left; yto = Wnd->rectClient.top; - width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom; - updateRgn = CreateRectRgn( 0, 0, width, height ); - CombineRgn( newVisRgn, newVisRgn, updateRgn, RGN_AND ); - SetRectRgn( updateRgn, 0, 0, Wnd->rectClient.right - xto, - Wnd->rectClient.bottom - yto ); - } - else - { - xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top; - xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top; - width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom; - updateRgn = CreateRectRgn( xto - Wnd->rectClient.left, - yto - Wnd->rectClient.top, - Wnd->rectWindow.right - Wnd->rectClient.left, - Wnd->rectWindow.bottom - Wnd->rectClient.top ); - } - - CombineRgn( newVisRgn, newVisRgn, updateRgn, RGN_AND ); - - /* substract new visRgn from target rect to get a region that won't be copied */ - - update = CombineRgn( updateRgn, updateRgn, newVisRgn, RGN_DIFF ); - - /* Blt valid bits using parent window DC */ - - if( Wnd->parent && my != NULLREGION && (xfrom != xto || yfrom != yto) ) - { - - /* compute clipping region in parent client coordinates */ - - OffsetRgn( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top ); - CombineRgn( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR ); - -// REMOVED DCX_KEEPCLIPRGN - - hDC = GetDCEx( Wnd->parent->hwndSelf, oldVisRgn, - DCX_INTERSECTRGN | DCX_CACHE | DCX_CLIPSIBLINGS); - - BitBlt( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY ); - ReleaseDC( Wnd->parent->hwndSelf, hDC); - - } - - if( update != NULLREGION ) - PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE | - RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN ); - else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT; - DeleteObject( updateRgn ); - } - - /* erase uncovered areas */ - - if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) ) - PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn, - RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN ); - DeleteObject(dirtyRgn); - DeleteObject(newVisRgn); - return uFlags; -} - /*********************************************************************** * MoveWindow (USER32.399) */