From 93381cbd0437b109ecf11328ae758bacabcbf89b Mon Sep 17 00:00:00 2001 From: David Welch Date: Tue, 17 Sep 2002 23:46:23 +0000 Subject: [PATCH] More user fixes. svn path=/trunk/; revision=3517 --- reactos/lib/user32/Makefile | 4 +- reactos/lib/user32/include/user32.h | 13 +- reactos/lib/user32/include/window.h | 3 + reactos/lib/user32/misc/desktop.c | 4 +- reactos/lib/user32/misc/dllmain.c | 45 +-- reactos/lib/user32/misc/stubs.c | 20 +- reactos/lib/user32/misc/winhelp.c | 4 +- reactos/lib/user32/windows/accel.c | 12 +- reactos/lib/user32/windows/bitmap.c | 10 +- reactos/lib/user32/windows/cursor.c | 11 +- reactos/lib/user32/windows/defwnd.c | 403 +++++++++++++++++++++++++-- reactos/lib/user32/windows/menu.c | 4 +- reactos/lib/user32/windows/message.c | 9 +- reactos/lib/user32/windows/prop.c | 30 +- reactos/lib/user32/windows/rect.c | 3 +- reactos/lib/user32/windows/text.c | 3 +- reactos/lib/user32/windows/window.c | 46 ++- 17 files changed, 479 insertions(+), 145 deletions(-) diff --git a/reactos/lib/user32/Makefile b/reactos/lib/user32/Makefile index bc9ff6c81d2..bbaba20bece 100644 --- a/reactos/lib/user32/Makefile +++ b/reactos/lib/user32/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.5 2002/09/08 10:23:09 chorns Exp $ +# $Id: Makefile,v 1.6 2002/09/17 23:46:22 dwelch Exp $ PATH_TO_TOP = ../.. @@ -10,7 +10,7 @@ TARGET_BASE = 0x77e70000 TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a -TARGET_CFLAGS = -I./include -DUNICODE -DDBG +TARGET_CFLAGS = -I./include -DUNICODE -DDBG -Wall -Werror TARGET_OBJECTS = $(TARGET_NAME).o diff --git a/reactos/lib/user32/include/user32.h b/reactos/lib/user32/include/user32.h index 23732f44e2b..8d31631033a 100644 --- a/reactos/lib/user32/include/user32.h +++ b/reactos/lib/user32/include/user32.h @@ -7,14 +7,5 @@ #include #include -extern HANDLE ProcessHeap; -VOID -User32FreeHeap(PVOID Block); -PVOID -User32AllocHeap(ULONG Size); -VOID -User32ConvertUnicodeString(PWSTR SrcString, PSTR DestString, ULONG DestSize); -PWSTR -User32ConvertString(PCSTR String); -VOID -User32FreeString(PWSTR String); + + diff --git a/reactos/lib/user32/include/window.h b/reactos/lib/user32/include/window.h index 87ef77edf12..02eb0eb64e7 100644 --- a/reactos/lib/user32/include/window.h +++ b/reactos/lib/user32/include/window.h @@ -8,3 +8,6 @@ #define IS_ATOM(x) \ (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000)) + +VOID +UserSetupInternalPos(VOID); diff --git a/reactos/lib/user32/misc/desktop.c b/reactos/lib/user32/misc/desktop.c index a6fe1b62a75..4db10d5b683 100644 --- a/reactos/lib/user32/misc/desktop.c +++ b/reactos/lib/user32/misc/desktop.c @@ -1,4 +1,4 @@ -/* $Id: desktop.c,v 1.6 2002/09/08 10:23:10 chorns Exp $ +/* $Id: desktop.c,v 1.7 2002/09/17 23:46:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -81,7 +81,7 @@ CreateDesktopA(LPCSTR lpszDesktop, hDesktop = CreateDesktopW(DesktopNameU.Buffer, NULL, - pDevmode, + (LPDEVMODEW)pDevmode, dwFlags, dwDesiredAccess, lpsa); diff --git a/reactos/lib/user32/misc/dllmain.c b/reactos/lib/user32/misc/dllmain.c index 077df95ba0c..eddbc972e1a 100644 --- a/reactos/lib/user32/misc/dllmain.c +++ b/reactos/lib/user32/misc/dllmain.c @@ -1,6 +1,7 @@ #include #include #include +#include #ifdef DBG @@ -12,55 +13,13 @@ DWORD DebugTraceLevel = MIN_TRACE; /* To make the linker happy */ VOID STDCALL KeBugCheck (ULONG BugCheckCode) {} -HANDLE ProcessHeap; HWINSTA ProcessWindowStation; -PVOID -User32AllocHeap(ULONG Size) -{ - return(RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, Size)); -} - -VOID -User32FreeHeap(PVOID Block) -{ - RtlFreeHeap(ProcessHeap, 0, Block); -} - -PWSTR -User32ConvertString(PCSTR String) -{ - ANSI_STRING InString; - UNICODE_STRING OutString; - RtlInitAnsiString(&InString, String); - RtlAnsiStringToUnicodeString(&OutString, &InString, TRUE); - return(OutString.Buffer); -} - -VOID -User32ConvertUnicodeString(PWSTR SrcString, PSTR DestString, ULONG DestSize) -{ - UNICODE_STRING InString; - ANSI_STRING OutString; - RtlInitUnicodeString(&InString, SrcString); - OutString.Buffer = DestString; - OutString.MaximumLength = DestSize; - RtlUnicodeStringToAnsiString(&OutString, &InString, FALSE); -} - -VOID -User32FreeString(PWSTR String) -{ - RtlFreeHeap(RtlGetProcessHeap(), 0, String); -} - DWORD Init(VOID) { DWORD Status; - ProcessHeap = RtlGetProcessHeap(); - /* Set up the kernel callbacks. */ NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] = (PVOID)User32CallWindowProcFromKernel; @@ -75,6 +34,8 @@ Init(VOID) NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_SENDNCCALCSIZE] = (PVOID)User32SendNCCALCSIZEMessageForKernel; + UserSetupInternalPos(); + GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL); return(Status); diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index 00fca0f49dd..fc91aabcbbe 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.14 2002/09/08 10:23:10 chorns Exp $ +/* $Id: stubs.c,v 1.15 2002/09/17 23:46:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -11,11 +11,6 @@ */ #include -WINBOOL STDCALL -ScreenToClient(HWND hWnd, LPPOINT lpPoint) -{ -} - WINBOOL STDCALL AnyPopup(VOID) @@ -289,19 +284,6 @@ LockWorkStation(VOID) return FALSE; } - - -int -STDCALL -MapWindowPoints( - HWND hWndFrom, - HWND hWndTo, - LPPOINT lpPoints, - UINT cPoints) -{ - return 0; -} - WINBOOL STDCALL MessageBeep( diff --git a/reactos/lib/user32/misc/winhelp.c b/reactos/lib/user32/misc/winhelp.c index e9f6568bd02..6e83a2efab6 100644 --- a/reactos/lib/user32/misc/winhelp.c +++ b/reactos/lib/user32/misc/winhelp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: winhelp.c,v 1.1 2002/08/27 06:40:15 robd Exp $ +/* $Id: winhelp.c,v 1.2 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/misc/winhelp.c @@ -123,7 +123,7 @@ WinHelpA(HWND hWnd, LPCSTR lpszHelp, UINT uCommand, DWORD dwData) lpwh->ofsData = 0; } GlobalUnlock(hwh); - return SendMessage(hDest, WM_WINHELP, hWnd, (LPARAM)hwh); + return SendMessage(hDest, WM_WINHELP, (WPARAM)hWnd, (LPARAM)hwh); } WINBOOL diff --git a/reactos/lib/user32/windows/accel.c b/reactos/lib/user32/windows/accel.c index cdd383cb099..a7192f7f5fd 100644 --- a/reactos/lib/user32/windows/accel.c +++ b/reactos/lib/user32/windows/accel.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: accel.c,v 1.3 2002/09/08 10:23:11 chorns Exp $ +/* $Id: accel.c,v 1.4 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -67,7 +67,7 @@ CreateAcceleratorTableW(LPACCEL lpaccl, WINBOOL STDCALL DestroyAcceleratorTable(HACCEL hAccel) { - User32FreeHeap(hAccel); + RtlFreeHeap(RtlGetProcessHeap(), 0, hAccel); return(TRUE); } @@ -77,9 +77,11 @@ LoadAcceleratorsA(HINSTANCE hInstance, { LPWSTR lpTableNameW; HACCEL Res; - lpTableNameW = User32ConvertString(lpTableName); + UNICODE_STRING lpTableNameString; + RtlCreateUnicodeStringFromAsciiz(&lpTableNameString, (LPSTR)lpTableName); + lpTableNameW = lpTableNameString.Buffer; Res = LoadAcceleratorsW(hInstance, lpTableNameW); - User32FreeString(lpTableName); + RtlFreeUnicodeString(&lpTableNameString); return(Res); } @@ -103,7 +105,7 @@ LoadAcceleratorsW(HINSTANCE hInstance, Mem = LoadResource(hInstance, Rsrc); Size = SizeofResource(hInstance, Rsrc); AccelTableRsrc = LockResource(Mem); - AccelTable = User32AllocHeap(Size); + AccelTable = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size); memcpy(AccelTable, AccelTableRsrc, Size); return((HACCEL)AccelTable); } diff --git a/reactos/lib/user32/windows/bitmap.c b/reactos/lib/user32/windows/bitmap.c index 5da0840e2e5..ab5aaff1caf 100644 --- a/reactos/lib/user32/windows/bitmap.c +++ b/reactos/lib/user32/windows/bitmap.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: bitmap.c,v 1.4 2002/09/08 10:23:11 chorns Exp $ +/* $Id: bitmap.c,v 1.5 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -44,13 +44,15 @@ LoadImageA(HINSTANCE hinst, { LPWSTR lpszWName; HANDLE Handle; + UNICODE_STRING NameString; if (HIWORD(lpszName)) - { - lpszWName = User32ConvertString(lpszName); + { + RtlCreateUnicodeStringFromAsciiz(&NameString, (LPSTR)lpszName); + lpszWName = NameString.Buffer; Handle = LoadImageW(hinst, lpszWName, uType, cxDesired, cyDesired, fuLoad); - User32FreeString(lpszWName); + RtlFreeUnicodeString(&NameString); } else { diff --git a/reactos/lib/user32/windows/cursor.c b/reactos/lib/user32/windows/cursor.c index 7357e2bf752..307d4d409cb 100644 --- a/reactos/lib/user32/windows/cursor.c +++ b/reactos/lib/user32/windows/cursor.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cursor.c,v 1.3 2002/09/08 10:23:12 chorns Exp $ +/* $Id: cursor.c,v 1.4 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/cursor.c @@ -121,8 +121,13 @@ LoadCursorA(HINSTANCE hInstance, HCURSOR STDCALL LoadCursorFromFileA(LPCSTR lpFileName) { - return(LoadImageW(0, lpFileName, IMAGE_CURSOR, 0, 0, - LR_LOADFROMFILE | LR_DEFAULTSIZE)); + UNICODE_STRING FileName; + HCURSOR Result; + RtlCreateUnicodeStringFromAsciiz(&FileName, (LPSTR)lpFileName); + Result = LoadImageW(0, FileName.Buffer, IMAGE_CURSOR, 0, 0, + LR_LOADFROMFILE | LR_DEFAULTSIZE); + RtlFreeUnicodeString(&FileName); + return(Result); } HCURSOR STDCALL diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 94ab84a3637..cf3f71ea14f 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.9 2002/09/08 10:23:12 chorns Exp $ +/* $Id: defwnd.c,v 1.10 2002/09/17 23:46:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -16,6 +16,7 @@ #include #include #include +#include /* GLOBALS *******************************************************************/ @@ -60,8 +61,17 @@ static COLORREF SysColours[] = RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */, }; +static ATOM AtomInternalPos; + /* FUNCTIONS *****************************************************************/ +VOID +UserSetupInternalPos(VOID) +{ + LPSTR Str = "SysIP"; + AtomInternalPos = GlobalAddAtomA(Str); +} + /* ReactOS extension */ HPEN STDCALL GetSysColorPen(int nIndex) @@ -100,6 +110,24 @@ DefFrameProcW(HWND hWnd, BOOL DefWndRedrawIconTitle(HWND hWnd) { + PINTERNALPOS lpPos = (PINTERNALPOS)GetPropA(hWnd, + (LPSTR)(DWORD)AtomInternalPos); + if (lpPos != NULL) + { + if (lpPos->IconTitle != NULL) + { + SendMessageA(lpPos->IconTitle, WM_SHOWWINDOW, TRUE, 0); + InvalidateRect(lpPos->IconTitle, NULL, TRUE); + return(TRUE); + } + } + return(FALSE); +} + +BOOL +UserHasMenu(HWND hWnd, ULONG Style) +{ + return(!(Style & WS_CHILD) && GetWindowLong(hWnd, GWL_ID) != 0); } ULONG @@ -292,8 +320,9 @@ static void UserDrawCaptionNC( HDC hdc, RECT *rect, HWND hwnd, if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) ); else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ); SetBkMode( hdc, TRANSPARENT ); - DrawTextA( hdc, buffer, -1, &r, - DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX ); + /*DrawTextA( hdc, buffer, -1, &r, + DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );*/ + TextOutA(hdc, r.left, r.top, buffer, strlen(buffer)); } } @@ -450,21 +479,342 @@ DefWndPaintNC(HWND hWnd, HRGN clip) LRESULT DefWndHitTestNC(HWND hWnd, POINT Point) { + RECT WindowRect; + ULONG Style = GetWindowLong(hWnd, GWL_STYLE); + ULONG ExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); + + GetWindowRect(hWnd, &WindowRect); + + if (!PtInRect(&WindowRect, Point)) + { + return(HTNOWHERE); + } + if (Style & WS_MINIMIZE) + { + return(HTCAPTION); + } + if (UserHasThickFrameStyle(Style, ExStyle)) + { + InflateRect(&WindowRect, -GetSystemMetrics(SM_CXFRAME), + -GetSystemMetrics(SM_CYFRAME)); + if (!PtInRect(&WindowRect, Point)) + { + if (Point.y < WindowRect.top) + { + if (Point.x < (WindowRect.left + GetSystemMetrics(SM_CXSIZE))) + { + return(HTTOPLEFT); + } + if (Point.x >= (WindowRect.right - GetSystemMetrics(SM_CXSIZE))) + { + return(HTTOPRIGHT); + } + return(HTTOP); + } + if (Point.y >= WindowRect.bottom) + { + if (Point.x < (WindowRect.left + GetSystemMetrics(SM_CXSIZE))) + { + return(HTBOTTOMLEFT); + } + if (Point.x >= (WindowRect.right - GetSystemMetrics(SM_CXSIZE))) + { + return(HTBOTTOMRIGHT); + } + return(HTBOTTOM); + } + if (Point.x < WindowRect.left) + { + if (Point.y < (WindowRect.top + GetSystemMetrics(SM_CYSIZE))) + { + return(HTTOPLEFT); + } + if (Point.y >= (WindowRect.bottom - GetSystemMetrics(SM_CYSIZE))) + { + return(HTBOTTOMLEFT); + } + return(HTLEFT); + } + if (Point.x >= WindowRect.right) + { + if (Point.y < (WindowRect.top + GetSystemMetrics(SM_CYSIZE))) + { + return(HTTOPRIGHT); + } + if (Point.y >= (WindowRect.bottom - GetSystemMetrics(SM_CYSIZE))) + { + return(HTBOTTOMRIGHT); + } + return(HTRIGHT); + } + } + } + else + { + if (UserHasDlgFrameStyle(Style, ExStyle)) + { + InflateRect(&WindowRect, -GetSystemMetrics(SM_CXDLGFRAME), + -GetSystemMetrics(SM_CYDLGFRAME)); + } + else if (UserHasThinFrameStyle(Style, ExStyle)) + { + InflateRect(&WindowRect, -GetSystemMetrics(SM_CXBORDER), + -GetSystemMetrics(SM_CYBORDER)); + } + if (!PtInRect(&WindowRect, Point)) + { + return(HTBORDER); + } + } + + if ((Style & WS_CAPTION) == WS_CAPTION) + { + WindowRect.top += GetSystemMetrics(SM_CYCAPTION) - + GetSystemMetrics(SM_CYBORDER); + if (!PtInRect(&WindowRect, Point)) + { + if ((Style & WS_SYSMENU) && !(ExStyle & WS_EX_TOOLWINDOW)) + { + WindowRect.left += GetSystemMetrics(SM_CXSIZE); + } + if (Point.x <= WindowRect.left) + { + return(HTSYSMENU); + } + + if (Style & WS_MAXIMIZEBOX) + { + WindowRect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + } + if (Point.x >= WindowRect.right) + { + return(HTMAXBUTTON); + } + + if (Style & WS_MINIMIZEBOX) + { + WindowRect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + } + if (Point.x >= WindowRect.right) + { + return(HTMINBUTTON); + } + return(HTCAPTION); + } + } + + ScreenToClient(hWnd, &Point); + GetClientRect(hWnd, &WindowRect); + + if (PtInRect(&WindowRect, Point)) + { + return(HTCLIENT); + } + + if (Style & WS_VSCROLL) + { + WindowRect.right += GetSystemMetrics(SM_CXVSCROLL); + if (PtInRect(&WindowRect, Point)) + { + return(HTVSCROLL); + } + } + + if (Style & WS_HSCROLL) + { + WindowRect.bottom += GetSystemMetrics(SM_CYHSCROLL); + if (PtInRect(&WindowRect, Point)) + { + if ((Style & WS_VSCROLL) && + (Point.x >= (WindowRect.right - GetSystemMetrics(SM_CXVSCROLL)))) + { + return(HTSIZE); + } + return(HTHSCROLL); + } + } + + if (UserHasMenu(hWnd, Style)) + { + if (Point.y < 0 && Point.x >= 0 && Point.x <= WindowRect.right) + { + return(HTMENU); + } + } + + return(HTNOWHERE); +} + +VOID +DefWndTrackMinMaxBox(HWND hWnd, WPARAM wParam) +{ + HDC hDC = GetWindowDC(hWnd); + BOOL Pressed = TRUE; + MSG Msg; + + SetCapture(hWnd); + + if (wParam == HTMINBUTTON) + { + UserDrawMinButton(hWnd, hDC, TRUE); + } + else + { + UserDrawMaxButton(hWnd, hDC, TRUE); + } + + for(;;) + { + BOOL OldState = Pressed; + + GetMessageA(hWnd, &Msg, 0, 0); + if (Msg.message == WM_LBUTTONUP) + { + break; + } + if (Msg.message != WM_MOUSEMOVE) + { + continue; + } + + Pressed = DefWndHitTestNC(hWnd, Msg.pt) == wParam; + if (Pressed != OldState) + { + if (wParam == HTMINBUTTON) + { + UserDrawMinButton(hWnd, hDC, Pressed); + } + else + { + UserDrawMaxButton(hWnd, hDC, Pressed); + } + } + } + + if (Pressed) + { + if (wParam == HTMINBUTTON) + { + UserDrawMinButton(hWnd, hDC, FALSE); + } + else + { + UserDrawMaxButton(hWnd, hDC, FALSE); + } + } + + ReleaseCapture(); + ReleaseDC(hWnd, hDC); + + if (!Pressed) + { + return; + } + + if (wParam == HTMINBUTTON) + { + SendMessageA(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, + MAKELONG(Msg.pt.x, Msg.pt.y)); + } + else + { + SendMessageA(hWnd, WM_SYSCOMMAND, + IsZoomed(hWnd) ? SC_RESTORE : SC_MAXIMIZE, + MAKELONG(Msg.pt.x, Msg.pt.y)); + } +} + +VOID +DefWndDrawSysButton(HWND hWnd, HDC hDC, BOOL Down) +{ + RECT Rect; + HDC hDcMem; + HBITMAP hSavedBitmap; + + UserGetInsideRectNC(hWnd, &Rect); + hDcMem = CreateCompatibleDC(hDC); + hSavedBitmap = SelectObject(hDcMem, hbitmapClose); + BitBlt(hDC, Rect.left, Rect.top, GetSystemMetrics(SM_CXSIZE), + GetSystemMetrics(SM_CYSIZE), hDcMem, + (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) ? + GetSystemMetrics(SM_CXSIZE): 0, 0, Down ? NOTSRCCOPY : SRCCOPY); + SelectObject(hDcMem, hSavedBitmap); + DeleteDC(hDcMem); } LRESULT DefWndHandleLButtonDownNC(HWND hWnd, WPARAM wParam, LPARAM lParam) { + switch (wParam) + { + case HTCAPTION: + { + HWND hTopWnd = GetAncestor(hWnd, GA_ROOT); + if (SetActiveWindow(hTopWnd) || GetActiveWindow() == hTopWnd) + { + SendMessageA(hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, lParam); + } + break; + } + case HTSYSMENU: + { + if (GetWindowLong(hWnd, GWL_STYLE) & WS_SYSMENU) + { + if (!(GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE)) + { + HDC hDC = GetWindowDC(hWnd); + DefWndDrawSysButton(hWnd, hDC, TRUE); + ReleaseDC(hWnd, hDC); + } + SendMessageA(hWnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, + lParam); + } + break; + } + + case HTMENU: + SendMessageA(hWnd, WM_SYSCOMMAND, SC_MOUSEMENU, lParam); + break; + + case HTHSCROLL: + SendMessageA(hWnd, WM_SYSCOMMAND, SC_HSCROLL + HTHSCROLL, lParam); + break; + + case HTVSCROLL: + SendMessageA(hWnd, WM_SYSCOMMAND, SC_VSCROLL + HTVSCROLL, lParam); + break; + + case HTMINBUTTON: + case HTMAXBUTTON: + DefWndTrackMinMaxBox(hWnd, wParam); + break; + + case HTLEFT: + case HTRIGHT: + case HTTOP: + case HTBOTTOM: + case HTTOPLEFT: + case HTTOPRIGHT: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + SendMessageA(hWnd, WM_SYSCOMMAND, SC_SIZE + wParam - 2, lParam); + break; + } + return(0); } LRESULT DefWndHandleLButtonDblClkNC(HWND hWnd, WPARAM wParam, LPARAM lParam) { + /* FIXME: Implement this. */ + return(0); } LRESULT DefWndHandleActiveNC(HWND hWnd, WPARAM wParam) { + /* FIXME: Implement this. */ + return(0); } VOID @@ -624,6 +974,7 @@ LRESULT DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos) { /* FIXME: Implement this. */ + return(0); } LRESULT STDCALL @@ -1022,7 +1373,7 @@ DefWindowProcA(HWND hWnd, LPARAM lParam) { LRESULT Result; - static ATOM WindowTextAtom = 0; + static LPSTR WindowTextAtom = 0; PSTR WindowText; switch (Msg) @@ -1032,8 +1383,10 @@ DefWindowProcA(HWND hWnd, CREATESTRUCTA* Cs = (CREATESTRUCTA*)lParam; if (HIWORD(Cs->lpszName)) { - WindowTextAtom = GlobalAddAtomA("USER32!WindowTextAtomA"); - WindowText = User32AllocHeap(strlen(Cs->lpszName) * sizeof(CHAR)); + WindowTextAtom = + (LPSTR)(ULONG)GlobalAddAtomA("USER32!WindowTextAtomA"); + WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0, + strlen(Cs->lpszName) * sizeof(CHAR)); strcpy(WindowText, Cs->lpszName); SetPropA(hWnd, WindowTextAtom, WindowText); } @@ -1057,7 +1410,7 @@ DefWindowProcA(HWND hWnd, { return(0); } - return(wcslen(WindowText)); + return(strlen(WindowText)); } case WM_GETTEXT: @@ -1071,22 +1424,24 @@ DefWindowProcA(HWND hWnd, } return(0); } - strncpy(lParam, WindowText, wParam); - return(min(wParam, wcslen(WindowText))); + strncpy((LPSTR)lParam, WindowText, wParam); + return(min(wParam, strlen(WindowText))); } case WM_SETTEXT: { if (WindowTextAtom != 0) { - WindowTextAtom = GlobalAddAtomA("USER32!WindowTextAtomW"); + WindowTextAtom = + (LPSTR)(DWORD)GlobalAddAtomA("USER32!WindowTextAtomW"); } if (WindowTextAtom != 0 && (WindowText = GetPropA(hWnd, WindowTextAtom)) == NULL) { - User32FreeHeap(WindowText); + RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText); } - WindowText = User32AllocHeap(strlen((PSTR)lParam) * sizeof(CHAR)); + WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0, + strlen((PSTR)lParam) * sizeof(CHAR)); strcpy(WindowText, (PSTR)lParam); SetPropA(hWnd, WindowTextAtom, WindowText); } @@ -1096,11 +1451,11 @@ DefWindowProcA(HWND hWnd, if (WindowTextAtom != 0 && (WindowText = RemovePropA(hWnd, WindowTextAtom)) == NULL) { - User32FreeHeap(WindowText); + RtlFreeHeap(GetProcessHeap(), 0, WindowText); } if (WindowTextAtom != 0) { - GlobalDeleteAtom(WindowTextAtom); + GlobalDeleteAtom((ATOM)(ULONG)WindowTextAtom); } /* FIXME: Destroy scroll bars here as well. */ return(0); @@ -1121,7 +1476,7 @@ DefWindowProcW(HWND hWnd, LPARAM lParam) { LRESULT Result; - static ATOM WindowTextAtom = 0; + static LPWSTR WindowTextAtom = 0; PWSTR WindowText; switch (Msg) @@ -1131,8 +1486,10 @@ DefWindowProcW(HWND hWnd, CREATESTRUCTW* Cs = (CREATESTRUCTW*)lParam; if (HIWORD(Cs->lpszName)) { - WindowTextAtom = GlobalAddAtomW(L"USER32!WindowTextAtomW"); - WindowText = User32AllocHeap(wcslen(Cs->lpszName) * sizeof(WCHAR)); + WindowTextAtom = + (LPWSTR)(DWORD)GlobalAddAtomW(L"USER32!WindowTextAtomW"); + WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0, + wcslen(Cs->lpszName) * sizeof(WCHAR)); wcscpy(WindowText, Cs->lpszName); SetPropW(hWnd, WindowTextAtom, WindowText); } @@ -1178,14 +1535,16 @@ DefWindowProcW(HWND hWnd, { if (WindowTextAtom != 0) { - WindowTextAtom = GlobalAddAtom(L"USER32!WindowTextAtomW"); + WindowTextAtom = + (LPWSTR)(DWORD)GlobalAddAtom(L"USER32!WindowTextAtomW"); } if (WindowTextAtom != 0 && (WindowText = GetPropW(hWnd, WindowTextAtom)) == NULL) { - User32FreeHeap(WindowText); + RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText); } - WindowText = User32AllocHeap(wcslen((PWSTR)lParam) * sizeof(WCHAR)); + WindowText = RtlAllocateHeap(RtlGetProcessHeap(), 0, + wcslen((PWSTR)lParam) * sizeof(WCHAR)); wcscpy(WindowText, (PWSTR)lParam); SetPropW(hWnd, WindowTextAtom, WindowText); } @@ -1195,11 +1554,11 @@ DefWindowProcW(HWND hWnd, if (WindowTextAtom != 0 && (WindowText = RemovePropW(hWnd, WindowTextAtom)) == NULL) { - User32FreeHeap(WindowText); + RtlFreeHeap(RtlGetProcessHeap(), 0, WindowText); } if (WindowTextAtom != 0) { - GlobalDeleteAtom(WindowTextAtom); + GlobalDeleteAtom((ATOM)(DWORD)WindowTextAtom); } /* FIXME: Destroy scroll bars here as well. */ return(0); diff --git a/reactos/lib/user32/windows/menu.c b/reactos/lib/user32/windows/menu.c index ed423c94070..34efa3e132e 100644 --- a/reactos/lib/user32/windows/menu.c +++ b/reactos/lib/user32/windows/menu.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: menu.c,v 1.5 2002/09/08 10:23:12 chorns Exp $ +/* $Id: menu.c,v 1.6 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/menu.c @@ -72,7 +72,7 @@ MenuFindItem(HMENU* hMenu, UINT* nPos, UINT wFlags) POPUP_MENU* Menu; ULONG i; - if ((*hMenu) == 0xFFFF || (Menu = MenuGetMenu(*hMenu)) == NULL) + if ((ULONG)(*hMenu) == 0xFFFF || (Menu = MenuGetMenu(*hMenu)) == NULL) { return(NULL); } diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c index 51c35b008b1..3fa3f693d1d 100644 --- a/reactos/lib/user32/windows/message.c +++ b/reactos/lib/user32/windows/message.c @@ -1,4 +1,4 @@ -/* $Id: message.c,v 1.10 2002/09/08 10:23:12 chorns Exp $ +/* $Id: message.c,v 1.11 2002/09/17 23:46:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -10,6 +10,7 @@ */ #include #include +#include #include LPARAM @@ -73,7 +74,7 @@ User32FreeAsciiConvertedMessage(UINT Msg, WPARAM wParam, LPARAM lParam) LPSTR TempString; LPSTR InString; InString = (LPSTR)lParam; - TempString = RtlAllocateHeap(RtlGetProcessHeap(), 0, strlen(lParam)); + TempString = RtlAllocateHeap(RtlGetProcessHeap(), 0, strlen(InString)); strcpy(TempString, InString); RtlInitAnsiString(&AnsiString, TempString); UnicodeString.Length = wParam; @@ -109,7 +110,7 @@ User32ConvertToAsciiMessage(UINT* Msg, WPARAM* wParam, LPARAM* lParam) ANSI_STRING AString; CsW = (CREATESTRUCTW*)(*lParam); - CsA = User32AllocHeap(sizeof(CREATESTRUCTA)); + CsA = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(CREATESTRUCTA)); memcpy(CsA, CsW, sizeof(CREATESTRUCTW)); RtlInitUnicodeString(&UString, CsW->lpszName); @@ -476,7 +477,7 @@ RegisterWindowMessageA(LPCSTR lpString) BOOLEAN Result; UINT Atom; - Result = RtlCreateUnicodeStringFromAsciiz(&String, lpString); + Result = RtlCreateUnicodeStringFromAsciiz(&String, (PCSZ)lpString); if (!Result) { return(0); diff --git a/reactos/lib/user32/windows/prop.c b/reactos/lib/user32/windows/prop.c index ef180dcfe80..efff72e5f60 100644 --- a/reactos/lib/user32/windows/prop.c +++ b/reactos/lib/user32/windows/prop.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: prop.c,v 1.4 2002/09/08 10:23:12 chorns Exp $ +/* $Id: prop.c,v 1.5 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -63,20 +63,22 @@ HANDLE STDCALL GetPropA(HWND hWnd, LPCSTR lpString) { PWSTR lpWString; + UNICODE_STRING UString; HANDLE Ret; if (HIWORD(lpString)) { - lpWString = User32ConvertString(lpString); + RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString); + lpWString = UString.Buffer; if (lpWString == NULL) { return(FALSE); } Ret = GetPropW(hWnd, lpWString); - User32FreeString(lpWString); + RtlFreeUnicodeString(&UString); } else { - Ret = GetPropW(hWnd, lpString); + Ret = GetPropW(hWnd, (LPWSTR)lpString); } return(Ret); } @@ -91,7 +93,7 @@ GetPropW(HWND hWnd, LPCWSTR lpString) } else { - Atom = LOWORD(lpString); + Atom = LOWORD((DWORD)lpString); } return(NtUserGetProp(hWnd, Atom)); } @@ -100,17 +102,19 @@ HANDLE STDCALL RemovePropA(HWND hWnd, LPCSTR lpString) { PWSTR lpWString; + UNICODE_STRING UString; HANDLE Ret; if (HIWORD(lpString)) { - lpWString = User32ConvertString(lpString); + RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString); + lpWString = UString.Buffer; if (lpWString == NULL) { return(FALSE); } Ret = RemovePropW(hWnd, lpWString); - User32FreeString(lpWString); + RtlFreeUnicodeString(&UString); } else { @@ -130,7 +134,7 @@ RemovePropW(HWND hWnd, } else { - Atom = LOWORD(lpString); + Atom = LOWORD((DWORD)lpString); } return(NtUserRemoveProp(hWnd, Atom)); } @@ -139,21 +143,23 @@ WINBOOL STDCALL SetPropA(HWND hWnd, LPCSTR lpString, HANDLE hData) { PWSTR lpWString; + UNICODE_STRING UString; BOOL Ret; if (HIWORD(lpString)) { - lpWString = User32ConvertString(lpString); + RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString); + lpWString = UString.Buffer; if (lpWString == NULL) { return(FALSE); } Ret = SetPropW(hWnd, lpWString, hData); - User32FreeString(lpWString); + RtlFreeUnicodeString(&UString); } else { - Ret = SetPropW(hWnd, lpString, hData); + Ret = SetPropW(hWnd, (LPWSTR)lpString, hData); } return(Ret); } @@ -168,7 +174,7 @@ SetPropW(HWND hWnd, LPCWSTR lpString, HANDLE hData) } else { - Atom = LOWORD(lpString); + Atom = LOWORD((DWORD)lpString); } return(NtUserSetProp(hWnd, Atom, hData)); diff --git a/reactos/lib/user32/windows/rect.c b/reactos/lib/user32/windows/rect.c index 746b89808c4..ccd0d41fa51 100644 --- a/reactos/lib/user32/windows/rect.c +++ b/reactos/lib/user32/windows/rect.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: rect.c,v 1.10 2002/09/08 10:23:12 chorns Exp $ +/* $Id: rect.c,v 1.11 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -87,6 +87,7 @@ IntersectRect(LPRECT lprcDst, lprcDst->right = min(lprcSrc1->right, lprcSrc2->right); lprcDst->top = max(lprcSrc1->top, lprcSrc2->top); lprcDst->bottom = min(lprcSrc1->bottom, lprcSrc2->bottom); + return(TRUE); } WINBOOL STDCALL diff --git a/reactos/lib/user32/windows/text.c b/reactos/lib/user32/windows/text.c index 44793eca3a1..bb2e481aba1 100644 --- a/reactos/lib/user32/windows/text.c +++ b/reactos/lib/user32/windows/text.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.3 2002/09/08 10:23:12 chorns Exp $ +/* $Id: text.c,v 1.4 2002/09/17 23:46:23 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -83,6 +83,7 @@ CharNextExA( LPCSTR lpCurrentChar, DWORD dwFlags) { + return (LPSTR)NULL; } LPWSTR diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 422ffae9d85..21b10af3bf3 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.13 2002/09/08 10:23:12 chorns Exp $ +/* $Id: window.c,v 1.14 2002/09/17 23:46:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -50,8 +50,7 @@ User32SendNCCALCSIZEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) Result.Rect = CallbackArgs->Rect; } DbgPrint("Returning result %d.\n", Result); - ZwCallbackReturn(&Result, sizeof(Result), STATUS_SUCCESS); - /* Doesn't return. */ + return(ZwCallbackReturn(&Result, sizeof(Result), STATUS_SUCCESS)); } NTSTATUS STDCALL @@ -75,8 +74,7 @@ User32SendGETMINMAXINFOMessageForKernel(PVOID Arguments, ULONG ArgumentLength) 0, (LPARAM)&CallbackArgs->MinMaxInfo); Result.MinMaxInfo = CallbackArgs->MinMaxInfo; DbgPrint("Returning result %d.\n", Result); - ZwCallbackReturn(&Result, sizeof(Result), STATUS_SUCCESS); - /* Doesn't return. */ + return(ZwCallbackReturn(&Result, sizeof(Result), STATUS_SUCCESS)); } NTSTATUS STDCALL @@ -99,8 +97,7 @@ User32SendCREATEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_CREATE, 0, (LPARAM)&CallbackArgs->CreateStruct); DbgPrint("Returning result %d.\n", Result); - ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS); - /* Doesn't return. */ + return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); } NTSTATUS STDCALL @@ -123,8 +120,7 @@ User32SendNCCREATEMessageForKernel(PVOID Arguments, ULONG ArgumentLength) Result = CallWindowProcW(Proc, CallbackArgs->Wnd, WM_NCCREATE, 0, (LPARAM)&CallbackArgs->CreateStruct); DbgPrint("Returning result %d.\n", Result); - ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS); - /* Doesn't return. */ + return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); } NTSTATUS STDCALL @@ -164,8 +160,7 @@ User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength) Result = CallWindowProcW(CallbackArgs->Proc, CallbackArgs->Wnd, CallbackArgs->Msg, CallbackArgs->wParam, CallbackArgs->lParam); - ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS); - /* Doesn't return. */ + return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); } WINBOOL STDCALL @@ -582,8 +577,7 @@ GetAncestor(HWND hwnd, UINT gaFlags) } WINBOOL STDCALL -GetClientRect(HWND hWnd, - LPRECT lpRect) +GetClientRect(HWND hWnd, LPRECT lpRect) { return FALSE; } @@ -918,4 +912,30 @@ WindowFromPoint(POINT Point) return (HWND)0; } +int STDCALL +MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) +{ + POINT FromOffset, ToOffset; + LONG XMove, YMove; + ULONG i; + + NtUserGetClientOrigin(hWndFrom, &FromOffset); + NtUserGetClientOrigin(hWndTo, &ToOffset); + XMove = ToOffset.x - FromOffset.x; + YMove = ToOffset.y - FromOffset.y; + for (i = 0; i < cPoints; i++) + { + lpPoints[i].x += XMove; + lpPoints[i].y += YMove; + } + return(MAKELONG(LOWORD(XMove), LOWORD(YMove))); +} + + +WINBOOL STDCALL +ScreenToClient(HWND hWnd, LPPOINT lpPoint) +{ + return(MapWindowPoints(NULL, hWnd, lpPoint, 1)); +} + /* EOF */