diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c deleted file mode 100644 index 9a316561e81..00000000000 --- a/reactos/lib/user32/windows/class.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: lib/user32/windows/class.c - * PURPOSE: Registers a window class - * PROGRAMER: Boudewijn Dekker - * UPDATE HISTORY: - * 28/05/99: Created - */ -#include -#include -#include -#include -#include - -CLASS *rootClass; - -ATOM STDCALL -RegisterClassA(const WNDCLASS* wc) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = wc->style; - wcex.lpfnWndProc = wc->lpfnWndProc; - wcex.cbClsExtra = wc->cbClsExtra; - wcex.cbWndExtra = wc->cbWndExtra; - wcex.hInstance = wc->hInstance; - wcex.hIcon = wc->hIcon; - wcex.hCursor = wc->hCursor; - wcex.hbrBackground = wc->hbrBackground; - wcex.lpszMenuName = wc->lpszMenuName; - wcex.lpszClassName = wc->lpszClassName; - wcex.hIconSm = NULL; - return RegisterClassExA(&wcex); -} - -ATOM STDCALL -RegisterClassW(const WNDCLASS* wc) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = wc->style; - wcex.lpfnWndProc = wc->lpfnWndProc; - wcex.cbClsExtra = wc->cbClsExtra; - wcex.cbWndExtra = wc->cbWndExtra; - wcex.hInstance = wc->hInstance; - wcex.hIcon = wc->hIcon; - wcex.hCursor = wc->hCursor; - wcex.hbrBackground = wc->hbrBackground; - wcex.lpszMenuName = wc->lpszMenuName; - wcex.lpszClassName = wc->lpszClassName; - wcex.hIconSm = NULL; - return RegisterClassExW(&wcex); -} - -ATOM STDCALL -RegisterClassExA(const WNDCLASSEX* wc) -{ - ATOM atom; - CLASS *classPtr; - INT classExtra, winExtra; - int len; - - if (wc == NULL || wc->cbSize != sizeof(WNDCLASSEX)) - { - SetLastError(ERROR_INVALID_DATA); - return FALSE; - } - - atom = GlobalAddAtomA(wc->lpszClassName); - if (!atom) - { - SetLastError(ERROR_CLASS_ALREADY_EXISTS); - return FALSE; - } - - classExtra = wc->cbClsExtra; - if (classExtra < 0) - classExtra = 0; - else if (classExtra > 40) - classExtra = 40; - - winExtra = wc->cbClsExtra; - if (winExtra < 0) - winExtra = 0; - else if (winExtra > 40) - winExtra = 40; - - classPtr = (CLASS *)HeapAlloc( GetProcessHeap(), 0, sizeof(CLASS) + - classExtra - sizeof(classPtr->wExtra) ); - - - if (classExtra) - HEAP_memset( classPtr->wExtra, 0, classExtra ); - - if (!classPtr) { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - GlobalDeleteAtom( atom ); - return FALSE; - } - classPtr->magic = CLASS_MAGIC; - classPtr->cWindows = 0; - classPtr->style = wc->style; - classPtr->winproc = wc->lpfnWndProc; - classPtr->cbWndExtra = winExtra; - classPtr->cbClsExtra = classExtra; - classPtr->hInstance = wc->hInstance; - classPtr->atomName = atom; - classPtr->hIcon = (HICON)wc->hIcon; - classPtr->hIconSm = (HICON)wc->hIconSm; - classPtr->hCursor = (HCURSOR)wc->hCursor; - classPtr->hbrBackground = (HBRUSH)wc->hbrBackground; - classPtr->bUnicode = FALSE; - - if (wc->style & CS_CLASSDC) - classPtr->dce = DCE_AllocDCE( 0, DCE_CLASS_DC ) ; - else - classPtr->dce = NULL; - - - if ( wc->lpszMenuName != NULL ) { - len = lstrlenA(wc->lpszMenuName); - classPtr->menuName = HeapAlloc(GetProcessHeap(),0,len+1); - lstrcpyA(classPtr->menuName,wc->lpszMenuName); - } - else - classPtr->menuName = NULL; - - - - len = lstrlenA(wc->lpszClassName); - classPtr->className = HeapAlloc(GetProcessHeap(),0,len+1); - lstrcpyA(classPtr->className,wc->lpszClassName); - - - - classPtr->next = rootClass; - rootClass = classPtr; - - return atom; -} - - -ATOM STDCALL RegisterClassExW( const WNDCLASSEX* wc ) -{ - ATOM atom; - CLASS *classPtr; - INT classExtra, winExtra; - - int len; - if ( wc == NULL || wc->cbSize != sizeof(WNDCLASSEX)) { - SetLastError(ERROR_INVALID_DATA); - return FALSE; - } - - if (!(atom = GlobalAddAtomW( (LPWSTR)wc->lpszClassName ))) - { - SetLastError(ERROR_CLASS_ALREADY_EXISTS); - return FALSE; - } - - classExtra = wc->cbClsExtra; - if (classExtra < 0) - classExtra = 0; - else if (classExtra > 40) - classExtra = 40; - - winExtra = wc->cbClsExtra; - if (winExtra < 0) - winExtra = 0; - else if (winExtra > 40) - winExtra = 40; - - classPtr = (CLASS *)HeapAlloc( GetProcessHeap(), 0, sizeof(CLASS) + - classExtra - sizeof(classPtr->wExtra) ); - - - if (classExtra) - HEAP_memset( classPtr->wExtra, 0, classExtra ); - - if (!classPtr) { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - GlobalDeleteAtom( atom ); - return FALSE; - } - classPtr->magic = CLASS_MAGIC; - classPtr->cWindows = 0; - classPtr->style = wc->style; - classPtr->winproc = wc->lpfnWndProc; - classPtr->cbWndExtra = winExtra; - classPtr->cbClsExtra = classExtra; - classPtr->hInstance = wc->hInstance; - classPtr->atomName = atom; - classPtr->hIcon = (HICON)wc->hIcon; - classPtr->hIconSm = (HICON)wc->hIconSm; - classPtr->hCursor = (HCURSOR)wc->hCursor; - classPtr->hbrBackground = (HBRUSH)wc->hbrBackground; - classPtr->bUnicode = FALSE; - - classPtr->dce = (wc->style & CS_CLASSDC) ? - CreateDC( "DISPLAY", NULL,NULL,NULL ) : NULL; - - if ( wc->lpszMenuName != NULL ) { - len = lstrlenW(wc->lpszMenuName); - classPtr->menuName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1)); - lstrcpyW(classPtr->menuName,wc->lpszMenuName); - } - else - classPtr->menuName = NULL; - - - len = lstrlenW((LPWSTR)wc->lpszClassName); - classPtr->className = HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR)); - lstrcpyW((LPWSTR)classPtr->className,(LPWSTR) wc->lpszClassName ); - - classPtr->next = rootClass; - rootClass = classPtr; - - return atom; -} - -WINBOOL STDCALL UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance ) -{ - CLASS *classPtr; - classPtr = CLASS_FindClassByAtom( STRING2ATOMA(lpClassName), hInstance ); - if ( classPtr == NULL ) - return FALSE; - - - if ( CLASS_FreeClass(classPtr) == TRUE ) - GlobalDeleteAtom( classPtr->atomName ); - return TRUE; -} - - - - -WINBOOL STDCALL UnregisterClassW(LPCWSTR lpClassName, HINSTANCE hInstance ) -{ - CLASS *classPtr; - classPtr = CLASS_FindClassByAtom( STRING2ATOMW(lpClassName), hInstance ); - if ( classPtr == NULL ) - return FALSE; - - - if ( CLASS_FreeClass(classPtr) == TRUE ) - GlobalDeleteAtom( classPtr->atomName ); - return TRUE; -} - - -WINBOOL STDCALL GetClassInfoA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASS lpWndClass ) -{ - - 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 STDCALL GetClassInfoW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASS lpWndClass ) -{ - CLASS *classPtr; - ATOM a; - - if ( HIWORD(lpClassName) != 0 ) - a = FindAtomW(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 STDCALL GetClassInfoExA( HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASSEX lpWndClassEx ) -{ - - 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 STDCALL GetClassInfoExW( HINSTANCE hInstance, LPCWSTR lpClassName, LPWNDCLASSEX lpWndClassEx ) -{ - - CLASS *classPtr; - ATOM a; - - if ( HIWORD(lpClassName) != 0 ) - a = FindAtomW(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; -} - -int STDCALL GetClassNameA(HWND hWnd, LPSTR lpClassName, int nMaxCount ) -{ - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if ( wndPtr == NULL ) - return 0; - - if ( wndPtr->class->bUnicode == TRUE ) - return 0; - - return lpstrncpyA(lpClassName,wndPtr->class->className, nMaxCount); - -} - -int STDCALL GetClassNameW(HWND hWnd, LPWSTR lpClassName, int nMaxCount ) -{ - WND *wndPtr = WIN_FindWndPtr(hWnd); - - if ( wndPtr == NULL ) - return 0; - - if ( wndPtr->class->bUnicode == FALSE ) - return 0; - - return lpstrncpyW(lpClassName,wndPtr->class->className, nMaxCount); - - -} - -DWORD STDCALL GetClassLongA(HWND hWnd, int nIndex ) -{ - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return 0; - if (nIndex >= 0) - { - if (nIndex <= wndPtr->class->cbClsExtra - sizeof(LONG)) - return (DWORD)((char *)wndPtr->class->wExtra) + nIndex; - } - switch(nIndex) - { - case GCL_STYLE: return (LONG)wndPtr->class->style; - case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra; - case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra; - case GCL_HMODULE: return (LONG)wndPtr->class->hInstance; - case GCL_WNDPROC: return (LONG)wndPtr->class->winproc; - case GCL_MENUNAME: return (LONG)wndPtr->class->menuName; - case GCW_ATOM: - case GCL_HBRBACKGROUND: - case GCL_HCURSOR: - case GCL_HICON: - case GCL_HICONSM: - return GetClassWord( hWnd, nIndex ); - default: - return -1; - } - - return 0; -} - -DWORD STDCALL GetClassLongW(HWND hWnd, int nIndex ) -{ - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return 0; - if (nIndex >= 0) - { - if (nIndex <= wndPtr->class->cbClsExtra - sizeof(LONG)) - return (DWORD)((char *)wndPtr->class->wExtra) + nIndex; - } - switch(nIndex) - { - case GCL_STYLE: return (LONG)wndPtr->class->style; - case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra; - case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra; - case GCL_HMODULE: return (LONG)wndPtr->class->hInstance; - case GCL_WNDPROC: return (LONG)wndPtr->class->winproc; - case GCL_MENUNAME: return (LONG)wndPtr->class->menuName; - case GCW_ATOM: - case GCL_HBRBACKGROUND: - case GCL_HCURSOR: - case GCL_HICON: - case GCL_HICONSM: - return GetClassWord( hWnd, nIndex ); - default: - return -1; - } - - return 0; -} - - - -WORD STDCALL GetClassWord( HWND hWnd, INT nIndex ) -{ - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return 0; - if (nIndex >= 0) - { - if (nIndex <= wndPtr->class->cbClsExtra - sizeof(WORD)) - return (WORD)(wndPtr->class->wExtra + nIndex); - } - else switch(nIndex) - { - //case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground; - //case GCW_HCURSOR: return wndPtr->class->hCursor; - //case GCW_HICON: return wndPtr->class->hIcon; - // case GCW_HICONSM: return wndPtr->class->hIconSm; - case GCW_ATOM: return wndPtr->class->atomName; - //case GCW_STYLE: - //case GCW_CBWNDEXTRA: - //case GCW_CBCLSEXTRA: - //case GCW_HMODULE: - return (WORD)GetClassLongA( hWnd, nIndex ); - default: - return -1; - } - - - return 0; -} - -WORD -STDCALL -SetClassWord( - HWND hWnd, - int nIndex, - WORD wNewWord) -{ - return 0; -} - -DWORD -STDCALL -SetClassLongA( - HWND hWnd, - int nIndex, - LONG dwNewLong) -{ - return 0; -} - -DWORD -STDCALL -SetClassLongW( - HWND hWnd, - int nIndex, - LONG dwNewLong) -{ - return 0; -} - -CLASS *CLASS_FindClassByAtom( ATOM classAtom, HINSTANCE hInstance ) -{ - CLASS *p = rootClass; - while(p != NULL ) { - if ( p->atomName == classAtom ) - return p; - p = p->next; - } - return NULL; -} - - -WINBOOL CLASS_FreeClass(CLASS *classPtr) -{ - CLASS *p = rootClass; - if( classPtr->cWindows > 0 ) - return FALSE; - - if (classPtr->dce) - DeleteDC( classPtr->dce ); - if (classPtr->hbrBackground) - DeleteObject( classPtr->hbrBackground ); - - - classPtr->atomName = 0; - HeapFree(GetProcessHeap(),0,classPtr->className); - - while(p != NULL && p->next != classPtr ) - p = p->next; - - if ( p != NULL ) - p->next = classPtr->next; - - HeapFree(GetProcessHeap(),0,classPtr); - return TRUE; -} - diff --git a/reactos/lib/user32/windows/dc.c b/reactos/lib/user32/windows/dc.c deleted file mode 100644 index 35c337aa561..00000000000 --- a/reactos/lib/user32/windows/dc.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * USER DCE functions - * - * Copyright 1993 Alexandre Julliard - * 1996,1997 Alex Korobka - * - * - * Note: Visible regions of CS_OWNDC/CS_CLASSDC window DCs - * have to be updated dynamically. - * - * Internal DCX flags: - * - * DCX_DCEEMPTY - dce is uninitialized - * DCX_DCEBUSY - dce is in use - * DCX_DCEDIRTY - ReleaseDC() should wipe instead of caching - * DCX_KEEPCLIPRGN - ReleaseDC() should not delete the clipping region - * DCX_WINDOWPAINT - BeginPaint() is in effect - */ - -/* GetDCEx flags */ - -#define DCX_USESTYLE 0x00010000 - - - -#include -#include -#include -#include -#include - - -extern DCE *firstDCE; - - - -HDC STDCALL GetDC( HWND hWnd ) -{ - WND *wndPtr; - if (!hWnd) - hWnd= GetDesktopWindow(); - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return 0; - - return wndPtr->dce->hDC; -} - -/*********************************************************************** - * GetDCEx - * - * Unimplemented flags: DCX_LOCKWINDOWUPDATE - * - * FIXME: Full support for hrgnClip == 1 (alias for entire window). - */ - - -HDC STDCALL GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) -{ - HRGN hrgnVisible = 0; - HDC hdc = 0; - DCE * dce; - //HDC dc; - WND * wndPtr; - DWORD dcxFlags = 0; - BOOL bUpdateVisRgn = TRUE; - BOOL bUpdateClipOrigin = FALSE; - - DPRINT("hwnd %04x, hrgnClip %04x, flags %08x\n", - hwnd, hrgnClip, (unsigned)flags); - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; - - /* fixup flags */ - - - - if (!(wndPtr->dwStyle & WS_CHILD) || !wndPtr->parent ) - flags &= ~DCX_PARENTCLIP; - else if( flags & DCX_PARENTCLIP ) - { - flags |= DCX_CACHE; - if( !(flags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN)) ) - if( (wndPtr->dwStyle & WS_VISIBLE) && (wndPtr->parent->dwStyle & WS_VISIBLE) ) - { - flags &= ~DCX_CLIPCHILDREN; - if( wndPtr->parent->dwStyle & WS_CLIPSIBLINGS ) - flags |= DCX_CLIPSIBLINGS; - } - } - - /* find a suitable DCE */ - - dcxFlags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | - DCX_CACHE | DCX_WINDOW); - - - dce = wndPtr->dce; - - dce->hwndCurrent = hwnd; - dce->hClipRgn = 0; - dce->DCXflags = dcxFlags | (flags & DCX_WINDOWPAINT) | DCX_DCEBUSY; - hdc = dce->hDC; - - - /* recompute visible region */ - - - if( bUpdateVisRgn ) - { - DPRINT("updating visrgn for %08x dce, hwnd [%04x]\n", (unsigned)dce, hwnd); - - if (flags & DCX_PARENTCLIP) - { - WND *parentPtr = wndPtr->parent; - - if( wndPtr->dwStyle & WS_VISIBLE && !(parentPtr->dwStyle & WS_MINIMIZE) ) - { - if( parentPtr->dwStyle & WS_CLIPSIBLINGS ) - dcxFlags = DCX_CLIPSIBLINGS | (flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW)); - else - dcxFlags = flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW); - - hrgnVisible = DCE_GetVisRgn( parentPtr->hwndSelf, dcxFlags ); - if( flags & DCX_WINDOW ) - OffsetRgn( hrgnVisible, -wndPtr->rectWindow.left, - -wndPtr->rectWindow.top ); - else - OffsetRgn( hrgnVisible, -wndPtr->rectClient.left, - -wndPtr->rectClient.top ); - DCE_OffsetVisRgn( hdc, hrgnVisible ); - } - else - hrgnVisible = CreateRectRgn( 0, 0, 0, 0 ); - } - else - if ((hwnd == GetDesktopWindow())) { - hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN, - SYSMETRICS_CYSCREEN ); - } - else - { - hrgnVisible = DCE_GetVisRgn( hwnd, flags ); - DCE_OffsetVisRgn( hdc, hrgnVisible ); - } - - //dc->w.flags &= ~DC_DIRTY; - dce->DCXflags &= ~DCX_DCEDIRTY; - SelectClipRgn( hdc, hrgnVisible ); - } - else - DPRINT("no visrgn update %08x dce, hwnd [%04x]\n", (unsigned)dce, hwnd); - - /* apply additional region operation (if any) */ - - if( flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) ) - { - 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); - - - CombineRgn( hrgnVisible, hrgnClip, 0, RGN_COPY ); - DCE_OffsetVisRgn( hdc, hrgnVisible ); - - SelectClipRgn( hdc, hrgnVisible ); - } - - if( hrgnVisible ) DeleteObject( hrgnVisible ); - - DPRINT( "(%04x,%04x,0x%lx): returning %04x\n", - hwnd, hrgnClip, flags, hdc); - return hdc; -} - -int STDCALL ReleaseDC(HWND hWnd,HDC hDC ) -{ - return 0; -} - -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 deleted file mode 100644 index 4ec8a1ae91c..00000000000 --- a/reactos/lib/user32/windows/defdlg.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Default dialog procedure - * - * Copyright 1993, 1996 Alexandre Julliard - * - */ - -#include -#include -#include -#include -#include - - - -/*********************************************************************** - * DEFDLG_SetFocus - * - * Set the focus to a control of the dialog, selecting the text if - * the control is an edit dialog. - */ -static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl ) -{ - HWND hwndPrev = GetFocus(); - - if (IsChild( hwndDlg, hwndPrev )) - { - if (SendMessage( hwndPrev, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) - SendMessage( hwndPrev, EM_SETSEL, TRUE, MAKELONG( -1, 0 ) ); - } - if (SendMessage( hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) - SendMessage( hwndCtrl, EM_SETSEL, FALSE, MAKELONG( 0, -1 ) ); - SetFocus( hwndCtrl ); -} - - -/*********************************************************************** - * DEFDLG_SaveFocus - */ -static BOOL DEFDLG_SaveFocus( HWND hwnd, DIALOGINFO *infoPtr ) -{ - HWND hwndFocus = GetFocus(); - - if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return FALSE; - infoPtr->hwndFocus = hwndFocus; - /* Remove default button */ - return TRUE; -} - - -/*********************************************************************** - * DEFDLG_RestoreFocus - */ -static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr ) -{ - if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE; - if (!IsWindow( infoPtr->hwndFocus )) return FALSE; - DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); - /* This used to set infoPtr->hwndFocus to NULL for no apparent reason, - sometimes losing focus when receiving WM_SETFOCUS messages. */ - return TRUE; -} - - -/*********************************************************************** - * DEFDLG_FindDefButton - * - * Find the current default push-button. - */ -static HWND DEFDLG_FindDefButton( HWND hwndDlg ) -{ - HWND hwndChild = GetWindow( hwndDlg, GW_CHILD ); - while (hwndChild) - { - if (SendMessage( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON) - break; - hwndChild = GetWindow( hwndChild, GW_HWNDNEXT ); - } - return hwndChild; -} - - -/*********************************************************************** - * DEFDLG_SetDefButton - * - * Set the new default button to be hwndNew. - */ -static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo, - HWND hwndNew ) -{ - if (hwndNew && - !(SendMessage(hwndNew, WM_GETDLGCODE, 0, 0 ) & DLGC_UNDEFPUSHBUTTON)) - return FALSE; /* Destination is not a push button */ - - if (dlgInfo->idResult) /* There's already a default pushbutton */ - { - HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult ); - if (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) - SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE ); - } - if (hwndNew) - { - SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE ); - dlgInfo->idResult = GetDlgCtrlID( hwndNew ); - } - else dlgInfo->idResult = 0; - return TRUE; -} - - -/*********************************************************************** - * DEFDLG_Proc - * - * Implementation of DefDlgProc(). Only handle messages that need special - * handling for dialogs. - */ -LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam, DIALOGINFO *dlgInfo ) -{ - switch(msg) - { - case WM_ERASEBKGND: - FillWindow( hwnd, hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_DLG ); - return 1; - - case WM_NCDESTROY: - - /* Free dialog heap (if created) */ - if (dlgInfo->hDialogHeap) - { - GlobalUnlock(dlgInfo->hDialogHeap); - GlobalFree(dlgInfo->hDialogHeap); - dlgInfo->hDialogHeap = 0; - } - - /* Delete font */ - if (dlgInfo->hUserFont) - { - DeleteObject( dlgInfo->hUserFont ); - dlgInfo->hUserFont = 0; - } - - /* Delete menu */ - if (dlgInfo->hMenu) - { - DestroyMenu( dlgInfo->hMenu ); - dlgInfo->hMenu = 0; - } - - /* Delete window procedure */ - //WINPROC_FreeProc( dlgInfo->dlgProc, WIN_PROC_WINDOW ); - dlgInfo->dlgProc = NULL; - dlgInfo->flags |= DF_END; /* just in case */ - - /* Window clean-up */ - return DefWindowProcA( hwnd, msg, wParam, lParam ); - - case WM_SHOWWINDOW: - if (!wParam) DEFDLG_SaveFocus( hwnd, dlgInfo ); - return DefWindowProcA( hwnd, msg, wParam, lParam ); - - case WM_ACTIVATE: - if (wParam) DEFDLG_RestoreFocus( hwnd, dlgInfo ); - else DEFDLG_SaveFocus( hwnd, dlgInfo ); - return 0; - - case WM_SETFOCUS: - DEFDLG_RestoreFocus( hwnd, dlgInfo ); - return 0; - - case DM_SETDEFID: - if (dlgInfo->flags & DF_END) return 1; - DEFDLG_SetDefButton( hwnd, dlgInfo, - wParam ? GetDlgItem( hwnd, wParam ) : 0 ); - return 1; - - case DM_GETDEFID: - { - HWND hwndDefId; - if (dlgInfo->flags & DF_END) return 0; - if (dlgInfo->idResult) - return MAKELONG( dlgInfo->idResult, DC_HASDEFID ); - if ((hwndDefId = DEFDLG_FindDefButton( hwnd ))) - return MAKELONG( GetDlgCtrlID( hwndDefId ), DC_HASDEFID); - } - return 0; - - case WM_NEXTDLGCTL: - { - HWND hwndDest = (HWND)wParam; - if (!lParam) - hwndDest = GetNextDlgTabItem(hwnd, GetFocus(), wParam); - if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest ); - DEFDLG_SetDefButton( hwnd, dlgInfo, hwndDest ); - } - return 0; - - case WM_ENTERMENULOOP: - case WM_LBUTTONDOWN: - case WM_NCLBUTTONDOWN: - { - HWND hwndFocus = GetFocus(); - if (hwndFocus) - { - WND *wnd = WIN_FindWndPtr( hwndFocus ); - - if( wnd ) - { - /* always make combo box hide its listbox control */ - - if( WIDGETS_IsControl( wnd, BIC_COMBO ) ) - SendMessageA( hwndFocus, CB_SHOWDROPDOWN, - FALSE, 0 ); - else if( WIDGETS_IsControl( wnd, BIC_EDIT ) && - WIDGETS_IsControl( wnd->parent, - BIC_COMBO )) - SendMessageA( wnd->parent->hwndSelf, - CB_SHOWDROPDOWN, FALSE, 0 ); - } - } - } - return DefWindowProcA( hwnd, msg, wParam, lParam ); - - case WM_GETFONT: - return dlgInfo->hUserFont; - - case WM_CLOSE: - PostMessageA( hwnd, WM_COMMAND, IDCANCEL, - (LPARAM)GetDlgItem( hwnd, IDCANCEL ) ); - return 0; - } - return 0; -} - -/*********************************************************************** - * DEFDLG_Epilog - */ -LRESULT DEFDLG_Epilog(DIALOGINFO* dlgInfo, UINT msg, BOOL fResult) -{ - /* see SDK 3.1 */ - - if ((msg >= WM_CTLCOLORMSGBOX && msg <= WM_CTLCOLORSTATIC) || - msg == WM_CTLCOLOR || msg == WM_COMPAREITEM || - msg == WM_VKEYTOITEM || msg == WM_CHARTOITEM || - msg == WM_QUERYDRAGICON || msg == WM_INITDIALOG) - return fResult; - - return dlgInfo->msgResult; -} - - - - -/*********************************************************************** - * DefDlgProcA (USER.120) - */ -LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam ) -{ - - DIALOGINFO * dlgInfo; - BOOL result = FALSE; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - - if (!wndPtr) return 0; - dlgInfo = (DIALOGINFO *)wndPtr->wExtra; - dlgInfo->msgResult = 0; - - if (dlgInfo->dlgProc) { /* Call dialog procedure */ - result = CallWindowProcA( (WNDPROC)dlgInfo->dlgProc, - hwnd, msg, wParam, lParam ); - - /* Check if window was destroyed by dialog procedure */ - if (dlgInfo->flags & DF_END && !(dlgInfo->flags & DF_ENDING)) { - dlgInfo->flags |= DF_ENDING; - DestroyWindow( hwnd ); - } - } - - if (!result && IsWindow(hwnd)) - { - /* callback didn't process this message */ - - switch(msg) - { - case WM_ERASEBKGND: - case WM_SHOWWINDOW: - case WM_ACTIVATE: - case WM_SETFOCUS: - case DM_SETDEFID: - case DM_GETDEFID: - case WM_NEXTDLGCTL: - case WM_GETFONT: - case WM_CLOSE: - case WM_NCDESTROY: - case WM_ENTERMENULOOP: - case WM_LBUTTONDOWN: - case WM_NCLBUTTONDOWN: - return DEFDLG_Proc( (HWND)hwnd, msg, - (WPARAM)wParam, lParam, dlgInfo ); - case WM_INITDIALOG: - case WM_VKEYTOITEM: - case WM_COMPAREITEM: - case WM_CHARTOITEM: - break; - - default: - return DefWindowProcA( hwnd, msg, wParam, lParam ); - } - } - - return DEFDLG_Epilog(dlgInfo, msg, result); - - -} - - -/*********************************************************************** - * DefDlgProcW (USER.121) - */ -LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - DIALOGINFO * dlgInfo; - BOOL result = FALSE; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - - if (!wndPtr) return 0; - dlgInfo = (DIALOGINFO *)wndPtr->wExtra; - dlgInfo->msgResult = 0; - - if (dlgInfo->dlgProc) { /* Call dialog procedure */ - result = CallWindowProcW( (WNDPROC)dlgInfo->dlgProc, - hwnd, msg, wParam, lParam ); - - /* Check if window was destroyed by dialog procedure */ - if (dlgInfo->flags & DF_END && !(dlgInfo->flags & DF_ENDING)) { - dlgInfo->flags |= DF_ENDING; - DestroyWindow( hwnd ); - } - } - - if (!result && IsWindow(hwnd)) - { - /* callback didn't process this message */ - - switch(msg) - { - case WM_ERASEBKGND: - case WM_SHOWWINDOW: - case WM_ACTIVATE: - case WM_SETFOCUS: - case DM_SETDEFID: - case DM_GETDEFID: - case WM_NEXTDLGCTL: - case WM_GETFONT: - case WM_CLOSE: - case WM_NCDESTROY: - case WM_ENTERMENULOOP: - case WM_LBUTTONDOWN: - case WM_NCLBUTTONDOWN: - return DEFDLG_Proc( (HWND)hwnd, msg, - (WPARAM)wParam, lParam, dlgInfo ); - case WM_INITDIALOG: - case WM_VKEYTOITEM: - case WM_COMPAREITEM: - case WM_CHARTOITEM: - break; - - default: - return DefWindowProcW( hwnd, msg, wParam, lParam ); - } - } - return DEFDLG_Epilog(dlgInfo, msg, result); -} diff --git a/reactos/lib/user32/windows/dialog.c b/reactos/lib/user32/windows/dialog.c deleted file mode 100644 index aa67b766654..00000000000 --- a/reactos/lib/user32/windows/dialog.c +++ /dev/null @@ -1,596 +0,0 @@ -#include -#include -#include -#include -/*********************************************************************** - * CreateDialog (USER32.89) - */ -#undef CreateDialogA -HWND STDCALL CreateDialogA( HINSTANCE hInst, LPCSTR dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return CreateDialogParamA( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - -/*********************************************************************** - * CreateDialog (USER32.89) - */ - -#undef CreateDialogW -HWND STDCALL CreateDialogW( HINSTANCE hInst, LPCWSTR dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return CreateDialogParamW( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - - - -/*********************************************************************** - * CreateDialogParamA (USER32.73) - */ -HWND STDCALL CreateDialogParamA( HINSTANCE hInst, LPCSTR name, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOG ); - if (!hrsrc) return 0; - return CreateDialogIndirectParamA( hInst, - (LPVOID)LoadResource(hInst, hrsrc), - owner, dlgProc, param ); -} - - -/*********************************************************************** - * CreateDialogParamW (USER32.74) - */ -HWND STDCALL CreateDialogParamW( HINSTANCE hInst, LPCWSTR name, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - HANDLE hrsrc = FindResourceW( hInst, name, (LPCWSTR)RT_DIALOG ); - if (!hrsrc) return 0; - return CreateDialogIndirectParamW( hInst, - (LPVOID)LoadResource(hInst, hrsrc), - owner, dlgProc, param ); -} - - -/*********************************************************************** - * CreateDialogIndirect (USER32.219) - */ -#undef CreateDialogIndirectA -HWND STDCALL CreateDialogIndirectA( HINSTANCE hInst, LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return CreateDialogIndirectParamA( hInst, dlgTemplate, owner, dlgProc, 0); -} - -/*********************************************************************** - * CreateDialogIndirect (USER32.219) - */ -#undef CreateDialogIndirectW -HWND STDCALL CreateDialogIndirectW( HINSTANCE hInst, LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return CreateDialogIndirectParamW( hInst, dlgTemplate, owner, dlgProc, 0); -} - - -/*********************************************************************** - * CreateDialogIndirectParamA (USER32.69) - */ -HWND STDCALL CreateDialogIndirectParamA( HINSTANCE hInst, - LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, - (DLGPROC)dlgProc, param, FALSE ); -} - - -/*********************************************************************** - * CreateDialogIndirectParamW (USER32.72) - */ -HWND STDCALL CreateDialogIndirectParamW( HINSTANCE hInst, - LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, - (DLGPROC)dlgProc, param, TRUE ); -} - - -/*********************************************************************** - * DialogBox (USER32.87) - */ - -#undef DialogBoxA -INT STDCALL DialogBoxA( HINSTANCE hInst, LPCSTR dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return DialogBoxParamA( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - -/*********************************************************************** - * DialogBox (USER32.87) - */ -#undef DialogBoxW -INT STDCALL DialogBoxW( HINSTANCE hInst, LPCWSTR dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return DialogBoxParamW( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - - - - -/*********************************************************************** - * DialogBoxParamA (USER32.139) - */ -INT STDCALL DialogBoxParamA( HINSTANCE hInst, LPCSTR name, - HWND owner, DLGPROC dlgProc, LPARAM param ) -{ - HWND hwnd = CreateDialogParamA( hInst, name, owner, dlgProc, param ); - if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); - return -1; -} - - -/*********************************************************************** - * DialogBoxParamW (USER32.140) - */ -INT STDCALL DialogBoxParamW( HINSTANCE hInst, LPCWSTR name, - HWND owner, DLGPROC dlgProc, LPARAM param ) -{ - HWND hwnd = CreateDialogParamW( hInst, name, owner, dlgProc, param ); - if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); - return -1; -} - - -/*********************************************************************** - * DialogBoxIndirect (USER32.218) - */ -#undef DialogBoxIndirectA -INT STDCALL DialogBoxIndirectA( HINSTANCE hInst, LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return DialogBoxIndirectParamA( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - -/*********************************************************************** - * DialogBoxIndirect (USER32.218) - */ -#undef DialogBoxIndirectW -INT STDCALL DialogBoxIndirectW( HINSTANCE hInst, LPCDLGTEMPLATE dlgTemplate, - HWND owner, DLGPROC dlgProc ) -{ - return DialogBoxIndirectParam( hInst, dlgTemplate, owner, dlgProc, 0 ); -} - - -/*********************************************************************** - * DialogBoxIndirectParamA (USER32.136) - */ -INT STDCALL DialogBoxIndirectParamA(HINSTANCE hInstance, LPCDLGTEMPLATE template, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - HWND hwnd = CreateDialogIndirectParamA( hInstance, template, - owner, dlgProc, param ); - if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); - return -1; -} - - -/*********************************************************************** - * DialogBoxIndirectParamW (USER32.138) - */ -INT STDCALL DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATE template, - HWND owner, DLGPROC dlgProc, - LPARAM param ) -{ - HWND hwnd = CreateDialogIndirectParamW( hInstance, template, - owner, dlgProc, param ); - if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); - return -1; -} - - -/*********************************************************************** - * EndDialog (USER32.88) - */ -WINBOOL STDCALL EndDialog( HWND hwnd, INT retval ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra; - - DPRINT( "%04x %d\n", hwnd, retval ); - - if( dlgInfo ) - { - dlgInfo->idResult = retval; - dlgInfo->flags |= DF_END; - } - return TRUE; -} - - -/*********************************************************************** - * IsDialogMessageA (USER32.342) - */ -WINBOOL STDCALL IsDialogMessageA( HWND hwndDlg, LPMSG msg ) -{ - WINBOOL ret, translate, dispatch; - INT dlgCode; - - if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) - return FALSE; - - dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg); - ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message, - msg->wParam, msg->lParam, - &translate, &dispatch, dlgCode ); - if (translate) TranslateMessage( msg ); - if (dispatch) DispatchMessageA( msg ); - return ret; -} - - -/*********************************************************************** - * IsDialogMessageW (USER32.343) - */ -WINBOOL STDCALL IsDialogMessageW( HWND hwndDlg, LPMSG msg ) -{ - WINBOOL ret, translate, dispatch; - INT dlgCode; - - if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) - return FALSE; - - dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg); - ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message, - msg->wParam, msg->lParam, - &translate, &dispatch, dlgCode ); - if (translate) TranslateMessage( msg ); - if (dispatch) DispatchMessageW( msg ); - return ret; -} - - - - -/**************************************************************** - * GetDlgCtrlID (USER32.234) - */ -INT STDCALL GetDlgCtrlID( HWND hwnd ) -{ - WND *wndPtr = WIN_FindWndPtr(hwnd); - if (wndPtr) return wndPtr->wIDmenu; - else return 0; -} - -HWND WINAPI GetDlgItem( HWND hwndDlg, INT id ) -{ - WND *pWnd; - - if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0; - for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next)) - if (pWnd->wIDmenu == (UINT)id) - { - HWND retvalue = pWnd->hwndSelf; - WIN_ReleaseWndPtr(pWnd); - return retvalue; - } - return 0; -} - - - -/******************************************************************* - * SendDlgItemMessageA (USER32.452) - */ -LRESULT STDCALL SendDlgItemMessageA( HWND hwnd, INT id, UINT msg, - WPARAM wParam, LPARAM lParam ) -{ - HWND hwndCtrl; - hwndCtrl = GetDlgItem( hwnd, id ); - if (hwndCtrl) - return SendMessageA( hwndCtrl, msg, wParam, lParam ); - else - return 0; -} - - -/******************************************************************* - * SendDlgItemMessageW (USER32.453) - */ -LRESULT STDCALL SendDlgItemMessageW( HWND hwnd, INT id, UINT msg, - WPARAM wParam, LPARAM lParam ) -{ - HWND hwndCtrl; - hwndCtrl = GetDlgItem( hwnd, id ); - if (hwndCtrl) - return SendMessageW( hwndCtrl, msg, wParam, lParam ); - else - return 0; -} - - - -/******************************************************************* - * SetDlgItemTextA (USER32.478) - */ -WINBOOL STDCALL SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString ) -{ - return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString ); -} - - -/******************************************************************* - * SetDlgItemTextW (USER32.479) - */ -WINBOOL STDCALL SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString ) -{ - return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString ); -} - - - - -/*********************************************************************** - * GetDlgItemTextA (USER32.237) - */ -UINT STDCALL GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, INT len ) -{ - return (UINT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT, - len, (LPARAM)str ); -} - - -/*********************************************************************** - * GetDlgItemTextW (USER32.238) - */ -UINT STDCALL GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, INT len ) -{ - return (UINT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT, - len, (LPARAM)str ); -} - - - - -/******************************************************************* - * SetDlgItemInt (USER32.477) - */ -WINBOOL STDCALL SetDlgItemInt( HWND hwnd, INT id, UINT value, - WINBOOL fSigned ) -{ - char str[20]; - - if (fSigned) sprintf( str, "%d", (INT)value ); - else sprintf( str, "%u", value ); - SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str ); - return TRUE; -} - - - - -/*********************************************************************** - * GetDlgItemInt (USER32.236) - */ -UINT STDCALL GetDlgItemInt( HWND hwnd, INT id, WINBOOL *translated, - WINBOOL fSigned ) -{ - char str[30]; - char * endptr; - long result = 0; - - if (translated) *translated = FALSE; - if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str)) - return 0; - if (fSigned) - { - result = strtol( str, &endptr, 10 ); - if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ - return 0; - if (((result == LONG_MIN) || (result == LONG_MAX)) ) { - // errno == ERANGE - return 0; - } - } - else - { - result = strtoul( str, &endptr, 10 ); - if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ - return 0; - if ((result == ULONG_MAX) ) { - // && (errno == ERANGE) - return 0; - } - } - if (translated) *translated = TRUE; - return (UINT)result; -} - - -/*********************************************************************** - * CheckDlgButton (USER32.97) - */ -BOOL STDCALL CheckDlgButton( HWND hwnd, INT id, UINT check ) -{ - SendDlgItemMessageW( hwnd, id, BM_SETCHECK, check, 0 ); - return TRUE; -} - - - - - -/*********************************************************************** - * IsDlgButtonChecked (USER32.98) - */ -UINT STDCALL IsDlgButtonChecked( HWND hwnd, INT id ) -{ - return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 ); -} - - - - -/*********************************************************************** - * CheckRadioButton (USER32.48) - */ -WINBOOL STDCALL CheckRadioButton( HWND hwndDlg, INT firstID, - INT lastID, INT checkID ) -{ - WND *pWnd = WIN_FindWndPtr( hwndDlg ); - if (!pWnd) return FALSE; - - for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next) - if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID)) break; - if (!pWnd) return FALSE; - - if (pWnd->wIDmenu == lastID) - lastID = firstID; /* Buttons are in reverse order */ - while (pWnd) - { - SendMessageA( pWnd->hwndSelf, BM_SETCHECK, - (pWnd->wIDmenu == checkID), 0 ); - if (pWnd->wIDmenu == lastID) break; - pWnd = pWnd->next; - } - return TRUE; -} - - -/*********************************************************************** - * GetDialogBaseUnits (USER32.243) (USER32.233) - */ -LONG STDCALL GetDialogBaseUnits(void) -{ - return MAKELONG( xBaseUnit, yBaseUnit ); -} - - -/*********************************************************************** - * MapDialogRect (USER32.103) - */ -WINBOOL STDCALL MapDialogRect( HWND hwnd, LPRECT rect ) -{ - DIALOGINFO * dlgInfo; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return FALSE; - dlgInfo = (DIALOGINFO *)wndPtr->wExtra; - rect->left = (rect->left * dlgInfo->xBaseUnit) / 4; - rect->right = (rect->right * dlgInfo->xBaseUnit) / 4; - rect->top = (rect->top * dlgInfo->yBaseUnit) / 8; - rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8; - return TRUE; -} - - - - - - - - -/*********************************************************************** - * GetNextDlgGroupItem (USER32.275) - */ -HWND STDCALL GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, - WINBOOL fPrevious ) -{ - WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg; - - if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0; - if (hwndCtrl) - { - if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0; - /* Make sure hwndCtrl is a top-level child */ - while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg)) - pWndCtrl = pWndCtrl->parent; - if (pWndCtrl->parent != pWndDlg) return 0; - } - else - { - /* No ctrl specified -> start from the beginning */ - if (!(pWndCtrl = pWndDlg->child)) return 0; - if (fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next; - } - - pWndLast = pWndCtrl; - pWnd = pWndCtrl->next; - while (1) - { - if (!pWnd || (pWnd->dwStyle & WS_GROUP)) - { - /* Wrap-around to the beginning of the group */ - WND *pWndStart = pWndDlg->child; - for (pWnd = pWndStart; pWnd; pWnd = pWnd->next) - { - if (pWnd->dwStyle & WS_GROUP) pWndStart = pWnd; - if (pWnd == pWndCtrl) break; - } - pWnd = pWndStart; - } - if (pWnd == pWndCtrl) break; - if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED)) - { - pWndLast = pWnd; - if (!fPrevious) break; - } - pWnd = pWnd->next; - } - return pWndLast->hwndSelf; -} - - - - - -/*********************************************************************** - * GetNextDlgTabItem (USER32.276) - */ -HWND STDCALL GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl, - WINBOOL fPrevious ) -{ - WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg; - - if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0; - if (hwndCtrl) - { - if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0; - /* Make sure hwndCtrl is a top-level child */ - while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg)) - pWndCtrl = pWndCtrl->parent; - if (pWndCtrl->parent != pWndDlg) return 0; - } - else - { - /* No ctrl specified -> start from the beginning */ - if (!(pWndCtrl = pWndDlg->child)) return 0; - if (!fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next; - } - - pWndLast = pWndCtrl; - pWnd = pWndCtrl->next; - while (1) - { - if (!pWnd) pWnd = pWndDlg->child; - if (pWnd == pWndCtrl) break; - if ((pWnd->dwStyle & WS_TABSTOP) && (pWnd->dwStyle & WS_VISIBLE) && - !(pWnd->dwStyle & WS_DISABLED)) - { - pWndLast = pWnd; - if (!fPrevious) break; - } - pWnd = pWnd->next; - } - return pWndLast->hwndSelf; -} - diff --git a/reactos/lib/user32/windows/focus.c b/reactos/lib/user32/windows/focus.c deleted file mode 100644 index da129fbbb3d..00000000000 --- a/reactos/lib/user32/windows/focus.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include - -HWND hwndFocus; - -//FIXME this a shared api by all procedures - -HWND STDCALL SetFocus( HWND hwnd ) -{ - HWND hWndPrevFocus, hwndTop = hwnd; - WND *wndPtr = WIN_FindWndPtr( hwnd ); - - if (wndPtr) - { - /* Check if we can set the focus to this window */ - - while ( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD ) - { - if ( wndPtr->dwStyle & ( WS_MINIMIZE | WS_DISABLED) ) - return 0; - if (!(wndPtr = wndPtr->parent)) return 0; - hwndTop = wndPtr->hwndSelf; - } - - if( hwnd == hwndFocus ) return hwnd; - - /* call hooks */ - if( HOOK_CallHooksA( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, - (LPARAM)hwndFocus) ) - return 0; - - /* activate hwndTop if needed. */ - if (hwndTop != GetActiveWindow()) - { - if (!WINPOS_SetActiveWindow(hwndTop, 0, 0)) return 0; - - if (!IsWindow( hwnd )) return 0; /* Abort if window destroyed */ - } - } - else if( HOOK_CallHooksA( WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)hwndFocus ) ) - return 0; - - /* Change focus and send messages */ - hWndPrevFocus = hwndFocus; - - FOCUS_SwitchFocus( hwndFocus , hwnd ); - - return hWndPrevFocus; -} - - -HWND STDCALL GetFocus(void) -{ - return hwndFocus; -} - -/***************************************************************** - * FOCUS_SwitchFocus - */ -void FOCUS_SwitchFocus( HWND hFocusFrom, HWND hFocusTo ) -{ - WND *pFocusTo = WIN_FindWndPtr( hFocusTo ); - hwndFocus = hFocusTo; - -#if 0 - if (hFocusFrom) SendMessageA( hFocusFrom, WM_KILLFOCUS, hFocusTo, 0 ); -#else - /* FIXME: must be SendMessage16() because 32A doesn't do - * intertask at this time */ - if (hFocusFrom) SendMessage( hFocusFrom, WM_KILLFOCUS, hFocusTo, 0 ); -#endif - if( !pFocusTo || hFocusTo != hwndFocus ) - return; - - /* According to API docs, the WM_SETFOCUS message is sent AFTER the window - has received the keyboard focus. */ - -// pFocusTo->pDriver->pSetFocus(pFocusTo); - -#if 0 - SendMessageA( hFocusTo, WM_SETFOCUS, hFocusFrom, 0 ); -#else - SendMessageA( hFocusTo, WM_SETFOCUS, hFocusFrom, 0 ); -#endif -} - diff --git a/reactos/lib/user32/windows/help.c b/reactos/lib/user32/windows/help.c deleted file mode 100644 index 0ca6e084eda..00000000000 --- a/reactos/lib/user32/windows/help.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $Id: help.c,v 1.1 1999/06/06 15:34:09 ea Exp $ - * - * reactos/lib/user32/windows/help.c - * - * Copyright (c) 1999 Emanuele Aliberti - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this software; see the file COPYING.LIB. If - * not, write to the Free Software Foundation, Inc., 675 Mass Ave, - * Cambridge, MA 02139, USA. - * - * -------------------------------------------------------------------- - * - * ReactOS user32.dll window context help functions. - * - */ -#include - -DWORD -STDCALL -GetMenuContextHelpId ( - HMENU hmenu - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -BOOL -STDCALL -SetMenuContextHelpId ( - HMENU hmenu, - DWORD dwContextHelpId - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -DWORD -STDCALL -GetWindowContextHelpId ( - HWND hwnd - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -BOOL -STDCALL -SetWindowContextHelpId ( - HWND hwnd, - DWORD dwContextHelpId - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/* EOF */ diff --git a/reactos/lib/user32/windows/hook.c b/reactos/lib/user32/windows/hook.c deleted file mode 100644 index c52d730aee5..00000000000 --- a/reactos/lib/user32/windows/hook.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Windows hook functions - * - * Copyright 1994, 1995 Alexandre Julliard - * 1996 Andrew Lewycky - * - * Based on investigations by Alex Korobka - */ - -#include -#include - -#define GetThreadQueue(x) NULL - -HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { NULL, }; - -/*********************************************************************** - * SetWindowsHookA - * - * FIXME: I don't know if this is correct - */ -HHOOK STDCALL SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) -{ - return HOOK_SetHook( idHook, lpfn, HOOK_WINA, hMod, dwThreadId ); - -} - - -/*********************************************************************** - * SetWindowsHookExW - * - * FIXME: I don't know if this is correct - */ -HHOOK STDCALL SetWindowsHookExW(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ) -{ - return HOOK_SetHook( idHook, lpfn, HOOK_WINW, hMod, dwThreadId ); - -} - - - - - - -/*********************************************************************** - * UnhookWindowsHook - */ -WINBOOL STDCALL UnhookWindowsHook( INT id, HOOKPROC proc ) -{ - return FALSE; -} - - -/*********************************************************************** - * UnhookWindowHookEx (USER.558) - */ -WINBOOL STDCALL UnhookWindowsHookEx( HHOOK hhook ) -{ - return HOOK_RemoveHook( hhook ); -} - - - -/*********************************************************************** - * CallNextHookEx - * - * There aren't ANSI and UNICODE versions of this. - */ -LRESULT STDCALL CallNextHookEx( HHOOK hhook, INT code, WPARAM wParam, - LPARAM lParam ) -{ - HHOOK next; - INT fromtype; /* figure out Ansi/Unicode */ - HOOKDATA *oldhook; - - - if (!(next = HOOK_GetNextHook(hhook ))) return 0; - - oldhook = (HOOKDATA *)hhook ; - fromtype = oldhook->flags & HOOK_MAPTYPE; - - - return HOOK_CallHook( next, fromtype, code, wParam, lParam ); -} - - - -/*********************************************************************** - * CallMsgFilterA (USER.15) - */ -/* - * FIXME: There are ANSI and UNICODE versions of this, plus an unspecified - * version, plus USER (the bit one) has a CallMsgFilter function. - */ -WINBOOL STDCALL CallMsgFilterA( LPMSG msg, INT code ) -{ - - if (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) - return TRUE; - return HOOK_CallHooksA( WH_MSGFILTER, code, 0, (LPARAM)msg ); -} - - -/*********************************************************************** - * CallMsgFilterW (USER.) - */ -WINBOOL STDCALL CallMsgFilterW( LPMSG msg, INT code ) -{ - if (HOOK_CallHooksW( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) - return TRUE; - return HOOK_CallHooksW( WH_MSGFILTER, code, 0, (LPARAM)msg ); -} - - - - - -/*********************************************************************** - * Internal Functions - */ - -/*********************************************************************** - * HOOK_GetNextHook - * - * Get the next hook of a given hook. - */ -HANDLE HOOK_GetNextHook( HHOOK hhook ) -{ - - HOOKDATA *hook; - if (!hhook) return 0; - hook = (HOOKDATA *)hhook; - - if (hook->next) return hook->next; - if (!hook->ownerQueue) return 0; /* Already system hook */ - - /* Now start enumerating the system hooks */ - return HOOK_systemHooks[hook->id - WH_MINHOOK]; -} - - -/*********************************************************************** - * HOOK_GetHook - * - * Get the first hook for a given type. - */ -HANDLE HOOK_GetHook( INT id, HQUEUE hQueue ) -{ -// MESSAGEQUEUE *queue; - HHOOK hook = 0; - - // if ((queue = (MESSAGEQUEUE *)GlobalLock( hQueue )) != NULL) - // hook = queue->hooks[id - WH_MINHOOK]; - if (!hook) hook = HOOK_systemHooks[id - WH_MINHOOK]; - return hook; -} - - -/*********************************************************************** - * HOOK_SetHook - * - * Install a given hook. - */ -HANDLE HOOK_SetHook( INT id, LPVOID proc, INT type, - HINSTANCE hInst, DWORD dwThreadId ) -{ - HOOKDATA *data; - //HANDLE handle; - HQUEUE hQueue = 0; - - if ((id < WH_MINHOOK) || (id > WH_MAXHOOK)) return 0; - - - - - //if (id == WH_JOURNALPLAYBACK) EnableHardwareInput(FALSE); - -#if 0 - if (hTask) /* Task-specific hook */ - { - if ((id == WH_JOURNALRECORD) || (id == WH_JOURNALPLAYBACK) || - (id == WH_SYSMSGFILTER)) return 0; /* System-only hooks */ - if (!(hQueue = GetTaskQueue( hTask ))) - { - /* FIXME: shouldn't this be done somewhere else? */ - if (hTask != GetCurrentTask()) return 0; - if (!(hQueue = GetFastQueue())) return 0; - } - } -#endif - - /* Create the hook structure */ - - if (!(data = HeapAlloc(GetProcessHeap(),0, sizeof(HOOKDATA) ))) return 0; - data->proc = proc; - data->id = id; - data->ownerQueue = hQueue; - data->ownerModule = hInst; - data->flags = type; - - /* Insert it in the correct linked list */ -#if 0 - if (hQueue) - { - MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( hQueue ); - data->next = queue->hooks[id - WH_MINHOOK]; - queue->hooks[id - WH_MINHOOK] = data; - return data; - } -#endif - - data->next = HOOK_systemHooks[id - WH_MINHOOK]; - HOOK_systemHooks[id - WH_MINHOOK] = data; - - - return data; -} - -/*********************************************************************** - * HOOK_RemoveHook - * - * Remove a hook from the list. - */ -WINBOOL HOOK_RemoveHook( HANDLE hook ) -{ - HOOKDATA *data; - HANDLE *prevHook = NULL; - - - - if (!(data = (HOOKDATA *)(hook))) return FALSE; - if (data->flags & HOOK_INUSE) - { - /* Mark it for deletion later on */ - //WARN(hook, "Hook still running, deletion delayed\n" ); - data->proc = (HOOKPROC)0; - return TRUE; - } - -// if (data->id == WH_JOURNALPLAYBACK) EnableHardwareInput(TRUE); - - /* Remove it from the linked list */ - - if (data->ownerQueue) - { -#if 0 - MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock( data->ownerQueue ); - if (!queue) return FALSE; - prevHook = &queue->hooks[data->id - WH_MINHOOK]; -#endif - } - else - prevHook = &HOOK_systemHooks[data->id - WH_MINHOOK]; - - while (*prevHook && *prevHook != hook) - prevHook = &((HOOKDATA *)(*prevHook))->next; - - if (!*prevHook) return FALSE; - *prevHook = data->next; - HeapFree(GetProcessHeap(),0, hook ); - return TRUE; -} - - -/*********************************************************************** - * HOOK_FindValidHook - */ -static HANDLE HOOK_FindValidHook( HANDLE hook ) -{ - HOOKDATA *data; - - for (;;) - { - if (!(data = (HOOKDATA *)(hook))) return 0; - if (data->proc) return hook; - hook = data->next; - } -} - - -/*********************************************************************** - * HOOK_CallHook - * - * Call a hook procedure. - */ -LRESULT HOOK_CallHook( HHOOK hook, INT fromtype, INT code, - WPARAM wParam, LPARAM lParam ) -{ - // MESSAGEQUEUE *queue; - //HANDLE prevHook; - HOOKDATA *data = (HOOKDATA *)(hook); - LRESULT ret; - - //WPARAM wParamOrig = wParam; - //LPARAM lParamOrig = lParam; - // HOOK_MapFunc MapFunc; - // HOOK_UnMapFunc UnMapFunc; - - // MapFunc = HOOK_MapFuncs[fromtype][data->flags & HOOK_MAPTYPE]; - // UnMapFunc = HOOK_UnMapFuncs[fromtype][data->flags & HOOK_MAPTYPE]; - - //if (MapFunc) - // MapFunc( data->id, code, &wParam, &lParam ); - - /* Now call it */ -#if 0 - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetThreadQueue(0) ))) return 0; - prevHook = queue->hCurHook; - queue->hCurHook = hook; - data->flags |= HOOK_INUSE; -#endif - //TRACE(hook, "Calling hook %04x: %d %08x %08lx\n", - // hook, code, wParam, lParam ); - - ret = data->proc(code, wParam, lParam); - - //TRACE(hook, "Ret hook %04x = %08lx\n", hook, ret ); - - data->flags &= ~HOOK_INUSE; - //queue->hCurHook = prevHook; - - //if (UnMapFunc) - // UnMapFunc( data->id, code, wParamOrig, lParamOrig, wParam, lParam ); - - if (!data->proc) HOOK_RemoveHook( hook ); - - return ret; -} - -/*********************************************************************** - * HOOK_IsHooked - * - * Replacement for calling HOOK_GetHook from other modules. - */ -WINBOOL HOOK_IsHooked( INT id ) -{ - return HOOK_GetHook( id, GetThreadQueue(0) ) != 0; -} - -LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wParam, - LPARAM lParam ,WINBOOL bUnicode) -{ - if ( bUnicode == TRUE ) - return HOOK_CallHooksW( id, code, wParam,lParam ); - else - return HOOK_CallHooksA( id, code, wParam,lParam ); - - return 0; -} - -/*********************************************************************** - * HOOK_CallHooksA - * - * Call a hook chain. - */ -LRESULT HOOK_CallHooksA( INT id, INT code, WPARAM wParam, - LPARAM lParam ) -{ - HANDLE hook; - - if (!(hook = HOOK_GetHook( id , GetThreadQueue(0) ))) return 0; - if (!(hook = HOOK_FindValidHook(hook))) return 0; - return HOOK_CallHook( hook, HOOK_WINA, code, wParam, lParam ); -} - -/*********************************************************************** - * HOOK_CallHooksW - * - * Call a hook chain. - */ -LRESULT HOOK_CallHooksW( INT id, INT code, WPARAM wParam, - LPARAM lParam ) -{ - HANDLE hook; - - if (!(hook = HOOK_GetHook( id , GetThreadQueue(0) ))) return 0; - if (!(hook = HOOK_FindValidHook(hook))) return 0; - return HOOK_CallHook( hook, HOOK_WINW, code, wParam, - lParam ); -} - - -/*********************************************************************** - * HOOK_ResetQueueHooks - */ -void HOOK_ResetQueueHooks( HQUEUE hQueue ) -{ -#if 0 - MESSAGEQUEUE *queue; - - if ((queue = (MESSAGEQUEUE *)GlobalLock( hQueue )) != NULL) - { - HOOKDATA* data; - HHOOK hook; - int id; - for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) - { - hook = queue->hooks[id - WH_MINHOOK]; - while( hook ) - { - if( (data = (HOOKDATA *)(hook)) ) - { - data->ownerQueue = hQueue; - hook = data->next; - } else break; - } - } - } -#endif -} - -/*********************************************************************** - * HOOK_FreeModuleHooks - */ -void HOOK_FreeModuleHooks( HMODULE hModule ) -{ - /* remove all system hooks registered by this module */ - - HOOKDATA* hptr; - HHOOK hook, next; - int id; - - for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) - { - hook = HOOK_systemHooks[id - WH_MINHOOK]; - while( hook ) - if( (hptr = (HOOKDATA *)(hook)) ) - { - next = hptr->next; - if( hptr->ownerModule == hModule ) - { - hptr->flags &= HOOK_MAPTYPE; - HOOK_RemoveHook(hook); - } - hook = next; - } - else hook = 0; - } -} - -/*********************************************************************** - * HOOK_FreeQueueHooks - */ -void HOOK_FreeQueueHooks( HQUEUE hQueue ) -{ - /* remove all hooks registered by this queue */ - - HOOKDATA* hptr = NULL; - HHOOK hook, next; - int id; - - for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ ) - { - hook = HOOK_GetHook( id, hQueue ); - while( hook ) - { - next = HOOK_GetNextHook(hook); - - hptr = (HOOKDATA *)(hook); - if( hptr && hptr->ownerQueue == hQueue ) - { - hptr->flags &= HOOK_MAPTYPE; - HOOK_RemoveHook(hook); - } - hook = next; - } - } -} diff --git a/reactos/lib/user32/windows/input.c b/reactos/lib/user32/windows/input.c deleted file mode 100644 index 924a88c477a..00000000000 --- a/reactos/lib/user32/windows/input.c +++ /dev/null @@ -1,64 +0,0 @@ - -#include -#include - -static INT captureHT = HTCLIENT; -static HWND captureWnd = 0; - -WINBOOL MouseButtonsStates[3]; -WINBOOL AsyncMouseButtonsStates[3]; -BYTE InputKeyStateTable[256]; -BYTE QueueKeyStateTable[256]; -BYTE AsyncKeyStateTable[256]; - -HWND EVENT_Capture(HWND hwnd, INT ht); - -HWND STDCALL SetCapture( HWND hwnd ) -{ - return EVENT_Capture( hwnd, HTCLIENT ); -} - - -WINBOOL STDCALL ReleaseCapture(void) -{ - if( captureWnd ) EVENT_Capture( 0, 0 ); -} - - -HWND STDCALL GetCapture(void) -{ - return captureWnd; -} - -/********************************************************************** - * EVENT_Capture - * - * We need this to be able to generate double click messages - * when menu code captures mouse in the window without CS_DBLCLK style. - */ -HWND EVENT_Capture(HWND hwnd, INT ht) -{ - HWND capturePrev = captureWnd; - - if (!hwnd) - { - captureWnd = 0L; - captureHT = 0; - } - else - { - if( IsWindow(hwnd) ) - { - DPRINT("(0x%04x)\n", hwnd ); - captureWnd = hwnd; - captureHT = ht; - } - } - - if( capturePrev && capturePrev != captureWnd ) - { - if( IsWindow(capturePrev) ) - SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd); - } - return capturePrev; -} \ No newline at end of file diff --git a/reactos/lib/user32/windows/msg.c b/reactos/lib/user32/windows/msg.c deleted file mode 100644 index e409f1af2ac..00000000000 --- a/reactos/lib/user32/windows/msg.c +++ /dev/null @@ -1,896 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -extern int doubleClickSpeed; - -HQUEUE hFirstQueue; -HQUEUE hNewQueue; - -/********************************************************************** - * SetDoubleClickTime (USER.480) - */ -WINBOOL STDCALL SetDoubleClickTime( UINT interval ) -{ - doubleClickSpeed = interval ? interval : 500; - return TRUE; -} - - -/********************************************************************** - * GetDoubleClickTime (USER.239) - */ -UINT STDCALL GetDoubleClickTime(void) -{ - return doubleClickSpeed; -} - -/*********************************************************************** - * PeekMessageW Check queue for messages - * - * Checks for a message in the thread's queue, filtered as for - * GetMessage(). Returns immediately whether a message is available - * or not. - * - * Whether a retrieved message is removed from the queue is set by the - * _wRemoveMsg_ flags, which should be one of the following values: - * - * PM_NOREMOVE Do not remove the message from the queue. - * - * PM_REMOVE Remove the message from the queue. - * - * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to - * request that the system not yield control during PeekMessage(); - * however applications may not rely on scheduling behavior. - * - * RETURNS - * - * Nonzero if a message is available and is retrieved, zero otherwise. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -WINBOOL STDCALL PeekMessageA( LPMSG msg, HWND hwnd, UINT first, - UINT last, UINT flags ) -{ - return MSG_PeekMessage( msg, hwnd, first, last, flags, FALSE ); -} - - -WINBOOL STDCALL PeekMessageW( LPMSG msg, HWND hwnd, UINT first, - UINT last, UINT flags ) -{ - return MSG_PeekMessage( msg, hwnd, first, last, flags, TRUE ); -} - -/*********************************************************************** - * GetMessageW (USER.274) Retrieve next message - * - * GetMessage retrieves the next event from the calling thread's - * queue and deposits it in *lpmsg. - * - * If _hwnd_ is not NULL, only messages for window _hwnd_ and its - * children as specified by IsChild() are retrieved. If _hwnd_ is NULL - * all application messages are retrieved. - * - * _min_ and _max_ specify the range of messages of interest. If - * min==max==0, no filtering is performed. Useful examples are - * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and - * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input. - * - * WM_PAINT messages are not removed from the queue; they remain until - * processed. Other messages are removed from the queue. - * - * RETURNS - * - * -1 on error, 0 if message is WM_QUIT, nonzero otherwise. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -WINBOOL -STDCALL -GetMessageA(LPMSG lpMsg, HWND hWnd , - UINT wMsgFilterMin, UINT wMsgFilterMax) -{ - - MSG_PeekMessage( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, PM_REMOVE, FALSE ); - - HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpMsg ); - return (lpMsg->message != WM_QUIT); -} - - - - -WINBOOL -STDCALL -GetMessageW( - LPMSG lpMsg, - HWND hWnd , - UINT wMsgFilterMin, - UINT wMsgFilterMax) -{ - - MSG_PeekMessage( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, PM_REMOVE, FALSE ); - - HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpMsg ); - return (lpMsg->message != WM_QUIT); -} - - -/*********************************************************************** - * PostMessageA (USER.419) - */ - -WINBOOL STDCALL PostMessageA( HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam ) -{ - MSG msg; - WND *wndPtr; - - - - - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wParam; - msg.lParam = lParam; - msg.time = GetTickCount(); - msg.pt.x = 0; - msg.pt.y = 0; - -#ifdef CONFIG_IPC - if (DDE_PostMessage(&msg)) - return TRUE; -#endif /* CONFIG_IPC */ - - if (hwnd == HWND_BROADCAST) - { - DPRINT("HWND_BROADCAST !\n"); - for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) - { - if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) - { - DPRINT("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n", - wndPtr->hwndSelf, message, wParam, lParam); - PostMessageA( wndPtr->hwndSelf, message, wParam, lParam ); - } - } - DPRINT("End of HWND_BROADCAST !\n"); - return TRUE; - } - - wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr || !wndPtr->hmemTaskQ) return FALSE; - - return QUEUE_AddMsg( wndPtr->hmemTaskQ, &msg, 0 ); -} - - - - - -/*********************************************************************** - * PostMessageW (USER.420) - */ -WINBOOL STDCALL PostMessageW( HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam ) -{ - MSG msg; - WND *wndPtr; - - - - - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wParam; - msg.lParam = lParam; - msg.time = GetTickCount(); - msg.pt.x = 0; - msg.pt.y = 0; - -#ifdef CONFIG_IPC - if (DDE_PostMessage(&msg)) - return TRUE; -#endif /* CONFIG_IPC */ - - if (hwnd == HWND_BROADCAST) - { - DPRINT("HWND_BROADCAST !\n"); - for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) - { - if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) - { - DPRINT("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n", - wndPtr->hwndSelf, message, wParam, lParam); - PostMessageA( wndPtr->hwndSelf, message, wParam, lParam ); - } - } - DPRINT("End of HWND_BROADCAST !\n"); - return TRUE; - } - - wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr || !wndPtr->hmemTaskQ) return FALSE; - - return QUEUE_AddMsg( wndPtr->hmemTaskQ, &msg, 0 ); -} - - - -/*********************************************************************** - * SendMessageW (USER.459) 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 - */ - -LRESULT STDCALL SendMessageA( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - WND *wndPtr; - - if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST) - { - return MSG_SendMessageInterTask(hwnd,msg,wParam,lParam,FALSE); - } - - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) - { - DPRINT( "invalid hwnd %08x\n", hwnd ); - return 0; - } - - if (HOOK_IsHooked( WH_CALLWNDPROC )) - MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE); - - - return MSG_SendMessage(wndPtr,msg,wParam,lParam); -} - - - -LRESULT STDCALL SendMessageW( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - WND *wndPtr; - - if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST) - { - return MSG_SendMessageInterTask(hwnd,msg,wParam,lParam,TRUE); - } - - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) - { - DPRINT( "invalid hwnd %08x\n", hwnd ); - return 0; - } - - if (HOOK_IsHooked( WH_CALLWNDPROC )) - MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE); - - - return MSG_SendMessage(wndPtr,msg,wParam,lParam); -} - -/*********************************************************************** - * TranslateMessage (USER.556) - */ -WINBOOL STDCALL TranslateMessage( const MSG *msg ) -{ - return MSG_DoTranslateMessage( msg->message, msg->hwnd, - msg->wParam, msg->lParam ); -} - -/*********************************************************************** - * DispatchMessageA (USER.141) - */ -LONG STDCALL DispatchMessageA( const MSG* msg ) -{ - WND * wndPtr; - LONG retval; - int painting; - - /* Process timer messages */ - if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER)) - { - if (msg->lParam) - { -/* HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ - return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd, - msg->message, msg->wParam, GetTickCount() ); - } - } - - if (!msg->hwnd) return 0; - if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0; - if (!wndPtr->winproc) return 0; - painting = (msg->message == WM_PAINT); - if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT; -/* HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ - - SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message, - msg->wParam, msg->lParam ); - retval = CallWindowProcA( (WNDPROC)wndPtr->winproc, - msg->hwnd, msg->message, - msg->wParam, msg->lParam ); - SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval ); - - if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) && - (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) - { - //ERR(msg, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", - // msg->hwnd); - wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; - /* Validate the update region to avoid infinite WM_PAINT loop */ - ValidateRect( msg->hwnd, NULL ); - } - return retval; -} - - -/*********************************************************************** - * DispatchMessageW (USER.142) Process Message - * - * Process the message specified in the structure *_msg_. - * - * If the lpMsg parameter points to a WM_TIMER message and the - * parameter of the WM_TIMER message is not NULL, the lParam parameter - * points to the function that is called instead of the window - * procedure. - * - * The message must be valid. - * - * RETURNS - * - * DispatchMessage() returns the result of the window procedure invoked. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -LONG STDCALL DispatchMessageW( const MSG* msg ) -{ - WND * wndPtr; - LONG retval; - int painting; - - /* Process timer messages */ - if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER)) - { - if (msg->lParam) - { -/* HOOK_CallHooksW( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ - return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd, - msg->message, msg->wParam, GetTickCount() ); - } - } - - if (!msg->hwnd) return 0; - if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0; - if (!wndPtr->winproc) return 0; - painting = (msg->message == WM_PAINT); - if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT; -/* HOOK_CallHooksW( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ - - SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message, - msg->wParam, msg->lParam ); - retval = CallWindowProcW( (WNDPROC)wndPtr->winproc, - msg->hwnd, msg->message, - msg->wParam, msg->lParam ); - SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval ); - - if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) && - (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) - { - //ERR(msg, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", - // msg->hwnd); - wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; - /* Validate the update region to avoid infinite WM_PAINT loop */ - ValidateRect( msg->hwnd, NULL ); - } - return retval; -} - - - -/********************************************************************** - * PostThreadMessageA (USER.422) - * - * BUGS - * - * Thread-local message queues are not supported. - * - */ -WINBOOL STDCALL PostThreadMessageA(DWORD idThread , UINT message, - WPARAM wParam, LPARAM lParam ) -{ - return FALSE; -} - -/********************************************************************** - * PostThreadMessageW (USER.423) - * - * BUGS - * - * Thread-local message queues are not supported. - * - */ -WINBOOL STDCALL PostThreadMessageW(DWORD idThread , UINT message, - WPARAM wParam, LPARAM lParam ) -{ - return FALSE; -} - -/*********************************************************************** - * SendMessageTimeoutA (USER.457) - */ -LRESULT STDCALL SendMessageTimeoutA( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam, UINT flags, - UINT timeout, LPDWORD resultp) -{ - // DPRINT( "(...): semistub\n"); - return SendMessageA (hwnd, msg, wParam, lParam); -} - - -/*********************************************************************** - * SendMessageTimeoutW (USER.458) - */ -LRESULT STDCALL SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam, UINT flags, - UINT timeout, LPDWORD resultp) -{ -// DPRINT( "(...): semistub\n"); - return SendMessageW (hwnd, msg, wParam, lParam); -} - - -/*********************************************************************** - * WaitMessage (USER.112) (USER.578) Suspend thread pending messages - * - * WaitMessage() suspends a thread until events appear in the thread's - * queue. - * - * BUGS - * - * Is supposed to return WINBOOL under Win. - * - * Thread-local message queues are not supported. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -WINBOOL -STDCALL -WaitMessage(VOID) -{ - QUEUE_WaitBits( QS_ALLINPUT ); - return TRUE; -} - -/*********************************************************************** - * MsgWaitForMultipleObjects (USER.400) - */ -DWORD STDCALL MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles, - WINBOOL fWaitAll, DWORD dwMilliseconds, - DWORD dwWakeMask ) -{ - -} - - -/*********************************************************************** - * RegisterWindowMessageA (USER.437) - */ -UINT -STDCALL -RegisterWindowMessageA( - LPCSTR lpString) -{ - return GlobalAddAtomA( lpString ); -} - - -/*********************************************************************** - * RegisterWindowMessageW (USER.438) - */ -UINT -STDCALL -RegisterWindowMessageW( - LPCWSTR lpString) -{ - return GlobalAddAtomW( lpString ); -} - -/*********************************************************************** - * InSendMessage (USER.0) - */ -WINBOOL STDCALL InSendMessage(void) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) - return 0; - return (WINBOOL)queue->InSendMessageHandle; -} - -/*********************************************************************** - * BroadcastSystemMessage (USER.12) - */ -LONG STDCALL BroadcastSystemMessage( - DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam, - LPARAM lParam -) { - DPRINT("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n", - dwFlags,*recipients,uMessage,wParam,lParam - ); - return 0; -} - -/*********************************************************************** - * SendNotifyMessageA (USER.460) - * FIXME - * The message sended with PostMessage has to be put in the queue - * with a higher priority as the other "Posted" messages. - * QUEUE_AddMsg has to be modifyed. - */ -WINBOOL STDCALL SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ WINBOOL ret = TRUE; - DPRINT("(%04x,%08x,%08x,%08lx) not complete\n", - hwnd, msg, wParam, lParam); - - if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL)) - { ret=SendMessageA ( hwnd, msg, wParam, lParam ); - } - else - { PostMessageA ( hwnd, msg, wParam, lParam ); - } - return ret; -} - -/*********************************************************************** - * SendNotifyMessageW (USER.461) - * FIXME - * The message sended with PostMessage has to be put in the queue - * with a higher priority as the other "Posted" messages. - * QUEUE_AddMsg has to be modifyed. - */ -WINBOOL STDCALL SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ WINBOOL ret = TRUE; - DPRINT("(%04x,%08x,%08x,%08lx) not complete\n", - hwnd, msg, wParam, lParam); - - if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL)) - { ret=SendMessageW ( hwnd, msg, wParam, lParam ); - } - else - { PostMessageW ( hwnd, msg, wParam, lParam ); - } - return ret; -} - -/*********************************************************************** - * SendMessageCallBackA - * FIXME: It's like PostMessage. The callback gets called when the message - * is processed. We have to modify the message processing for a exact - * implementation... - */ -WINBOOL -STDCALL -SendMessageCallbackA( - HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - SENDASYNCPROC lpResultCallBack, - DWORD dwData) -{ - - if ( hWnd == HWND_BROADCAST) - { PostMessageA( hWnd, Msg, wParam, lParam); - // DPRINT("Broadcast: Callback will not be called!\n"); - return TRUE; - } - (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam )); - return TRUE; -} - -WINBOOL -STDCALL -SendMessageCallbackW( - HWND hWnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam, - SENDASYNCPROC lpResultCallBack, - DWORD dwData) -{ - return FALSE; -} - -/*********************************************************************** - * ReplyMessage (USER.115) - */ -WINBOOL STDCALL ReplyMessage( LRESULT result ) -{ - MESSAGEQUEUE *senderQ; - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE*)GlobalLock( GetFastQueue() ))) return; - - DPRINT("ReplyMessage, queue %04x\n", queue->self); - - while( (senderQ = (MESSAGEQUEUE*)GlobalLock( queue->InSendMessageHandle))) - { - DPRINT("\trpm: replying to %04x (%04x -> %04x)\n", - queue->msg, queue->self, senderQ->self); - - if( queue->wakeBits & QS_SENDMESSAGE ) - { - QUEUE_ReceiveMessage( queue ); - continue; /* ReceiveMessage() already called us */ - } - - if(!(senderQ->wakeBits & QS_SMRESULT) ) break; -// if (THREAD_IsWinA(THREAD_Current())) OldYield(); - } - if( !senderQ ) { DPRINT("\trpm: done\n"); return; } - - senderQ->SendMessageReturn = result; - DPRINT("\trpm: smResult = %08x, result = %08lx\n", - (unsigned)queue->smResultCurrent, result ); - - senderQ->smResult = queue->smResultCurrent; - queue->InSendMessageHandle = 0; - - QUEUE_SetWakeBit( senderQ, QS_SMRESULT ); -// if (THREAD_IsWinA(THREAD_Current())) DirectedYield( senderQ->hTask ); -} - - - - -/*********************************************************************** - * PostQuitMessage (USER.421) - * - * PostQuitMessage() posts a message to the system requesting an - * application to terminate execution. As a result of this function, - * the WM_QUIT message is posted to the application, and - * PostQuitMessage() returns immediately. The exitCode parameter - * specifies an application-defined exit code, which appears in the - * _wParam_ parameter of the WM_QUIT message posted to the application. - * - * CONFORMANCE - * - * ECMA-234, Win - */ -void STDCALL PostQuitMessage( INT exitCode ) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) return; - queue->wPostQMsg = TRUE; - queue->wExitCode = (WORD)exitCode; -} - - - - -/*********************************************************************** - * GetWindowThreadProcessId (USER.313) - */ -DWORD STDCALL GetWindowThreadProcessId( HWND hwnd, LPDWORD process ) -{ - return 0; -} - - - - - -/*********************************************************************** - * SetMessageQueue (USER.494) - */ -WINBOOL STDCALL SetMessageQueue( INT size ) -{ - - HQUEUE hQueue, hNewQueue; - MESSAGEQUEUE *queuePtr; - - DPRINT("task %04x size %i\n", GetCurrentTask(), size); - - if ((size > MAX_QUEUE_SIZE) || (size <= 0)) return FALSE; - - if( !(hNewQueue = QUEUE_CreateMsgQueue( size ))) - { - DPRINT( "failed!\n"); - return FALSE; - } - queuePtr = (MESSAGEQUEUE *)GlobalLock( hNewQueue ); - - SIGNAL_MaskAsyncEvents( TRUE ); - - /* Copy data and free the old message queue */ - if ((hQueue = GetThreadQueue(0)) != 0) - { - MESSAGEQUEUE *oldQ = (MESSAGEQUEUE *)GlobalLock( hQueue ); - memcpy( &queuePtr->wParamHigh, &oldQ->wParamHigh, - (int)oldQ->messages - (int)(&oldQ->wParamHigh) ); - HOOK_ResetQueueHooks( hNewQueue ); - if( WIN_GetDesktop()->hmemTaskQ == hQueue ) - WIN_GetDesktop()->hmemTaskQ = hNewQueue; - WIN_ResetQueueWindows( WIN_GetDesktop(), hQueue, hNewQueue ); -// CLIPBOARD_ResetLock( hQueue, hNewQueue ); - QUEUE_DeleteMsgQueue( hQueue ); - } - - /* Link new queue into list */ - queuePtr->hTask = GetCurrentTask(); - queuePtr->next = hFirstQueue; - hFirstQueue = hNewQueue; - - if( !queuePtr->next ) pCursorQueue = queuePtr; - SetThreadQueue( 0, hNewQueue ); - - SIGNAL_MaskAsyncEvents( FALSE ); - return TRUE; - - -// win32 dynamically expands the message queue -} - - - -/*********************************************************************** - * GetQueueStatus (USER.283) - */ -DWORD STDCALL GetQueueStatus( UINT flags ) -{ - MESSAGEQUEUE *queue; - DWORD ret; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) return 0; - ret = MAKELONG( queue->changeBits, queue->wakeBits ); - queue->changeBits = 0; - return ret & MAKELONG( flags, flags ); -} - - -/*********************************************************************** - * WaitForInputIdle (USER.577) - */ -DWORD STDCALL WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut) -{ - // FIXME (msg, "(hProcess=%d, dwTimeOut=%ld): stub\n", hProcess, dwTimeOut); - - return WAIT_TIMEOUT; -} - - -/*********************************************************************** - * GetInputState (USER.244) - */ -WINBOOL STDCALL GetInputState(void) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) - return FALSE; - return queue->wakeBits & (QS_KEY | QS_MOUSEBUTTON); -} - - - -/*********************************************************************** - * GetMessagePos (USER.272) - * - * The GetMessagePos() function returns a long value representing a - * cursor position, in screen coordinates, when the last message - * retrieved by the GetMessage() function occurs. The x-coordinate is - * in the low-order word of the return value, the y-coordinate is in - * the high-order word. The application can use the MAKEPOINT() - * macro to obtain a POINT structure from the return value. - * - * For the current cursor position, use GetCursorPos(). - * - * RETURNS - * - * Cursor position of last message on success, zero on failure. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -DWORD STDCALL GetMessagePos(void) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) return 0; - return queue->GetMessagePosVal; -} - - -/*********************************************************************** - * GetMessageTime (USER.273) - * - * GetMessageTime() returns the message time for the last message - * retrieved by the function. The time is measured in milliseconds with - * the same offset as GetTickCount(). - * - * Since the tick count wraps, this is only useful for moderately short - * relative time comparisons. - * - * RETURNS - * - * Time of last message on success, zero on failure. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ -LONG STDCALL GetMessageTime(void) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) return 0; - return queue->GetMessageTimeVal; -} - - -/*********************************************************************** - * GetMessageExtraInfo (USER.271) - */ -LONG STDCALL GetMessageExtraInfo(void) -{ - MESSAGEQUEUE *queue; - - if (!(queue = (MESSAGEQUEUE *)GlobalLock( GetFastQueue() ))) return 0; - return queue->GetMessageExtraInfoVal; -} - - -LPARAM -STDCALL -SetMessageExtraInfo( - LPARAM lParam) -{ - return 0; -} - -WINBOOL STDCALL MessageBeep( UINT uType ) -{ - return Beep(uType ,0); -} - - diff --git a/reactos/lib/user32/windows/msgbox.c b/reactos/lib/user32/windows/msgbox.c deleted file mode 100644 index fa4ee296cce..00000000000 --- a/reactos/lib/user32/windows/msgbox.c +++ /dev/null @@ -1,348 +0,0 @@ -#include -#define MIN min -#define MAX max - -#define UNICODE -#include -#include -#include -#include - - -#define MB_TYPEMASK 0x0000000F -#define MB_ICONMASK 0x000000F0 -#define MB_DEFMASK 0x00000F00 - -LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam, WINBOOL bUnicode ); - -LRESULT CALLBACK MSGBOX_DlgProcA( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam ); -LRESULT CALLBACK MSGBOX_DlgProcW( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam ); - -// FIXME ????????? - /* Static text */ -#define stc1 0x0440 -/************************************************************************** - * MessageBoxA (USER.391) - * - * NOTES - * The WARN is here to help debug erroneous MessageBoxes - * Use: -debugmsg warn+dialog,+relay - */ -INT STDCALL MessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type) -{ - - return MessageBoxExA(hWnd,text,title,type,0); - -} - - -/************************************************************************** - * MessageBoxW (USER.396) - */ -INT STDCALL MessageBoxW( HWND hWnd, LPCWSTR text, LPCWSTR title, - UINT type ) -{ - return MessageBoxExW(hWnd,text,title,type,0); -} - - -/************************************************************************** - * MessageBoxExA (USER.392) - */ -INT STDCALL MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title, - UINT type, WORD langid ) -{ - MSGBOXPARAMS mbox; - HANDLE hrsrc; - HANDLE hDlgTemplate; - if (title == NULL) - title="Error"; - if (text == NULL) - text=" "; - - mbox.lpszCaption = title; - mbox.lpszText = text; - mbox.dwStyle = type; - - hrsrc = FindResourceA( NULL, "MSGBOX", RT_DIALOG ); - if (!hrsrc) return 0; - - hDlgTemplate = LockResource(LoadResource(NULL,hrsrc)); - return DialogBoxIndirectParamA( NULL, hDlgTemplate, - hWnd, MSGBOX_DlgProcA, (LPARAM)&mbox ); -} - -/************************************************************************** - * MessageBoxExW (USER.393) - */ -INT STDCALL MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title, - UINT type, WORD langid ) -{ - MSGBOXPARAMS mbox; - HANDLE hrsrc; - HANDLE hDlgTemplate; - if (title == NULL) - title=L"Error"; - if (text == NULL) - text=L" "; - - mbox.lpszCaption = title; - mbox.lpszText = text; - mbox.dwStyle = type; - - hrsrc = FindResourceW( NULL, L"MSGBOX", RT_DIALOG ); - if (!hrsrc) return 0; - - hDlgTemplate = LockResource(LoadResource(NULL,hrsrc)); - return DialogBoxIndirectParamW( NULL, - hDlgTemplate, - hWnd, MSGBOX_DlgProcW, (LPARAM)&mbox ); -} - - - -/************************************************************************** - * MessageBoxIndirectA (USER.394) - */ -INT STDCALL MessageBoxIndirectA( LPMSGBOXPARAMS msgbox ) -{ - HANDLE hrsrc = FindResourceA( NULL, "MSGBOX", RT_DIALOG ); - HANDLE hDlgTemplate; - if (!hrsrc) return 0; - hDlgTemplate = LockResource(LoadResource(NULL,hrsrc)); - return DialogBoxIndirectParamA( msgbox->hInstance, - hDlgTemplate, - msgbox->hwndOwner, MSGBOX_DlgProcA, - (LPARAM)msgbox ); -} - -/************************************************************************** - * MessageBoxIndirectW (USER.395) - */ -INT STDCALL MessageBoxIndirectW( LPMSGBOXPARAMS msgbox ) -{ - - HANDLE hrsrc = FindResourceW( NULL, L"MSGBOX", RT_DIALOG ); - HANDLE hDlgTemplate; - if (!hrsrc) return 0; - hDlgTemplate = LockResource(LoadResource(NULL,hrsrc)); - return DialogBoxIndirectParamW( msgbox->hInstance, - hDlgTemplate, - msgbox->hwndOwner, MSGBOX_DlgProcW, - (LPARAM)msgbox ); -} - -/************************************************************************** - * MSGBOX_DlgProc - * - * Dialog procedure for message boxes. - */ -LRESULT CALLBACK MSGBOX_DlgProcA( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam ) -{ - return MSGBOX_DlgProc(hwnd,message,wParam,lParam,FALSE); -} - -LRESULT CALLBACK MSGBOX_DlgProcW( HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam ) -{ - return MSGBOX_DlgProc(hwnd,message,wParam,lParam,TRUE); -} - -LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam, WINBOOL bUnicode ) -{ - static HFONT hFont = 0; - LPMSGBOXPARAMS lpmb; - - RECT rect, textrect; - HWND hItem; - HDC hdc; - LRESULT lRet; - int i, buttons, bwidth, bheight, theight, wwidth, bpos; - int borheight, iheight, tiheight; - - - switch(message) { - case WM_INITDIALOG: - lpmb = (LPMSGBOXPARAMS)lParam; - - if (TWEAK_WineLook >= WIN95_LOOK) { - NONCLIENTMETRICS nclm; - INT i; - nclm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); - hFont = CreateFontIndirect (&nclm.lfMessageFont); - /* set button font */ - for (i=1; i < 8; i++) - SendDlgItemMessage (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0); - /* set text font */ - SendDlgItemMessage (hwnd, 100, WM_SETFONT, (WPARAM)hFont, 0); - } - - - - - if ( bUnicode == TRUE ) { - if (lpmb->lpszCaption) - SetWindowTextW(hwnd, (LPCWSTR)lpmb->lpszCaption); - SetWindowTextW(GetDlgItem(hwnd, 100),(LPWSTR) lpmb->lpszText); - } else { - if (lpmb->lpszCaption) - SetWindowTextA(hwnd, lpmb->lpszCaption); - SetWindowTextA(GetDlgItem(hwnd, 100), lpmb->lpszText); - } - /* Hide not selected buttons */ - switch(lpmb->dwStyle & MB_TYPEMASK) { - case MB_OK: - ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); - /* fall through */ - case MB_OKCANCEL: - ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE); - break; - case MB_ABORTRETRYIGNORE: - ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE); - break; - case MB_YESNO: - ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); - /* fall through */ - case MB_YESNOCANCEL: - ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE); - ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE); - break; - } - /* Set the icon */ - switch(lpmb->dwStyle & MB_ICONMASK) { - case MB_ICONEXCLAMATION: - SendDlgItemMessage(hwnd, stc1, STM_SETICON, - (WPARAM)LoadIcon(0, IDI_EXCLAMATION), 0); - break; - case MB_ICONQUESTION: - SendDlgItemMessage(hwnd, stc1, STM_SETICON, - (WPARAM)LoadIcon(0, IDI_QUESTION), 0); - break; - case MB_ICONASTERISK: - SendDlgItemMessage(hwnd, stc1, STM_SETICON, - (WPARAM)LoadIcon(0, IDI_ASTERISK), 0); - break; - case MB_ICONHAND: - default: - SendDlgItemMessage(hwnd, stc1, STM_SETICON, - (WPARAM)LoadIcon(0, IDI_HAND), 0); - break; - } - - /* Position everything */ - GetWindowRect(hwnd, &rect); - borheight = rect.bottom - rect.top; - wwidth = rect.right - rect.left; - GetClientRect(hwnd, &rect); - borheight -= rect.bottom - rect.top; - - /* Get the icon height */ - GetWindowRect(GetDlgItem(hwnd, 1088), &rect); - iheight = rect.bottom - rect.top; - - /* Get the number of visible buttons and their width */ - GetWindowRect(GetDlgItem(hwnd, 2), &rect); - bheight = rect.bottom - rect.top; - bwidth = rect.left; - GetWindowRect(GetDlgItem(hwnd, 1), &rect); - bwidth -= rect.left; - for (buttons = 0, i = 1; i < 8; i++) - { - hItem = GetDlgItem(hwnd, i); - if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE) - buttons++; - } - - /* Get the text size */ - hItem = GetDlgItem(hwnd, 100); - GetWindowRect(hItem, &textrect); - MapWindowPoints(0, hwnd, (LPPOINT)&textrect, 2); - - GetClientRect(hItem, &rect); - hdc = GetDC(hItem); - - - if ( bUnicode ) - lRet = DrawTextW( hdc, (LPCWSTR)lpmb->lpszText, -1, &rect, - DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); - else - lRet = DrawTextA( hdc, lpmb->lpszText, -1, &rect, - DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); - theight = rect.bottom - rect.top; - tiheight = 16 + MAX(iheight, theight); - ReleaseDC(hItem, hdc); - - /* Position the text */ - SetWindowPos(hItem, 0, textrect.left, (tiheight - theight) / 2, - rect.right - rect.left, theight, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); - - /* Position the icon */ - hItem = GetDlgItem(hwnd, 1088); - GetWindowRect(hItem, &rect); - MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2); - SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); - - /* Resize the window */ - SetWindowPos(hwnd, 0, 0, 0, wwidth, 8 + tiheight + bheight + borheight, - SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); - - /* Position the buttons */ - bpos = (wwidth - bwidth * buttons) / 2; - GetWindowRect(GetDlgItem(hwnd, 1), &rect); - for (buttons = i = 0; i < 7; i++) { - /* some arithmetic to get the right order for YesNoCancel windows */ - hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1); - if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE) { - if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) { - SetFocus(hItem); - SendMessage( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE ); - } - SetWindowPos(hItem, 0, bpos, tiheight, 0, 0, - SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW); - bpos += bwidth; - } - } - return 0; - break; - - case WM_COMMAND: - switch (wParam) - { - case IDOK: - case IDCANCEL: - case IDABORT: - case IDRETRY: - case IDIGNORE: - case IDYES: - case IDNO: - if ( hFont) - DeleteObject (hFont); - EndDialog(hwnd, wParam); - break; - } - - default: - break; - } - return 0; -} - - - - diff --git a/reactos/lib/user32/windows/paint.c b/reactos/lib/user32/windows/paint.c deleted file mode 100644 index 5ca7eefb521..00000000000 --- a/reactos/lib/user32/windows/paint.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Window painting functions - * - * Copyright 1993, 1994, 1995 Alexandre Julliard - * - * FIXME: Do not repaint full nonclient area all the time. Instead, compute - * intersection with hrgnUpdate (which should be moved from client to - * window coords as well, lookup 'the pain' comment in the winpos.c). - */ -#include -#include -#include -#include -#include -#include - - - /* Last CTLCOLOR id */ -//#define CTLCOLOR_MAX CTLCOLOR_STATIC - - - - - -HDC -STDCALL -BeginPaint( - HWND hWnd, - LPPAINTSTRUCT lpPaint) -{ - WINBOOL bIcon; - HRGN hrgnUpdate; - WND *wndPtr = WIN_FindWndPtr( hWnd ); - if (!wndPtr) return 0; - - bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon); - - wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; - - if (wndPtr->flags & WIN_NEEDS_NCPAINT) WIN_UpdateNCArea( wndPtr, TRUE ); - - if (((hrgnUpdate = wndPtr->hrgnUpdate) != 0) || - (wndPtr->flags & WIN_INTERNAL_PAINT)) - QUEUE_DecPaintCount( wndPtr->hmemTaskQ ); - - wndPtr->hrgnUpdate = 0; - wndPtr->flags &= ~WIN_INTERNAL_PAINT; - - HideCaret( hWnd ); - - DPRINT("hrgnUpdate = %04x, \n", hrgnUpdate); - - /* When bIcon is TRUE hrgnUpdate is automatically in window coordinates - * (because rectClient == rectWindow for WS_MINIMIZE windows). - */ - - if (wndPtr->class->style & CS_PARENTDC) - { - /* Don't clip the output to the update region for CS_PARENTDC window */ - if(hrgnUpdate > (HRGN)1) - DeleteObject(hrgnUpdate); - lpPaint->hdc = GetDCEx( hWnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE | - (bIcon ? DCX_WINDOW : 0) ); - } - else - { - lpPaint->hdc = GetDCEx(hWnd, hrgnUpdate, DCX_INTERSECTRGN | - DCX_WINDOWPAINT | DCX_USESTYLE | - (bIcon ? DCX_WINDOW : 0) ); - } - - DPRINT("hdc = %04x\n", lpPaint->hdc); - - if (!lpPaint->hdc) - { - //WARN(win, "GetDCEx() failed in BeginPaint(), hWnd=%04x\n", hWnd); - return 0; - } - - GetClipBox( lpPaint->hdc, &lpPaint->rcPaint ); - - DPRINT("box = (%i,%i - %i,%i)\n", lpPaint->rcPaint.left, lpPaint->rcPaint.top, - lpPaint->rcPaint.right, lpPaint->rcPaint.bottom ); - - if (wndPtr->flags & WIN_NEEDS_ERASEBKGND) - { - wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND; - lpPaint->fErase = !SendMessageA(hWnd, (bIcon) ? WM_ICONERASEBKGND - : WM_ERASEBKGND, - (WPARAM)lpPaint->hdc, 0 ); - } - else lpPaint->fErase = TRUE; - - return lpPaint->hdc; - -} - - -WINBOOL STDCALL EndPaint( HWND hWnd, const PAINTSTRUCT *lpPaint ) -{ - ReleaseDC( hWnd, lpPaint->hdc ); - ShowCaret( hWnd ); - return TRUE; -} - -/*********************************************************************** - * RedrawWindow (USER32.426) - */ -WINBOOL STDCALL RedrawWindow( HWND hwnd, const RECT *rectUpdate, - HRGN hrgnUpdate, UINT flags ) -{ - return PAINT_RedrawWindow( hwnd, rectUpdate, hrgnUpdate, flags, 0 ); -} - -/*********************************************************************** - * UpdateWindow (USER32.567) - */ -WINBOOL -STDCALL -UpdateWindow( - HWND hWnd) -{ - return PAINT_RedrawWindow( hWnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN, 0 ); -} - -/*********************************************************************** - * InvalidateRgn (USER32.9) - */ -WINBOOL -STDCALL -InvalidateRgn( - HWND hWnd, - HRGN hRgn, - WINBOOL bErase) -{ - return PAINT_RedrawWindow(hWnd, NULL, hRgn, RDW_INVALIDATE | (bErase ? RDW_ERASE : 0), 0 ); -} - -/*********************************************************************** - * InvalidateRect (USER32.8) - */ -WINBOOL -STDCALL -InvalidateRect( - HWND hWnd , - CONST RECT *lpRect, - WINBOOL bErase) -{ - return PAINT_RedrawWindow( hWnd, lpRect, 0, - RDW_INVALIDATE | (bErase ? RDW_ERASE : 0), 0 ); -} - -/*********************************************************************** - * ValidateRgn (USER32.572) - */ -WINBOOL -STDCALL -ValidateRgn( - HWND hWnd, - HRGN hRgn) -{ - return PAINT_RedrawWindow( hWnd, NULL, hRgn, RDW_VALIDATE | RDW_NOCHILDREN, 0 ); -} - -/*********************************************************************** - * ValidateRect (USER32.571) - */ -WINBOOL -STDCALL -ValidateRect( - HWND hWnd , - CONST RECT *lpRect) -{ - return PAINT_RedrawWindow( hWnd, lpRect, 0, RDW_VALIDATE | RDW_NOCHILDREN, 0 ); -} - -/*********************************************************************** - * GetUpdateRect (USER32.297) - */ -WINBOOL STDCALL GetUpdateRect( HWND hwnd, LPRECT rect, WINBOOL erase ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return FALSE; - - if (rect) - { - if (wndPtr->hrgnUpdate > (HRGN)1) - { - HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); - if (GetUpdateRgn( hwnd, hrgn, erase ) == ERROR) return FALSE; - GetRgnBox( hrgn, rect ); - DeleteObject( hrgn ); - } - else SetRectEmpty( rect ); - } - return ((UINT)wndPtr->hrgnUpdate > 1); -} - -/*********************************************************************** - * GetUpdateRgn (USER32.298) - */ -INT STDCALL GetUpdateRgn( HWND hwnd, HRGN hrgn, WINBOOL erase ) -{ - INT retval; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return ERROR; - - if ((UINT)wndPtr->hrgnUpdate <= 1) - { - SetRectRgn( hrgn, 0, 0, 0, 0 ); - return NULLREGION; - } - retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY ); - if (erase) RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN ); - return retval; -} - -int -STDCALL -SetWindowRgn( - HWND hWnd, - HRGN hRgn, - WINBOOL bRedraw) -{ - return 0; -} - -int -STDCALL -GetWindowRgn( - HWND hWnd, - HRGN hRgn) -{ - return 0; -} - -/*********************************************************************** - * ExcludeUpdateRgn (USER32.195) - */ -INT STDCALL ExcludeUpdateRgn( HDC hdc, HWND hwnd ) -{ - RECT rect; - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return ERROR; - - if (wndPtr->hrgnUpdate) - { - INT ret; - HRGN hrgn = CreateRectRgn(wndPtr->rectWindow.left - wndPtr->rectClient.left, - wndPtr->rectWindow.top - wndPtr->rectClient.top, - wndPtr->rectClient.right - wndPtr->rectClient.left, - wndPtr->rectClient.bottom - wndPtr->rectClient.top); - if( wndPtr->hrgnUpdate > (HRGN)1 ) - CombineRgn(hrgn, wndPtr->hrgnUpdate, 0, RGN_COPY); - - /* do ugly coordinate translations in dce.c */ - - ret = DCE_ExcludeRgn( hdc, wndPtr, hrgn ); - DeleteObject( hrgn ); - return ret; - } - return GetClipBox( hdc, &rect ); -} - - diff --git a/reactos/lib/user32/windows/property.c b/reactos/lib/user32/windows/property.c deleted file mode 100644 index b9adb4c24ec..00000000000 --- a/reactos/lib/user32/windows/property.c +++ /dev/null @@ -1,318 +0,0 @@ -#include -#include -#include -#include - -//TODO user Wide Character functions as basis - - -/* - * Window properties - * - * Copyright 1995, 1996 Alexandre Julliard - */ - -/*********************************************************************** - * PROP_FindProp - */ -static PROPERTY *PROP_FindProp( HWND hwnd, LPCSTR str ) -{ - ATOM atom; - PROPERTY *prop; - WND *pWnd = WIN_FindWndPtr( hwnd ); - - if (!pWnd) return NULL; - if (HIWORD(str)) - { - atom = GlobalFindAtomA( str ); - for (prop = pWnd->pProp; prop; prop = prop->next) - { - if (HIWORD(prop->string)) - { - if (!lstrcmpiA( prop->string, str )) goto END; - } - else if (LOWORD(prop->string) == atom) goto END; - } - } - else /* atom */ - { - atom = LOWORD(str); - for (prop = pWnd->pProp; (prop); prop = prop->next) - { - if (HIWORD(prop->string)) - { - if (GlobalFindAtomA( prop->string ) == atom) goto END; - } - else if (LOWORD(prop->string) == atom) goto END; - } - } - prop = NULL; -END: - WIN_ReleaseWndPtr(pWnd); - return prop; -} - - -/*********************************************************************** - * GetProp32A (USER32.281) - */ -HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str ) -{ - PROPERTY *prop = PROP_FindProp( hwnd, str ); - - if (HIWORD(str)) - DPRINT("(%08x,'%s'): returning %08x\n", - hwnd, str, prop ? prop->handle : 0 ); - else - DPRINT("(%08x,#%04x): returning %08x\n", - hwnd, LOWORD(str), prop ? prop->handle : 0 ); - - return prop ? prop->handle : 0; -} - - -/*********************************************************************** - * GetProp32W (USER32.282) - */ -HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str ) -{ - LPSTR strA; - HANDLE ret; - - if (!HIWORD(str)) return GetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str) ); - strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str ); - ret = GetPropA( hwnd, strA ); - HeapFree( GetProcessHeap(), 0, strA ); - return ret; -} - - - -/*********************************************************************** - * SetProp32A (USER32.497) - */ -BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle ) -{ - PROPERTY *prop; - - if (HIWORD(str)) - DPRINT("%04x '%s' %08x\n", hwnd, str, handle ); - else - DPRINT("%04x #%04x %08x\n", - hwnd, LOWORD(str), handle ); - - if (!(prop = PROP_FindProp( hwnd, str ))) - { - /* We need to create it */ - WND *pWnd = WIN_FindWndPtr( hwnd ); - if (!pWnd) return FALSE; - if (!(prop = HeapAlloc( GetProcessHeap(), 0, sizeof(*prop) ))) - { - WIN_ReleaseWndPtr(pWnd); - return FALSE; - } - if (!(prop->string = HEAP_strdupA(GetProcessHeap(),0,str))) - { - HeapFree( GetProcessHeap(), 0, prop ); - WIN_ReleaseWndPtr(pWnd); - return FALSE; - - } - prop->next = pWnd->pProp; - pWnd->pProp = prop; - WIN_ReleaseWndPtr(pWnd); - } - prop->handle = handle; - return TRUE; -} - - -/*********************************************************************** - * SetProp32W (USER32.498) - */ -BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle ) -{ - BOOL ret; - LPSTR strA; - - if (!HIWORD(str)) - return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle ); - strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str ); - ret = SetPropA( hwnd, strA, handle ); - HeapFree( GetProcessHeap(), 0, strA ); - return ret; -} - - - - -/*********************************************************************** - * RemoveProp32A (USER32.442) - */ -HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str ) -{ - ATOM atom; - HANDLE handle; - PROPERTY **pprop, *prop; - WND *pWnd = WIN_FindWndPtr( hwnd ); - - if (HIWORD(str)) - DPRINT("%04x '%s'\n", hwnd, str ); - else - DPRINT("%04x #%04x\n", hwnd, LOWORD(str)); - - - if (!pWnd) return (HANDLE)0; - if (HIWORD(str)) - { - atom = GlobalFindAtomA( str ); - for (pprop=(PROPERTY**)&pWnd->pProp; (*pprop); pprop = &(*pprop)->next) - { - if (HIWORD((*pprop)->string)) - { - if (!lstrcmpiA( (*pprop)->string, str )) break; - } - else if (LOWORD((*pprop)->string) == atom) break; - } - } - else /* atom */ - { - atom = LOWORD(str); - for (pprop=(PROPERTY**)&pWnd->pProp; (*pprop); pprop = &(*pprop)->next) - { - if (HIWORD((*pprop)->string)) - { - if (GlobalFindAtomA( (*pprop)->string ) == atom) break; - } - else if (LOWORD((*pprop)->string) == atom) break; - } - } - WIN_ReleaseWndPtr(pWnd); - if (!*pprop) return 0; - prop = *pprop; - handle = prop->handle; - *pprop = prop->next; - HeapFree( GetProcessHeap(), 0, prop->string); - HeapFree( GetProcessHeap(), 0, prop ); - return handle; -} - - -/*********************************************************************** - * RemoveProp32W (USER32.443) - */ -HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str ) -{ - LPSTR strA; - HANDLE ret; - - if (!HIWORD(str)) - return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) ); - strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str ); - ret = RemovePropA( hwnd, strA ); - HeapFree( GetProcessHeap(), 0, strA ); - return ret; -} - - -/*********************************************************************** - * PROPERTY_RemoveWindowProps - * - * Remove all properties of a window. - */ -void PROPERTY_RemoveWindowProps( WND *pWnd ) -{ - PROPERTY *prop, *next; - - for (prop = pWnd->pProp; (prop); prop = next) - { - next = prop->next; - HeapFree( GetProcessHeap(), 0, prop->string ); - HeapFree( GetProcessHeap(), 0, prop ); - } - pWnd->pProp = NULL; -} - - - - -/*********************************************************************** - * EnumProps32A (USER32.186) - */ -INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROC func ) -{ - return EnumPropsExA( hwnd, (PROPENUMPROCEX)func, 0 ); -} - - -/*********************************************************************** - * EnumProps32W (USER32.189) - */ -INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROC func ) -{ - return EnumPropsExW( hwnd, (PROPENUMPROCEX)func, 0 ); -} - - -/*********************************************************************** - * EnumPropsEx32A (USER32.187) - */ -INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEX func, LPARAM lParam) -{ - PROPERTY *prop, *next; - WND *pWnd; - INT ret = -1; - - DPRINT("%04x %08x %08lx\n", - hwnd, (UINT)func, lParam ); - if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1; - for (prop = pWnd->pProp; (prop); prop = next) - { - /* Already get the next in case the callback */ - /* function removes the current property. */ - next = prop->next; - - DPRINT(" Callback: handle=%08x str='%s'\n", - prop->handle, prop->string ); - ret = func( hwnd, prop->string, prop->handle, lParam ); - if (!ret) break; - } - WIN_ReleaseWndPtr(pWnd); - return ret; -} - - -/*********************************************************************** - * EnumPropsEx32W (USER32.188) - */ -INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEX func, LPARAM lParam) -{ - PROPERTY *prop, *next; - WND *pWnd; - INT ret = -1; - - DPRINT("%04x %08x %08lx\n", - hwnd, (UINT)func, lParam ); - if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1; - for (prop = pWnd->pProp; (prop); prop = next) - { - /* Already get the next in case the callback */ - /* function removes the current property. */ - next = prop->next; - - DPRINT(" Callback: handle=%08x str='%s'\n", - prop->handle, prop->string ); - if (HIWORD(prop->string)) - { - LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, prop->string ); - ret = func( hwnd, str, prop->handle, lParam ); - HeapFree( GetProcessHeap(), 0, str ); - } - else - ret = func( hwnd, (LPCWSTR)(UINT)LOWORD( prop->string ), - prop->handle, lParam ); - if (!ret) break; - } - WIN_ReleaseWndPtr(pWnd); - return ret; -} diff --git a/reactos/lib/user32/windows/queue.c b/reactos/lib/user32/windows/queue.c deleted file mode 100644 index a123969f444..00000000000 --- a/reactos/lib/user32/windows/queue.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -#include - - - diff --git a/reactos/lib/user32/windows/rect.c b/reactos/lib/user32/windows/rect.c deleted file mode 100644 index 6a42504a790..00000000000 --- a/reactos/lib/user32/windows/rect.c +++ /dev/null @@ -1,67 +0,0 @@ -#include -#define MIN min -#define MAX max - -#include -#include - -WINBOOL -STDCALL -AdjustWindowRect( LPRECT lpRect, DWORD dwStyle, WINBOOL bMenu ) -{ - return AdjustWindowRectEx( lpRect, dwStyle, bMenu, 0 ); -} - - - -WINBOOL -STDCALL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, WINBOOL bMenu, DWORD dwExStyle) -{ - /* Correct the window style */ - - if (!(dwStyle & (WS_POPUP | WS_CHILD))) /* Overlapped window */ - dwStyle |= WS_CAPTION; - dwStyle &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD); - dwExStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | - WS_EX_STATICEDGE | WS_EX_TOOLWINDOW); - if (dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; - - if (TWEAK_WineLook == WIN31_LOOK) - NC_AdjustRect( lpRect, dwStyle, bMenu, dwExStyle ); - else { - NC_AdjustRectOuter95( lpRect, dwStyle, bMenu, dwExStyle ); - NC_AdjustRectInner95( lpRect, dwStyle, dwExStyle ); - } - - return TRUE; -} - - -WINBOOL STDCALL GetWindowRect( HWND hwnd, LPRECT rect ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return FALSE; - - *rect = wndPtr->rectWindow; - if (wndPtr->dwStyle & WS_CHILD ) - MapWindowPoints( wndPtr->parent->hwndSelf, 0, (POINT *)rect, 2 ); - return TRUE; -} - - -WINBOOL -STDCALL -GetClientRect(HWND hWnd, LPRECT lpRect) -{ - WND * wndPtr = WIN_FindWndPtr( hWnd ); - if ( wndPtr == NULL || 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; -} diff --git a/reactos/lib/user32/windows/scroll.c b/reactos/lib/user32/windows/scroll.c deleted file mode 100644 index 1ff13bae374..00000000000 --- a/reactos/lib/user32/windows/scroll.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Scroll windows and DCs - * - * Copyright David W. Metcalfe, 1993 - * Alex Korobka 1995,1996 - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - - - -/************************************************************************* - * ScrollWindow (USER.450) - * - * FIXME: verify clipping region calculations - */ -WINBOOL STDCALL ScrollWindow( HWND hwnd, INT dx, INT dy, - const RECT *rect, const RECT *clipRect ) -{ - HDC hdc; - HRGN hrgnUpdate,hrgnClip; - RECT rc, cliprc; - HWND hCaretWnd = CARET_GetHwnd(); - WND* wndScroll = WIN_FindWndPtr( hwnd ); - - - if ( !wndScroll || !WIN_IsWindowDrawable( wndScroll, TRUE ) ) return TRUE; - - if ( !rect ) /* do not clip children */ - { - GetClientRect(hwnd, &rc); - hrgnClip = CreateRectRgnIndirect( &rc ); - - if ((hCaretWnd == hwnd) || IsChild(hwnd,hCaretWnd)) - HideCaret(hCaretWnd); - else hCaretWnd = 0; - - hdc = GetDCEx(hwnd, hrgnClip, DCX_CACHE | DCX_CLIPSIBLINGS); - DeleteObject( hrgnClip ); - } - else /* clip children */ - { - CopyRect(&rc, rect); - - if (hCaretWnd == hwnd) HideCaret(hCaretWnd); - else hCaretWnd = 0; - - hdc = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE ); - } - - if (clipRect == NULL) - GetClientRect(hwnd, &cliprc); - else - CopyRect(&cliprc, clipRect); - - hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 ); - ScrollDC( hdc, dx, dy, &rc, &cliprc, hrgnUpdate, NULL ); - ReleaseDC(hwnd, hdc); - - if( !rect ) /* move child windows and update region */ - { - WND* wndPtr; - - if( wndScroll->hrgnUpdate > 1 ) - OffsetRgn( wndScroll->hrgnUpdate, dx, dy ); - - for (wndPtr = wndScroll->child; wndPtr; wndPtr = wndPtr->next) - SetWindowPos(wndPtr->hwndSelf, 0, wndPtr->rectWindow.left + dx, - wndPtr->rectWindow.top + dy, 0,0, SWP_NOZORDER | - SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | - SWP_DEFERERASE ); - } - - PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_ALLCHILDREN | - RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW, RDW_C_USEHRGN ); - - DeleteObject( hrgnUpdate ); - if( hCaretWnd ) - { - POINT pt; - GetCaretPos(&pt); - pt.x += dx; pt.y += dy; - SetCaretPos(pt.x, pt.y); - ShowCaret(hCaretWnd); - } - return TRUE; -} - - - - - -/************************************************************************* - * ScrollDC (USER.449) - * - * Both 'rc' and 'prLClip' are in logical units but update info is - * returned in device coordinates. - */ -WINBOOL STDCALL ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc, - const RECT *prLClip, HRGN hrgnUpdate, - LPRECT rcUpdate ) -{ - - - 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 */ - - if ( rc ) - rClip = *rc; - else /* maybe we should just return FALSE? */ - GetClipBox( hdc, &rClip ); - - if (prLClip) - IntersectRect(&rClip,&rClip,prLClip); - - if( rClip.left >= rClip.right || rClip.top >= rClip.bottom ) - { - return FALSE; - } - - - /// IntersectVisRect( hdc, rClip.left, rClip.top, - // rClip.right, rClip.bottom ); - - - /* translate coordinates */ - - - ldx = dx * wndExt.cx / vportExt.cx; - ldy = dy * wndExt.cy / vportExt.cy; - - if (dx > 0) - dest.x = (src.x = rClip.left) + ldx; - else - src.x = (dest.x = rClip.left) - ldx; - - if (dy > 0) - dest.y = (src.y = rClip.top) + ldy; - else - src.y = (dest.y = rClip.top) - ldy; - - /* copy bits */ - - if( rClip.right - rClip.left > ldx && - rClip.bottom - rClip.top > ldy ) - { - ldx = rClip.right - rClip.left - ldx; - ldy = rClip.bottom - rClip.top - ldy; - - if (!BitBlt( hdc, dest.x, dest.y, ldx, ldy, - hdc, src.x, src.y, SRCCOPY)) - { - return FALSE; - } - } - - /* restore clipping region */ - - SelectClipRgn( hdc,NULL ); - - - /* compute update areas */ - - //&& dc->w.hVisRgn - if ( (hrgnUpdate || rcUpdate) ) - { - HRGN hrgn = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 ); - HRGN hrgnClip; - - //LPtoDP( hdc, (LPPOINT)&rClip, 2 ); - OffsetRect( &rClip, DCOrg.x, DCOrg.y ); - hrgnClip = CreateRectRgnIndirect( &rClip ); - - //CombineRgn( hrgn, dc->w.hVisRgn, hrgnClip, RGN_AND ); - OffsetRgn( hrgn, dx, dy ); - //CombineRgn( hrgn, dc->w.hVisRgn, hrgn, RGN_DIFF ); - CombineRgn( hrgn, hrgn, hrgnClip, RGN_AND ); - OffsetRgn( hrgn, -DCOrg.x, -DCOrg.y ); - - if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate ); - - if (!hrgnUpdate) DeleteObject( hrgn ); - DeleteObject( hrgnClip ); - } - - return TRUE; -} - - - - - -/************************************************************************* - * ScrollWindowEx (USER.451) - * - * NOTE: Use this function instead of ScrollWindow - */ -INT STDCALL ScrollWindowEx( HWND hwnd, INT dx, INT dy, - const RECT *rect, const RECT *clipRect, - HRGN hrgnUpdate, LPRECT rcUpdate, - UINT flags ) -{ - INT retVal = NULLREGION; - WINBOOL bCaret = FALSE, bOwnRgn = TRUE; - RECT rc, cliprc; - WND* wnd = WIN_FindWndPtr( hwnd ); - - if( !wnd || !WIN_IsWindowDrawable( wnd, TRUE )) return ERROR; - - if (rect == NULL) GetClientRect(hwnd, &rc); - else rc = *rect; - - if (clipRect) IntersectRect(&cliprc,&rc,clipRect); - else cliprc = rc; - - if (!IsRectEmpty(&cliprc) && (dx || dy)) - { - - HDC hDC; - WINBOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE)); - HRGN hrgnClip = CreateRectRgnIndirect(&cliprc); - - - rc = cliprc; - bCaret = SCROLL_FixCaret(hwnd, &rc, flags); - - if( hrgnUpdate ) bOwnRgn = FALSE; - else if( bUpdate ) hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 ); - - hDC = GetDCEx( hwnd, hrgnClip, DCX_CACHE | DCX_USESTYLE | - ((flags & SW_SCROLLCHILDREN) ? DCX_NOCLIPCHILDREN : 0) ); - if( hDC != NULL) - { - -#if 0 - if( dc->w.hVisRgn && bUpdate ) - { - OffsetRgn( hrgnClip, dc->w.DCOrgX, dc->w.DCOrgY ); - CombineRgn( hrgnUpdate, dc->w.hVisRgn, hrgnClip, RGN_AND ); - OffsetRgn( hrgnUpdate, dx, dy ); - CombineRgn( hrgnUpdate, dc->w.hVisRgn, hrgnUpdate, RGN_DIFF ); - CombineRgn( hrgnUpdate, hrgnUpdate, hrgnClip, RGN_AND ); - OffsetRgn( hrgnUpdate, -dc->w.DCOrgX, -dc->w.DCOrgY ); - - if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate ); - } -#endif - ReleaseDC(hwnd, hDC); - - } - - if( wnd->hrgnUpdate > 1 ) - { - if( rect || clipRect ) - { - if( (CombineRgn( hrgnClip, hrgnClip, - wnd->hrgnUpdate, RGN_AND ) != NULLREGION) ) - { - CombineRgn( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_DIFF ); - OffsetRgn( hrgnClip, dx, dy ); - CombineRgn( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_OR ); - } - } - else - OffsetRgn( wnd->hrgnUpdate, dx, dy ); - } - - if( flags & SW_SCROLLCHILDREN ) - { - RECT r; - WND* w; - for( w = wnd->child; w; w = w->next ) - { - - if( !clipRect || IntersectRect(&w->rectWindow, &r, &cliprc) ) - SetWindowPos(w->hwndSelf, 0, w->rectWindow.left + dx, - w->rectWindow.top + dy, 0,0, SWP_NOZORDER | - SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | - SWP_DEFERERASE ); - } - } - - if( flags & (SW_INVALIDATE | SW_ERASE) ) - PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | - ((flags & SW_ERASE) ? RDW_ERASENOW : 0) | ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0 ), 0 ); - - if( bCaret ) - { - SetCaretPos( rc.left + dx, rc.top + dy ); - ShowCaret(0); - } - - if( bOwnRgn && hrgnUpdate ) DeleteObject( hrgnUpdate ); - DeleteObject( hrgnClip ); - } - return retVal; -} - - diff --git a/reactos/lib/user32/windows/spy.c b/reactos/lib/user32/windows/spy.c deleted file mode 100644 index d76dd5c817c..00000000000 --- a/reactos/lib/user32/windows/spy.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -int SPY_EnterMessage( UINT id, HWND hwnd, UINT msg, WPARAM wParam,LPARAM lParam ) -{ -} - -int SPY_ExitMessage( UINT id, HWND hwnd, UINT msg, LRESULT res ) -{ -} - -const char *SPY_GetMsgName( UINT msg ) -{ -} \ No newline at end of file diff --git a/reactos/lib/user32/windows/timer.c b/reactos/lib/user32/windows/timer.c deleted file mode 100644 index 6d204d31ba7..00000000000 --- a/reactos/lib/user32/windows/timer.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -UINT STDCALL SetTimer( HWND hWnd,UINT nIDEvent, - UINT uElapse, TIMERPROC lpTimerFunc - ) -{ - return 0; -} - -WINBOOL STDCALL KillTimer(HWND hWnd, UINT uIDEvent ) -{ - return FALSE; -} \ No newline at end of file diff --git a/reactos/lib/user32/windows/win.c b/reactos/lib/user32/windows/win.c deleted file mode 100644 index 5eec3da2046..00000000000 --- a/reactos/lib/user32/windows/win.c +++ /dev/null @@ -1,618 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// change style on WS_OVERLAPPEDWINDOW - -#undef CreateWindowA -HWND STDCALL CreateWindowA(LPCSTR lpClassName, LPCSTR lpWindowName, - DWORD dwStyle,int x, int y, - int nWidth, int nHeight, HWND hWndParent, - HMENU hMenu, HANDLE hInstance, - LPVOID lpParam ) -{ - return CreateWindowExA( 0, lpClassName, lpWindowName, dwStyle,x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam ); -} - -#undef CreateWindowW -HWND STDCALL CreateWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName, - DWORD dwStyle,int x, int y, - int nWidth, int nHeight, HWND hWndParent, - HMENU hMenu, HANDLE hInstance, - LPVOID lpParam ) -{ - return CreateWindowExW( 0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam ); -} - -HWND STDCALL CreateWindowExA( DWORD exStyle, LPCSTR lpClassName, - LPCSTR lpWindowName, DWORD style, INT x, - INT y, INT width, INT height, - HWND parent, HMENU menu, - HINSTANCE hInstance, LPVOID data ) -{ - - CREATESTRUCT cs; - CLASS *p; - DWORD status; - -// int i; - - - p = CLASS_FindClassByAtom( STRING2ATOMA(lpClassName), hInstance ); - if ( p == NULL ) - return NULL; - - - //if(exStyle & WS_EX_MDICHILD) - // return MDI_CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, data); - - - - - if ( style == WS_OVERLAPPEDWINDOW ) - style |= (WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |WS_MAXIMIZEBOX ); - - - /* Create the window */ - - cs.lpCreateParams = data; - cs.hInstance = hInstance; - cs.hMenu = menu; - cs.hwndParent = parent; - cs.x = x; - cs.y = y; - cs.cx = width; - cs.cy = height; - cs.style = style; - cs.lpszName = (LPWSTR)lpWindowName; - cs.dwExStyle = exStyle; - - - - return WIN_CreateWindowEx( &cs, p->atomName ); - -} - - -HWND STDCALL CreateWindowExW( DWORD exStyle, LPCWSTR lpClassName, - LPCWSTR windowName, DWORD style, INT x, - INT y, INT width, INT height, - HWND parent, HMENU menu, - HINSTANCE hInstance, LPVOID data ) -{ - CLASS *p; - DWORD status; - CREATESTRUCT cs; - - - - p = CLASS_FindClassByAtom( STRING2ATOMW(lpClassName), hInstance ); - if ( p == NULL ) - return NULL; - - if ( style == WS_OVERLAPPEDWINDOW ) - style |= (WS_OVERLAPPED| WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |WS_MAXIMIZEBOX ); - - /* Create the window */ - - cs.lpCreateParams = data; - cs.hInstance = hInstance; - cs.hMenu = menu; - cs.hwndParent = parent; - cs.x = x; - cs.y = y; - cs.cx = width; - cs.cy = height; - cs.style = style; - cs.lpszName = windowName; - cs.lpszClass = p->className; - cs.dwExStyle = exStyle; - - - return WIN_CreateWindowEx( &cs, p->atomName ); - -} - - -/*********************************************************************** - * DestroyWindow (USER.135) - */ -WINBOOL STDCALL DestroyWindow( HWND hwnd ) -{ - WND * wndPtr; - - /* Initialization */ - - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; - //if (wndPtr == pWndDesktop) return FALSE; /* Can't destroy desktop */ - - - if ( hwnd == NULL ) - return FALSE; - - - /* Call hooks */ - - - if( HOOK_CallHooks( WH_CBT, HCBT_DESTROYWND, hwnd, 0L, wndPtr->class->bUnicode ) ) - return FALSE; - - if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner) - { - HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L, wndPtr->class->bUnicode ); - /* FIXME: clean up palette - see "Internals" p.352 */ - } - - if( !QUEUE_IsExitingQueue(wndPtr->hmemTaskQ) ) - if( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) ) - { - /* Notify the parent window only */ - if ( wndPtr->parent != NULL ) - SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY, - MAKEWPARAM(WM_DESTROY, wndPtr->wIDmenu), (LPARAM)hwnd ); - if( !IsWindow(hwnd) ) return TRUE; - } - - - - /* Hide the window */ - - if (wndPtr->dwStyle & WS_VISIBLE) - { - SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW | - SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE| - ((QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))?SWP_DEFERERASE:0) ); - if (!IsWindow(hwnd)) return TRUE; - } - - /* Recursively destroy owned windows */ - - if( !(wndPtr->dwStyle & WS_CHILD) ) - { - /* make sure top menu popup doesn't get destroyed */ - MENU_PatchResidentPopup( (HQUEUE)0xFFFF, wndPtr ); - - for (;;) - { - - WND *siblingPtr = NULL; - if ( wndPtr->parent != NULL ) - siblingPtr = wndPtr->parent->child; /* First sibling */ - while (siblingPtr) - { - if (siblingPtr->owner == wndPtr) - { - if (siblingPtr->hmemTaskQ == wndPtr->hmemTaskQ) - break; - else - siblingPtr->owner = NULL; - } - siblingPtr = siblingPtr->next; - } - if (siblingPtr) DestroyWindow( siblingPtr->hwndSelf ); - else break; - } -// !Options.managed || - if( EVENT_CheckFocus() ) - WINPOS_ActivateOtherWindow(wndPtr); - - if( wndPtr->owner && - wndPtr->owner->hwndLastActive == wndPtr->hwndSelf ) - wndPtr->owner->hwndLastActive = wndPtr->owner->hwndSelf; - } - - /* Send destroy messages */ - - WIN_SendDestroyMsg( wndPtr ); - if (!IsWindow(hwnd)) return TRUE; - - /* Unlink now so we won't bother with the children later on */ - - if( wndPtr->parent ) WIN_UnlinkWindow(hwnd); - - /* Destroy the window storage */ - - WIN_DestroyWindow( wndPtr ); - return TRUE; -} - - -/******************************************************************* - * EnableWindow - */ -WINBOOL STDCALL EnableWindow( HWND hWnd, WINBOOL enable ) -{ - WND *wndPtr; - - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return FALSE; - if (enable && (wndPtr->dwStyle & WS_DISABLED)) - { - /* Enable window */ - wndPtr->dwStyle &= ~WS_DISABLED; - SendMessageA( hWnd, WM_ENABLE, TRUE, 0 ); - return TRUE; - } - else if (!enable && !(wndPtr->dwStyle & WS_DISABLED)) - { - /* Disable window */ - wndPtr->dwStyle |= WS_DISABLED; - if ((hWnd == GetFocus()) || IsChild( hWnd, GetFocus() )) - SetFocus( 0 ); /* A disabled window can't have the focus */ - if ((hWnd == GetCapture()) || IsChild( hWnd, GetCapture() )) - ReleaseCapture(); /* A disabled window can't capture the mouse */ - SendMessageA( hWnd, WM_ENABLE, FALSE, 0 ); - return FALSE; - } - return ((wndPtr->dwStyle & WS_DISABLED) != 0); -} - - - -HWND STDCALL GetDesktopWindow(VOID) -{ - return WIN_GetDesktop()->hwndSelf; -} - - - -HWND STDCALL GetWindow( HWND hwnd, UINT rel ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return 0; - switch(rel) - { - case GW_HWNDFIRST: - if (wndPtr->parent) return wndPtr->parent->child->hwndSelf; - else return 0; - - case GW_HWNDLAST: - if (!wndPtr->parent) return 0; /* Desktop window */ - while (wndPtr->next) wndPtr = wndPtr->next; - return wndPtr->hwndSelf; - - case GW_HWNDNEXT: - if (!wndPtr->next) return 0; - return wndPtr->next->hwndSelf; - - case GW_HWNDPREV: - if (!wndPtr->parent) return 0; /* Desktop window */ - wndPtr = wndPtr->parent->child; /* First sibling */ - if (wndPtr->hwndSelf == hwnd) return 0; /* First in list */ - while (wndPtr->next) - { - if (wndPtr->next->hwndSelf == hwnd) return wndPtr->hwndSelf; - wndPtr = wndPtr->next; - } - return 0; - - case GW_OWNER: - return wndPtr->owner ? wndPtr->owner->hwndSelf : 0; - - case GW_CHILD: - return wndPtr->child ? wndPtr->child->hwndSelf : 0; - } - return 0; -} - - -WORD STDCALL SetWindowWord( HWND hwnd, INT offset, WORD newval ) -{ - WORD *ptr, retval; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return 0; - if (offset >= 0) - { - if (offset + sizeof(WORD) > wndPtr->class->cbWndExtra) - { - DPRINT( "Invalid offset %d\n", offset ); - return 0; - } - ptr = (WORD *)(((char *)wndPtr->wExtra) + offset); - } - else switch(offset) - { - case GWW_ID: ptr = (WORD *)&wndPtr->wIDmenu; break; - case GWW_HINSTANCE: ptr = (WORD *)&wndPtr->hInstance; break; - case GWW_HWNDPARENT: return SetParent( hwnd, newval ); - default: - DPRINT("Invalid offset %d\n", offset ); - return 0; - } - retval = *ptr; - *ptr = newval; - return retval; -} - -LONG STDCALL GetWindowLongA( HWND hwnd, INT offset ) -{ - return WIN_GetWindowLong( hwnd, offset ); -} - - -LONG STDCALL GetWindowLongW( HWND hwnd, INT offset ) -{ - return WIN_GetWindowLong( hwnd, offset ); -} - -/********************************************************************** - * SetWindowLongW (USER.518) Set window attribute - * - * SetWindowLong() alters one of a window's attributes or sets a -bit (long) - * value in a window's extra memory. - * - * The _hwnd_ parameter specifies the window. is the handle to a - * window that has extra memory. The _newval_ parameter contains the - * new attribute or extra memory value. If positive, the _offset_ - * parameter is the byte-addressed location in the window's extra - * memory to set. If negative, _offset_ specifies the window - * attribute to set, and should be one of the following values: - * - * GWL_EXSTYLE The window's extended window style - * - * GWL_STYLE The window's window style. - * - * GWL_WNDPROC Pointer to the window's window procedure. - * - * GWL_HINSTANCE The window's pplication instance handle. - * - * GWL_ID The window's identifier. - * - * GWL_USERDATA The window's user-specified data. - * - * If the window is a dialog box, the _offset_ parameter can be one of - * the following values: - * - * DWL_DLGPROC The address of the window's dialog box procedure. - * - * DWL_MSGRESULT The return value of a message - * that the dialog box procedure processed. - * - * DWL_USER Application specific information. - * - * RETURNS - * - * If successful, returns the previous value located at _offset_. Otherwise, - * returns 0. - * - * NOTES - * - * Extra memory for a window class is specified by a nonzero cbWndExtra - * parameter of the WNDCLASS structure passed to RegisterClass() at the - * time of class creation. - * - * Using GWL_WNDPROC to set a new window procedure effectively creates - * a window subclass. Use CallWindowProc() in the new windows procedure - * to pass messages to the superclass's window procedure. - * - * The user data is reserved for use by the application which created - * the window. - * - * Do not use GWL_STYLE to change the window's WS_DISABLE style; - * instead, call the EnableWindow() function to change the window's - * disabled state. - * - * Do not use GWL_HWNDPARENT to reset the window's parent, use - * SetParent() instead. - * - * Win95: - * When offset is GWL_STYLE and the calling app's ver is 4.0, - * it sends WM_STYLECHANGING before changing the settings - * and WM_STYLECHANGED afterwards. - * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST. - * - * BUGS - * - * GWL_STYLE does not dispatch WM_STYLE... messages. - * - * CONFORMANCE - * - * ECMA-234, Win - * - */ - -LONG STDCALL SetWindowLongA( HWND hwnd, INT offset, LONG newval ) -{ - return WIN_SetWindowLong( hwnd, offset, newval ); -} - - -LONG STDCALL SetWindowLongW( - HWND hwnd, - INT offset, - LONG newval -) { - return WIN_SetWindowLong( hwnd, offset, newval ); -} - - -HWND STDCALL GetTopWindow( HWND hwnd ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr && wndPtr->child) return wndPtr->child->hwndSelf; - else return 0; -} - -HWND STDCALL GetNextWindow( HWND hwnd, UINT flag ) -{ - if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0; - return GetWindow( hwnd, flag ); -} - -/***************************************************************** - * GetParent (USER.278) - */ -HWND STDCALL GetParent( HWND hwnd ) -{ - WND *wndPtr = WIN_FindWndPtr(hwnd); - if ((!wndPtr) || (!(wndPtr->dwStyle & (WS_POPUP|WS_CHILD)))) return 0; - wndPtr = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner; - return wndPtr ? wndPtr->hwndSelf : NULL; -} - -/***************************************************************** - * SetParent (USER.495) - */ -HWND STDCALL SetParent( HWND hWndChild, HWND hWndNewParent ) -{ - WND *wndPtr = WIN_FindWndPtr( hWndChild ); - WND *pWndNewParent = - (hWndNewParent) ? WIN_FindWndPtr( hWndNewParent ) : WIN_FindWndPtr(GetDesktopWindow()); - WND *pWndOldParent; - - // (wndPtr)?(*wndPtr->pDriver->pSetParent)(wndPtr, pWndNewParent):NULL; - - return pWndOldParent?pWndOldParent->hwndSelf:NULL; -} - -/******************************************************************* - * GetWindowTextA (USER.309) - */ -INT STDCALL GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) -{ - return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, - (LPARAM)lpString ); -} - - - -/******************************************************************* - * GetWindowTextW (USER.312) - */ -INT STDCALL GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount ) -{ - return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, - (LPARAM)lpString ); -} - - -WINBOOL STDCALL SetWindowTextA( HWND hwnd, LPCSTR lpString ) -{ - return (WINBOOL)SendMessageA( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); -} - - -WINBOOL STDCALL SetWindowTextW( HWND hwnd, LPCWSTR lpString ) -{ - return (WINBOOL)SendMessageW( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); -} - - -INT STDCALL GetWindowTextLengthA( HWND hwnd ) -{ - return SendMessageA( hwnd, WM_GETTEXTLENGTH, 0, 0 ); -} - - -INT STDCALL GetWindowTextLengthW( HWND hwnd ) -{ - return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ); -} - - -WINBOOL STDCALL IsChild( HWND parent, HWND child ) -{ - WND * wndPtr = WIN_FindWndPtr( child ); - while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) - { - wndPtr = wndPtr->parent; - if (wndPtr->hwndSelf == parent) return TRUE; - } - return FALSE; -} - -WINBOOL STDCALL IsWindow(HANDLE hWnd) -{ - if (WIN_FindWndPtr( hWnd ) == NULL) return FALSE; - return TRUE; -} - - -/*********************************************************************** - * IsWindowEnabled - */ -WINBOOL STDCALL IsWindowEnabled(HWND hWnd) -{ - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr(hWnd))) return FALSE; - return !(wndPtr->dwStyle & WS_DISABLED); -} - - -/*********************************************************************** - * IsWindowUnicode - */ -WINBOOL STDCALL IsWindowUnicode( HWND hWnd ) -{ - WND * wndPtr; - - if (!(wndPtr = WIN_FindWndPtr(hWnd))) - return FALSE; - return wndPtr->class->bUnicode; -} - - -WINBOOL STDCALL IsWindowVisible( HWND hwnd ) -{ - WND *wndPtr = WIN_FindWndPtr( hwnd ); - while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) - { - if (!(wndPtr->dwStyle & WS_VISIBLE)) return FALSE; - wndPtr = wndPtr->parent; - } - return (wndPtr && (wndPtr->dwStyle & WS_VISIBLE)); -} - - - - - -/******************************************************************* - * FlashWindow (USER32.202) - */ -WINBOOL STDCALL FlashWindow( HWND hWnd, WINBOOL bInvert ) -{ - WND *wndPtr = WIN_FindWndPtr(hWnd); - - - if (!wndPtr) return FALSE; - - if (wndPtr->dwStyle & WS_MINIMIZE) - { - if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED)) - { - HDC hDC = GetDC(hWnd); - - if (!SendMessage( hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0 )) - wndPtr->flags |= WIN_NEEDS_ERASEBKGND; - - ReleaseDC( hWnd, hDC ); - wndPtr->flags |= WIN_NCACTIVATED; - } - else - { - PAINT_RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | - RDW_UPDATENOW | RDW_FRAME, 0 ); - wndPtr->flags &= ~WIN_NCACTIVATED; - } - return TRUE; - } - else - { - WPARAM wparam; - if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED); - else wparam = (hWnd == GetActiveWindow()); - - SendMessage( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 ); - return wparam; - } -} - - diff --git a/reactos/lib/user32/windows/winpos.c b/reactos/lib/user32/windows/winpos.c deleted file mode 100644 index 827320c6906..00000000000 --- a/reactos/lib/user32/windows/winpos.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * Window position related functions. - * - * Copyright 1993, 1994, 1995 Alexandre Julliard - * 1995, 1996 Alex Korobka - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -HWND GetSysModalWindow(void); - - -extern MESSAGEQUEUE* pActiveQueue; - - -void STDCALL SwitchToThisWindow( HWND hwnd, WINBOOL restore ) -{ - ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED ); -} - - -WINBOOL STDCALL ClientToScreen( HWND hwnd, LPPOINT lppnt ) -{ - return MapWindowPoints( hwnd, 0, lppnt, 1 ); - -} - - -WINBOOL STDCALL ScreenToClient( HWND hwnd, LPPOINT lppnt ) -{ - return MapWindowPoints( 0, hwnd, lppnt, 1 ); -} - - -HWND STDCALL WindowFromPoint( POINT pt ) -{ - WND *pWnd; - - WINPOS_WindowFromPoint( WIN_GetDesktop(), pt, &pWnd ); - return (HWND)pWnd->hwndSelf; -} - - - -HWND STDCALL ChildWindowFromPoint( HWND hwndParent, POINT pt ) -{ - /* pt is in the client coordinates */ - - WND* wnd = WIN_FindWndPtr(hwndParent); - RECT rect; - - if( !wnd ) return 0; - - /* get client rect fast */ - rect.top = rect.left = 0; - rect.right = wnd->rectClient.right - wnd->rectClient.left; - rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top; - - if (!PtInRect( &rect, pt )) return 0; - - wnd = wnd->child; - while ( wnd ) - { - if (PtInRect( &wnd->rectWindow, pt )) return wnd->hwndSelf; - wnd = wnd->next; - } - return hwndParent; -} - - - - -HWND STDCALL ChildWindowFromPointEx( HWND hwndParent, POINT pt, - UINT uFlags) -{ - /* pt is in the client coordinates */ - - WND* wnd = WIN_FindWndPtr(hwndParent); - RECT rect; - - if( !wnd ) return 0; - - /* get client rect fast */ - rect.top = rect.left = 0; - rect.right = wnd->rectClient.right - wnd->rectClient.left; - rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top; - - if (!PtInRect( &rect, pt )) return 0; - - wnd = wnd->child; - while ( wnd ) - { - if (PtInRect( &wnd->rectWindow, pt )) { - if ( (uFlags & CWP_SKIPINVISIBLE) && - !(wnd->dwStyle & WS_VISIBLE) ) - wnd = wnd->next; - else if ( (uFlags & CWP_SKIPDISABLED) && - (wnd->dwStyle & WS_DISABLED) ) - wnd = wnd->next; - else if ( (uFlags & CWP_SKIPTRANSPARENT) && - (wnd->dwExStyle & WS_EX_TRANSPARENT) ) - wnd = wnd->next; - else - return wnd->hwndSelf; - } - } - return hwndParent; -} - - -WINBOOL STDCALL MapWindowPoints( HWND hwndFrom, HWND hwndTo, - LPPOINT lppt, UINT count ) -{ - POINT offset; - - WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset ); - while (count--) - { - lppt->x += offset.x; - lppt->y += offset.y; - lppt++; - } - return TRUE; -} - - -WINBOOL STDCALL IsIconic(HWND hWnd) -{ - WND * wndPtr = WIN_FindWndPtr(hWnd); - if (wndPtr == NULL) return FALSE; - return (wndPtr->dwStyle & WS_MINIMIZE) != 0; -} - - -WINBOOL STDCALL IsZoomed(HWND hWnd) -{ - WND * wndPtr = WIN_FindWndPtr(hWnd); - if (wndPtr == NULL) return FALSE; - return (wndPtr->dwStyle & WS_MAXIMIZE) != 0; -} - - -HWND STDCALL GetActiveWindow(void) -{ - return WINPOS_GetActiveWindow(); -} - -HWND STDCALL SetActiveWindow(HWND hWnd ) -{ - HWND hPrev; - hPrev = GetActiveWindow(); - if ( WINPOS_SetActiveWindow( hWnd, TRUE, TRUE) ) - return hPrev; - return NULL; -} - - -/*********************************************************************** - * 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 -ShowWindowAsync( - HWND hWnd, - int nCmdShow) -{ - return FALSE; -} - -WINBOOL -STDCALL -BringWindowToTop( - HWND hWnd) { return FALSE; } - -WINBOOL STDCALL SetWindowPos( HWND hWnd, HWND hWndInsertAfter , - int X, int Y, - int cx, int cy, - UINT flags) -{ - - WINDOWPOS winpos; - WND * wndPtr; - RECT newWindowRect, newClientRect, oldWindowRect; - HRGN visRgn = 0; - HWND tempInsertAfter= 0; - int result = 0; - UINT uFlags; - WINBOOL resync = FALSE; - - - /* Check window handle */ - - if (hWnd == GetDesktopWindow()) return FALSE; - - if (hWnd == GetActiveWindow() ) flags |= SWP_NOACTIVATE; /* Already active */ - - - /* Check dimensions */ - - if (cx <= 0) cx = 1; - if (cy <= 0) cy = 1; - - if (!(wndPtr = WIN_FindWndPtr( hWnd ))) return FALSE; - -#if OPTIMIZATION - if(wndPtr->dwStyle & WS_VISIBLE) - flags &= ~SWP_SHOWWINDOW; - else - { - uFlags |= SMC_NOPARENTERASE; - flags &= ~SWP_HIDEWINDOW; - if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW; - } - - - - /* Check flags */ - - if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) && - (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy)) - flags |= SWP_NOSIZE; /* Already the right size */ - if ((wndPtr->rectWindow.left == X) && (wndPtr->rectWindow.top == Y)) - flags |= SWP_NOMOVE; /* Already the right position */ - -#endif - /* Check hWndInsertAfter */ - - if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE))) - { - /* Ignore TOPMOST flags when activating a window */ - /* _and_ moving it in Z order. */ - - if ((hWndInsertAfter == HWND_TOPMOST) || (hWndInsertAfter == HWND_NOTOPMOST)) - hWndInsertAfter = HWND_TOP; - } - /* TOPMOST not supported yet */ - if ((hWndInsertAfter == HWND_TOPMOST) || (hWndInsertAfter == HWND_NOTOPMOST)) - hWndInsertAfter = HWND_TOP; - - /* hWndInsertAfter must be a sibling of the window */ - if ((hWndInsertAfter != HWND_TOP) && (hWndInsertAfter != HWND_BOTTOM)) - { - WND* wnd = WIN_FindWndPtr(hWndInsertAfter); - - if( wnd ) { - if( wnd->parent != wndPtr->parent ) return FALSE; - if( wnd->next == wndPtr ) flags |= SWP_NOZORDER; - } - } - else - { - /* FIXME: the following optimization is no good for "X-ed" windows */ - if (hWndInsertAfter == HWND_TOP && wndPtr->parent) - flags |= ( wndPtr->parent->child == wndPtr)? SWP_NOZORDER: 0; - else /* HWND_BOTTOM */ - flags |= ( wndPtr->next )? 0: SWP_NOZORDER; - } - - - /* Fill the WINDOWPOS structure */ - - winpos.hwnd = hWnd; - winpos.hwndInsertAfter = hWndInsertAfter; - winpos.x = X; - winpos.y = Y; - winpos.cx = cx; - winpos.cy = cy; - winpos.flags = flags; - - /* Send WM_WINDOWPOSCHANGING message */ - - if (!(winpos.flags & SWP_NOSENDCHANGING)) - MSG_SendMessage( wndPtr, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos ); - - /* Calculate new position and size */ - - newWindowRect = wndPtr->rectWindow; - newClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow - : wndPtr->rectClient; - - if (!(winpos.flags & SWP_NOSIZE)) - { - newWindowRect.right = newWindowRect.left + winpos.cx; - newWindowRect.bottom = newWindowRect.top + winpos.cy; - } - if (!(winpos.flags & SWP_NOMOVE)) - { - newWindowRect.left = winpos.x; - newWindowRect.top = winpos.y; - newWindowRect.right += winpos.x - wndPtr->rectWindow.left; - newWindowRect.bottom += winpos.y - wndPtr->rectWindow.top; - - OffsetRect( &newClientRect, winpos.x - wndPtr->rectWindow.left, - winpos.y - wndPtr->rectWindow.top ); - } - - winpos.flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE; - - /* Reposition window in Z order */ - - if (!(winpos.flags & SWP_NOZORDER)) - { - /* reorder owned popups if hwnd is top-level window - */ - if( wndPtr->parent == WIN_GetDesktop() ) - hWndInsertAfter = WINPOS_ReorderOwnedPopups( hWndInsertAfter, - wndPtr, winpos.flags ); - - // if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window) - //{ - // WIN_UnlinkWindow( winpos.hwnd ); - // WIN_LinkWindow( winpos.hwnd, hWndInsertAfter ); - //} - else WINPOS_MoveWindowZOrder( winpos.hwnd, hWndInsertAfter ); - } - - if ( !(winpos.flags & SWP_NOREDRAW) && - ((winpos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED)) - != (SWP_NOMOVE | SWP_NOSIZE)) ) - visRgn = DCE_GetVisRgn(hWnd, DCX_WINDOW | DCX_CLIPSIBLINGS); - - - /* Send WM_NCCALCSIZE message to get new client area */ - if( (winpos.flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE ) - { - result = WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect, - &wndPtr->rectWindow, &wndPtr->rectClient, - &winpos, &newClientRect ); - - /* FIXME: WVR_ALIGNxxx */ - - if( newClientRect.left != wndPtr->rectClient.left || - newClientRect.top != wndPtr->rectClient.top ) - winpos.flags &= ~SWP_NOCLIENTMOVE; - - if( (newClientRect.right - newClientRect.left != - wndPtr->rectClient.right - wndPtr->rectClient.left) || - (newClientRect.bottom - newClientRect.top != - wndPtr->rectClient.bottom - wndPtr->rectClient.top) ) - winpos.flags &= ~SWP_NOCLIENTSIZE; - } - else - if( !(flags & SWP_NOMOVE) && (newClientRect.left != wndPtr->rectClient.left || - newClientRect.top != wndPtr->rectClient.top) ) - winpos.flags &= ~SWP_NOCLIENTMOVE; - - /* Update active DCEs - * 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)) ) - { - RECT rect; - - UnionRect(&rect, &newWindowRect, &wndPtr->rectWindow); - DCE_InvalidateDCE(wndPtr, &rect); - } - - /* change geometry */ - - oldWindowRect = wndPtr->rectWindow; - { - RECT oldClientRect = wndPtr->rectClient; - - wndPtr->rectWindow = newWindowRect; - wndPtr->rectClient = newClientRect; - - if( oldClientRect.bottom - oldClientRect.top == - newClientRect.bottom - newClientRect.top ) result &= ~WVR_VREDRAW; - - if( oldClientRect.right - oldClientRect.left == - newClientRect.right - newClientRect.left ) result &= ~WVR_HREDRAW; - - if( !(flags & (SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) ) - { - uFlags |= ((winpos.flags & SWP_NOCOPYBITS) || - (result >= WVR_HREDRAW && result < WVR_VALIDRECTS)) ? SMC_NOCOPY : 0; - uFlags |= (winpos.flags & SWP_FRAMECHANGED) ? SMC_DRAWFRAME : 0; - - if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE ) - uFlags = WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect, - &oldClientRect, uFlags); - else - { - /* adjust the frame and do not erase the parent */ - - if( winpos.flags & SWP_FRAMECHANGED ) wndPtr->flags |= WIN_NEEDS_NCPAINT; - if( winpos.flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE; - } - } - DeleteObject(visRgn); - } -#endif - if (flags & SWP_SHOWWINDOW) - { - wndPtr->dwStyle |= WS_VISIBLE; - - { - if (!(flags & SWP_NOREDRAW)) - PAINT_RedrawWindow( winpos.hwnd, NULL, 0, - RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 ); - } - } - else if (flags & SWP_HIDEWINDOW) - { - wndPtr->dwStyle &= ~WS_VISIBLE; - - - - if (!(flags & SWP_NOREDRAW) && wndPtr->parent != NULL ) - PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect, - 0, RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_ERASE | RDW_ERASENOW, 0 ); - - uFlags |= SMC_NOPARENTERASE; - - - if ((winpos.hwnd == GetFocus()) || - IsChild( winpos.hwnd, GetFocus())) - { - /* Revert focus to parent */ - SetFocus( GetParent(winpos.hwnd) ); - } - if (hWnd == CARET_GetHwnd()) DestroyCaret(); - - if (winpos.hwnd == GetActiveWindow()) - WINPOS_ActivateOtherWindow( wndPtr ); - } - - /* Activate the window */ - - if (!(flags & SWP_NOACTIVATE)) - WINPOS_ChangeActiveWindow( winpos.hwnd, FALSE ); - - /* Repaint the window */ - - // if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window) - // EVENT_Synchronize(); /* Wait for all expose events */ - - //if (!GetCapture()) - // EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */ - - if (wndPtr->parent && !(flags & SWP_DEFERERASE) && !(uFlags & SMC_NOPARENTERASE) ) - PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW, 0 ); - else if(wndPtr->parent && wndPtr->parent == WIN_GetDesktop() && wndPtr->parent->flags & WIN_NEEDS_ERASEBKGND ) - PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_NOCHILDREN | RDW_ERASENOW, 0 ); - - /* And last, send the WM_WINDOWPOSCHANGED message */ - - DPRINT("\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS); - - if ( resync || - (((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) && - !(winpos.flags & SWP_NOSENDCHANGING)) ) - { - SendMessageA( winpos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos ); - //if (resync) EVENT_Synchronize (); - } - - return TRUE; -} - - - - -/*********************************************************************** - * MoveWindow (USER32.399) - */ -WINBOOL STDCALL MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy, - WINBOOL repaint ) -{ - int flags = SWP_NOZORDER | SWP_NOACTIVATE; - if (!repaint) flags |= SWP_NOREDRAW; - - return SetWindowPos( hwnd, 0, x, y, cx, cy, flags ); -} - -WINBOOL -STDCALL -GetWindowPlacement( - HWND hWnd, - WINDOWPLACEMENT *lpwndpl) -{ - return FALSE; -} - - -WINBOOL -STDCALL -SetWindowPlacement( - HWND hWnd, - CONST WINDOWPLACEMENT *lpwndpl) -{ - return FALSE; -} - -WINBOOL -STDCALL -SetForegroundWindow( - HWND hWnd) -{ - return FALSE; -} \ No newline at end of file diff --git a/reactos/lib/user32/windows/wndproc.c b/reactos/lib/user32/windows/wndproc.c deleted file mode 100644 index 2a558076a9f..00000000000 --- a/reactos/lib/user32/windows/wndproc.c +++ /dev/null @@ -1,710 +0,0 @@ -#include -#include -#include -#include -//#include - -//#include - -#define MDICREATESTRUCT MDICREATESTRUCT -#define MDICREATESTRUCT MDICREATESTRUCT - - -/********************************************************************** - * CallWindowProc - * - * The CallWindowProc() function invokes the windows procedure _func_, - * with _hwnd_ as the target window, the message specified by _msg_, and - * the message parameters _wParam_ and _lParam_. - * - * Some kinds of argument conversion may be done, I'm not sure what. - * - * CallWindowProc() may be used for windows subclassing. Use - * SetWindowLong() to set a new windows procedure for windows of the - * subclass, and handle subclassed messages in the new windows - * procedure. The new windows procedure may then use CallWindowProc() - * with _func_ set to the parent class's windows procedure to dispatch - * the message to the superclass. - * - * RETURNS - * - * The return value is message dependent. - * - * CONFORMANCE - * - * ECMA-234, Win32 - */ -LRESULT WINAPI CallWindowProcA( - WNDPROC func, - HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam -) -{ - INT ret; - WND *w; - LRESULT l; - w = WIN_FindWndPtr( hwnd ); - if ( w == NULL ) - return 0; - - if ( w->class->bUnicode == FALSE ) - return func(hwnd,msg,wParam,lParam); - - - //convert message - ret = WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ); - if ( ret == -1 ) - return 0; - l = func(hwnd,msg,wParam,lParam); - if ( ret == 1 ) - WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam ); - return l; - - - - -} - -LRESULT WINAPI CallWindowProcW( - WNDPROC func, - HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam -) -{ - INT ret; - WND *w; - LRESULT l; - w = WIN_FindWndPtr( hwnd ); - if ( w == NULL ) - return 0; - - if ( w->class->bUnicode == TRUE ) - return func(hwnd,msg,wParam,lParam); - - - //convert message - ret = WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ); - if ( ret == -1 ) - return 0; - l = func(hwnd,msg,wParam,lParam); - if ( ret == 1 ) - WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam ); - return l; -} - -/*********************************************************************** - * DefWindowProc Calls default window message handler - * - * Calls default window procedure for messages not processed - * by application. - * - * RETURNS - * Return value is dependent upon the message. -*/ - - -/*********************************************************************** - * DefWindowProcA [USER32.126] - * - */ -LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - LRESULT result = 0; - - if (!wndPtr) return 0; -// SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam ); - - switch(msg) - { - case WM_NCCREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - if (cs->lpszName) DEFWND_SetTextA( wndPtr, cs->lpszName ); - result = 1; - } - break; - - case WM_NCCALCSIZE: - result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam ); - break; - - case WM_WINDOWPOSCHANGING: - result = WINPOS_HandleWindowPosChanging( wndPtr, - (WINDOWPOS *)lParam ); - break; - - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS * winPos = (WINDOWPOS *)lParam; - DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags ); - } - break; - - case WM_GETTEXT: - if (wParam && wndPtr->text) - { - lstrcpynA( (LPSTR)lParam, wndPtr->text, wParam ); - result = (LRESULT)lstrlenA( (LPSTR)lParam ); - } - break; - - case WM_SETTEXT: - DEFWND_SetTextA( wndPtr, (LPSTR)lParam ); - NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */ - break; - - default: - result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam ); - break; - } - -// SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result ); - return result; -} - - -/*********************************************************************** - * DefWindowProcW [USER32.127] Calls default window message handler - * - * Calls default window procedure for messages not processed - * by application. - * - * RETURNS - * Return value is dependent upon the message. -*/ -LRESULT WINAPI DefWindowProcW( HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam ) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - LRESULT result = 0; - - if (!wndPtr) return 0; - // SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam ); - - switch(msg) - { - case WM_NCCREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - if (cs->lpszName) DEFWND_SetTextW( wndPtr, cs->lpszName ); - result = 1; - } - break; - - case WM_NCCALCSIZE: - result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam ); - break; - - case WM_WINDOWPOSCHANGING: - result = WINPOS_HandleWindowPosChanging( wndPtr, - (WINDOWPOS *)lParam ); - break; - - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS * winPos = (WINDOWPOS *)lParam; - DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags ); - } - break; - - case WM_GETTEXT: - if (wParam && wndPtr->text) - { - lstrcpynW( (LPWSTR)lParam, wndPtr->text, wParam ); - result = (LRESULT)lstrlenW( (LPWSTR)lParam ); - } - break; - - case WM_SETTEXT: - DEFWND_SetTextW( wndPtr, (LPSTR)lParam ); - NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */ - break; - - default: - result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam ); - break; - } - - // SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result ); - return result; -} - -/********************************************************************** - * WINPROC_TestCBForStr - * - * Return TRUE if the lparam is a string - */ -WINBOOL WINPROC_TestCBForStr ( HWND hwnd ) -{ WND * wnd = WIN_FindWndPtr(hwnd); - return ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || - (LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) ); -} -/********************************************************************** - * WINPROC_TestLBForStr - * - * Return TRUE if the lparam is a string - */ -WINBOOL WINPROC_TestLBForStr ( HWND hwnd ) -{ WND * wnd = WIN_FindWndPtr(hwnd); - return ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || - (LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) ); -} - - -/********************************************************************** - * WINPROC_MapMsg32ATo32W - * - * Map a message from Ansi to Unicode. - * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. - * - * FIXME: - * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR - * - * FIXME: - * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style: - * the first four bytes are the handle of the icon - * when the WM_SETTEXT message has been used to set the icon - */ -INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) -{ - switch(msg) - { - case WM_GETTEXT: - { - LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, - wParam * sizeof(WCHAR) + sizeof(LPARAM) ); - if (!ptr) - return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - return 1; - - case WM_SETTEXT: - case CB_DIR: - case CB_FINDSTRING: - case CB_FINDSTRINGEXACT: - case CB_SELECTSTRING: - case LB_DIR: - case LB_ADDFILE: - case LB_FINDSTRING: - case LB_SELECTSTRING: - case EM_REPLACESEL: - *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); - return (*plparam ? 1 : -1); - break; - - case WM_NCCREATE: - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)HeapAlloc( GetProcessHeap(), 0, - sizeof(*cs) ); - if (!cs) return -1; - *cs = *(CREATESTRUCT *)*plparam; - if (HIWORD(cs->lpszName)) - cs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0, - (LPCSTR)cs->lpszName ); - if (HIWORD(cs->lpszClass)) - cs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0, - (LPCSTR)cs->lpszClass ); - *plparam = (LPARAM)cs; - } - return 1; - case WM_MDICREATE: - { - MDICREATESTRUCT *cs = HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT) ); - if (!cs) return -1; - *cs = *(MDICREATESTRUCT *)*plparam; - if (HIWORD(cs->szClass)) - cs->szClass = HEAP_strdupAtoW( GetProcessHeap(), 0, - (LPCSTR)cs->szClass ); - if (HIWORD(cs->szTitle)) - cs->szTitle = HEAP_strdupAtoW( GetProcessHeap(), 0, - (LPCSTR)cs->szTitle ); - *plparam = (LPARAM)cs; - } - return 1; - -/* Listbox */ - case LB_ADDSTRING: - case LB_INSERTSTRING: - if ( WINPROC_TestLBForStr( hwnd )) - *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); - return (*plparam ? 1 : -1); - - case LB_GETTEXT: /* fixme: fixed sized buffer */ - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - -/* Combobox */ - case CB_ADDSTRING: - case CB_INSERTSTRING: - if ( WINPROC_TestCBForStr( hwnd )) - *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); - return (*plparam ? 1 : -1); - - case CB_GETLBTEXT: /* fixme: fixed sized buffer */ - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - -/* Multiline edit */ - case EM_GETLINE: - { WORD len = (WORD)*plparam; - LPARAM *ptr = (LPARAM *) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - (WORD)*ptr = len; /* Store the lenght */ - *plparam = (LPARAM)ptr; - } - return 1; - - case WM_ASKCBFORMATNAME: - case WM_DEVMODECHANGE: - case WM_PAINTCLIPBOARD: - case WM_SIZECLIPBOARD: - case WM_WININICHANGE: - case EM_SETPASSWORDCHAR: - // FIXME(msg, "message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg ); - return -1; - default: /* No translation needed */ - return 0; - } -} - - -/********************************************************************** - * WINPROC_UnmapMsg32ATo32W - * - * Unmap a message that was mapped from Ansi to Unicode. - */ -void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch(msg) - { - case WM_GETTEXT: - { - LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - - case WM_NCCREATE: - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - if (HIWORD(cs->lpszName)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName ); - if (HIWORD(cs->lpszClass)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass ); - HeapFree( GetProcessHeap(), 0, cs ); - } - break; - - case WM_MDICREATE: - { - MDICREATESTRUCT *cs = (MDICREATESTRUCT *)lParam; - if (HIWORD(cs->szTitle)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle ); - if (HIWORD(cs->szClass)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass ); - HeapFree( GetProcessHeap(), 0, cs ); - } - break; - - case WM_SETTEXT: - case CB_DIR: - case CB_FINDSTRING: - case CB_FINDSTRINGEXACT: - case CB_SELECTSTRING: - case LB_DIR: - case LB_ADDFILE: - case LB_FINDSTRING: - case LB_SELECTSTRING: - case EM_REPLACESEL: - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - -/* Listbox */ - case LB_ADDSTRING: - case LB_INSERTSTRING: - if ( WINPROC_TestLBForStr( hwnd )) - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - - case LB_GETTEXT: - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - } - break; - -/* Combobox */ - case CB_ADDSTRING: - case CB_INSERTSTRING: - if ( WINPROC_TestCBForStr( hwnd )) - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - - case CB_GETLBTEXT: - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - } - break; - -/* Multiline edit */ - case EM_GETLINE: - { LPARAM *ptr = (LPARAM *)lParam - 1; /* get the old lParam */ - WORD len = *(WORD *)ptr; - lstrcpynWtoA( ((LPSTR)*ptr)+2, ((LPWSTR)(lParam + 1))+1, len ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - } -} - - -/********************************************************************** - * WINPROC_MapMsg32WTo32A - * - * Map a message from Unicode to Ansi. - * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. - */ -INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) -{ switch(msg) - { - case WM_GETTEXT: - { - LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, - wParam + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - return 1; - - case WM_SETTEXT: - case CB_DIR: - case CB_FINDSTRING: - case CB_FINDSTRINGEXACT: - case CB_SELECTSTRING: - case LB_DIR: - case LB_ADDFILE: - case LB_FINDSTRING: - case LB_SELECTSTRING: - case EM_REPLACESEL: - *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); - return (*plparam ? 1 : -1); - - case WM_NCCREATE: - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)HeapAlloc( GetProcessHeap(), 0, - sizeof(*cs) ); - if (!cs) return -1; - *cs = *(CREATESTRUCT *)*plparam; - if (HIWORD(cs->lpszName)) - cs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0, - (LPCWSTR)cs->lpszName ); - if (HIWORD(cs->lpszClass)) - cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0, - (LPCWSTR)cs->lpszClass); - *plparam = (LPARAM)cs; - } - return 1; - case WM_MDICREATE: - { - MDICREATESTRUCT *cs = - (MDICREATESTRUCT *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) ); - if (!cs) return -1; - *cs = *(MDICREATESTRUCT *)*plparam; - if (HIWORD(cs->szTitle)) - cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0, - (LPCWSTR)cs->szTitle ); - if (HIWORD(cs->szClass)) - cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0, - (LPCWSTR)cs->szClass ); - *plparam = (LPARAM)cs; - } - return 1; - -/* Listbox */ - case LB_ADDSTRING: - case LB_INSERTSTRING: - if ( WINPROC_TestLBForStr( hwnd )) - *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); - return (*plparam ? 1 : -1); - - case LB_GETTEXT: /* fixme: fixed sized buffer */ - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - -/* Combobox */ - case CB_ADDSTRING: - case CB_INSERTSTRING: - if ( WINPROC_TestCBForStr( hwnd )) - *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); - return (*plparam ? 1 : -1); - - case CB_GETLBTEXT: /* fixme: fixed sized buffer */ - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - -/* Multiline edit */ - case EM_GETLINE: - { WORD len = (WORD)*plparam; - LPARAM *ptr = (LPARAM *) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - (WORD)*ptr = len; /* Store the lenght */ - *plparam = (LPARAM)ptr; - } - return 1; - - case WM_ASKCBFORMATNAME: - case WM_DEVMODECHANGE: - case WM_PAINTCLIPBOARD: - case WM_SIZECLIPBOARD: - case WM_WININICHANGE: - case EM_SETPASSWORDCHAR: -// FIXME(msg, "message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg ); - return -1; - default: /* No translation needed */ - return 0; - } -} - - -/********************************************************************** - * WINPROC_UnmapMsg32WTo32A - * - * Unmap a message that was mapped from Unicode to Ansi. - */ -void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - switch(msg) - { - case WM_GETTEXT: - { - LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - - case WM_SETTEXT: - case CB_DIR: - case CB_FINDSTRING: - case CB_FINDSTRINGEXACT: - case CB_SELECTSTRING: - case LB_DIR: - case LB_ADDFILE: - case LB_FINDSTRING: - case LB_SELECTSTRING: - case EM_REPLACESEL: - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - - case WM_NCCREATE: - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - if (HIWORD(cs->lpszName)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName ); - if (HIWORD(cs->lpszClass)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass ); - HeapFree( GetProcessHeap(), 0, cs ); - } - break; - - case WM_MDICREATE: - { - MDICREATESTRUCT *cs = (MDICREATESTRUCT *)lParam; - if (HIWORD(cs->szTitle)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle ); - if (HIWORD(cs->szClass)) - HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass ); - HeapFree( GetProcessHeap(), 0, cs ); - } - break; - -/* Listbox */ - case LB_ADDSTRING: - case LB_INSERTSTRING: - if ( WINPROC_TestLBForStr( hwnd )) - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - - case LB_GETTEXT: - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - } - break; - -/* Combobox */ - case CB_ADDSTRING: - case CB_INSERTSTRING: - if ( WINPROC_TestCBForStr( hwnd )) - HeapFree( GetProcessHeap(), 0, (void *)lParam ); - break; - - case CB_GETLBTEXT: - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - } - break; - -/* Multiline edit */ - case EM_GETLINE: - { LPARAM *ptr = (LPARAM *)lParam - 1; /* get the old lParam */ - WORD len = *(WORD *)ptr; - lstrcpynAtoW( ((LPWSTR)*ptr)+1, ((LPSTR)(lParam + 1))+2, len ); - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - } -} - - -