Author: pborobia
Date: Wed Aug 30 23:35:22 2006
New Revision: 23810
URL:
http://svn.reactos.org/svn/reactos?rev=23810&view=rev
Log:
user32.dll part:
* Clipboard implemtation in win32k and user32
* Added a clipboard system for each Window Station
* GetLastInputInfo implementation
* GetLayout in win32k Stubs
* Shell32 changes to cut/copy & paste link/paste
* Implemented ALT+PrintScreen to clipboard
Modified:
trunk/reactos/dll/win32/user32/include/user32p.h
trunk/reactos/dll/win32/user32/windows/clipboard.c
trunk/reactos/dll/win32/user32/windows/defwnd.c
trunk/reactos/dll/win32/user32/windows/input.c
Modified: trunk/reactos/dll/win32/user32/include/user32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32p.h (original)
+++ trunk/reactos/dll/win32/user32/include/user32p.h Wed Aug 30 23:35:22 2006
@@ -75,10 +75,10 @@
#define NtUserSetCaretBlinkTime(uMSeconds) \
(BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
-
+/*
#define NtUserEnumClipboardFormats(format) \
(UINT)NtUserCallOneParam(format, ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS)
-
+*/
#define NtUserWindowFromDC(hDC) \
(HWND)NtUserCallOneParam((DWORD)hDC, ONEPARAM_ROUTINE_WINDOWFROMDC)
Modified: trunk/reactos/dll/win32/user32/windows/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/clipboard.c (original)
+++ trunk/reactos/dll/win32/user32/windows/clipboard.c Wed Aug 30 23:35:22 2006
@@ -1,37 +1,25 @@
-/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
/* $Id$
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/clipboard.c
* PURPOSE: Input
* PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * Pablo Borobia <pborobia(a)gmail.com>
* UPDATE HISTORY:
* 09-05-2001 CSH Created
+ *
*/
/* INCLUDES ******************************************************************/
#include <user32.h>
+#define DEBUG
+
#include <wine/debug.h>
+#define QUERY_SIZE 0
+
/* FUNCTIONS *****************************************************************/
/*
@@ -40,7 +28,8 @@
BOOL STDCALL
OpenClipboard(HWND hWndNewOwner)
{
- return NtUserOpenClipboard(hWndNewOwner, 0);
+ BOOL ret = NtUserOpenClipboard(hWndNewOwner, 0);
+ return ret;
}
/*
@@ -49,7 +38,9 @@
BOOL STDCALL
CloseClipboard(VOID)
{
- return NtUserCloseClipboard();
+ BOOL ret;
+ ret = NtUserCloseClipboard();
+ return ret;
}
/*
@@ -58,7 +49,8 @@
INT STDCALL
CountClipboardFormats(VOID)
{
- return NtUserCountClipboardFormats();
+ INT ret = NtUserCountClipboardFormats();
+ return ret;
}
/*
@@ -67,7 +59,7 @@
BOOL STDCALL
EmptyClipboard(VOID)
{
- return NtUserEmptyClipboard();
+ return NtUserEmptyClipboard();
}
/*
@@ -76,7 +68,8 @@
UINT STDCALL
EnumClipboardFormats(UINT format)
{
- return NtUserEnumClipboardFormats(format);
+ UINT ret = NtUserEnumClipboardFormats(format);
+ return ret;
}
/*
@@ -85,7 +78,31 @@
HANDLE STDCALL
GetClipboardData(UINT uFormat)
{
- return NtUserGetClipboardData(uFormat, 0);
+ HGLOBAL hGlobal = NULL;
+ PVOID pGlobal = NULL;
+ DWORD size = 0;
+
+ /* dealing with bitmap object */
+ if (uFormat != CF_BITMAP)
+ {
+ size = (DWORD)NtUserGetClipboardData(uFormat, QUERY_SIZE);
+
+ if (size)
+ {
+ hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, size);
+ pGlobal = GlobalLock(hGlobal);
+
+ size = (DWORD)NtUserGetClipboardData(uFormat, (DWORD)pGlobal);
+
+ GlobalUnlock(hGlobal);
+ }
+ }
+ else
+ {
+ hGlobal = NtUserGetClipboardData(CF_BITMAP, !QUERY_SIZE);
+ }
+
+ return hGlobal;
}
/*
@@ -94,28 +111,32 @@
INT STDCALL
GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
{
- LPWSTR lpBuffer;
- UNICODE_STRING FormatName;
- INT Length;
-
- lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR));
- if (!lpBuffer)
- {
- SetLastError(ERROR_OUTOFMEMORY);
- return 0;
- }
+ LPWSTR lpBuffer;
+ UNICODE_STRING FormatName;
+ INT Length;
+ ANSI_STRING ClassName;
+
+ ClassName.MaximumLength = cchMaxCount;
+ ClassName.Buffer = lpszFormatName;
+
+ lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR));
+
+ if (!lpBuffer)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return 0;
+ }
FormatName.Length = 0;
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = lpBuffer;
+ /* we need a UNICODE string */
Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
- DPRINT("GetClipboardFormatNameA(%x): %S\n", format, lpBuffer);
- HEAP_strcpyWtoA(lpszFormatName, lpBuffer, Length);
- HEAP_free(lpBuffer);
- DPRINT("GetClipboardFormatNameA(%x): returning %s\n", format,
lpszFormatName);
-
- return Length;
+
+ HEAP_strcpyWtoA(lpszFormatName, FormatName.Buffer, Length);
+
+ return strlen(lpszFormatName);
}
/*
@@ -124,15 +145,15 @@
INT STDCALL
GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount)
{
- UNICODE_STRING FormatName;
- ULONG Ret;
-
- FormatName.Length = 0;
- FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
- FormatName.Buffer = (PWSTR)lpszFormatName;
- Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
- DPRINT("GetClipboardFormatNameW(%x): returning %S\n", format,
lpszFormatName);
- return Ret;
+ UNICODE_STRING FormatName;
+ ULONG Ret;
+
+ FormatName.Length = 0;
+ FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
+ FormatName.Buffer = (PWSTR)lpszFormatName;
+ Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
+ return Ret;
+
}
/*
@@ -177,7 +198,8 @@
INT STDCALL
GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
{
- return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
+ INT ret = NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
+ return ret;
}
/*
@@ -186,18 +208,42 @@
BOOL STDCALL
IsClipboardFormatAvailable(UINT format)
{
- return NtUserIsClipboardFormatAvailable(format);
-}
-
-/*
- * @implemented
- */
+ BOOL ret = NtUserIsClipboardFormatAvailable(format);
+ return ret;
+}
+
+/*
+ * @implemented
+ */
+
+
UINT STDCALL
RegisterClipboardFormatA(LPCSTR lpszFormat)
{
- ULONG Ret = RegisterWindowMessageA(lpszFormat);
- DPRINT("RegisterClipboardFormatA(%s) - %x\n", lpszFormat, Ret);
- return Ret;
+ UINT ret = 0;
+ UNICODE_STRING usFormat = {0};
+
+ if (lpszFormat == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ /* check for "" */
+ if (*lpszFormat == 0) //NULL
+ {
+ SetLastError(ERROR_INVALID_NAME);
+ return 0;
+ }
+
+ ret = RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat);
+ if (ret)
+ {
+ ret = NtUserRegisterClipboardFormat(&usFormat); //(LPCWSTR)
+ RtlFreeUnicodeString(&usFormat);
+ }
+
+ return ret;
}
/*
@@ -206,9 +252,48 @@
UINT STDCALL
RegisterClipboardFormatW(LPCWSTR lpszFormat)
{
- ULONG Ret = RegisterWindowMessageW(lpszFormat);
- DPRINT("RegisterClipboardFormatW(%S) - %x\n", lpszFormat, Ret);
- return Ret;
+ UINT ret = 0;
+ UNICODE_STRING usFormat = {0};
+
+ if (lpszFormat == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ /* check for "" */
+ if (*lpszFormat == 0) //NULL
+ {
+ SetLastError(ERROR_INVALID_NAME);
+ return 0;
+ }
+
+ RtlInitUnicodeString(&usFormat, lpszFormat);
+ ret = NtUserRegisterClipboardFormat(&usFormat);
+ RtlFreeUnicodeString(&usFormat);
+
+ return ret;
+}
+
+HGLOBAL renderLocale (DWORD Locale)
+{
+ DWORD* pLocale;
+ HGLOBAL hGlobal;
+
+ hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(DWORD));
+
+ if(!hGlobal)
+ {
+ return hGlobal;
+ }
+
+ pLocale = (DWORD*)GlobalLock(hGlobal);
+
+ *pLocale = Locale;
+
+ GlobalUnlock(hGlobal);
+
+ return hGlobal;
}
/*
@@ -217,7 +302,41 @@
HANDLE STDCALL
SetClipboardData(UINT uFormat, HANDLE hMem)
{
- return NtUserSetClipboardData(uFormat, hMem, 0);
+ DWORD size;
+ LPVOID pMem;
+ HANDLE ret = NULL;
+
+ if (hMem == NULL)
+ {
+ return NtUserSetClipboardData(uFormat, 0, 0);
+ }
+
+ if (uFormat == CF_BITMAP)
+ {
+ /*FIXME: check if hMem is GDI handle
+ GlobalLock(hMem) fails && GetObject(hMem, 0, NULL) > 0
+ */
+ return NtUserSetClipboardData(uFormat, hMem, 0);
+ }
+
+ size = GlobalSize(hMem);
+ pMem = GlobalLock(hMem);
+
+ if ((pMem) && (size))
+ {
+ DPRINT1("[1]");
+ size = GlobalSize(hMem);
+ ret = NtUserSetClipboardData(uFormat, pMem, size);
+ //sholud i unlock hMmem?
+ GlobalUnlock(hMem);
+ }
+ else
+ {
+ DPRINT1("SetClipboardData fail\n");
+ }
+
+ return ret;
+
}
/*
@@ -237,3 +356,35 @@
{
return NtUserChangeClipboardChain(hWndRemove, hWndNewNext);
}
+
+/*
+ * @unimplemented
+ */
+BOOL STDCALL
+AddClipboardFormatListener(HWND hwnd)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+/*
+ * @unimplemented
+ */
+BOOL STDCALL
+RemoveClipboardFormatListener(HWND hwnd)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL STDCALL
+GetUpdatedClipboardFormats(
+ PUINT lpuiFormats,
+ UINT cFormats,
+ PUINT pcFormatsOut)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c Wed Aug 30 23:35:22 2006
@@ -984,7 +984,31 @@
VOID FASTCALL
DefWndScreenshot(HWND hWnd)
{
-
+ RECT rect;
+
+ OpenClipboard(hWnd);
+ EmptyClipboard();
+
+ HDC hdc = GetWindowDC(hWnd);
+ GetWindowRect(hWnd, &rect);
+ INT w = rect.right - rect.left;
+ INT h = rect.bottom - rect.top;
+
+ HBITMAP hbitmap = CreateCompatibleBitmap(hdc, w, h);
+ HDC hdc2 = CreateCompatibleDC(hdc);
+ SelectObject(hdc2, hbitmap);
+
+ BitBlt(hdc2, 0, 0, w, h,
+ hdc, 0, 0,
+ SRCCOPY);
+
+ SetClipboardData(CF_BITMAP, hbitmap);
+
+ ReleaseDC(hWnd, hdc);
+ ReleaseDC(hWnd, hdc2);
+
+ CloseClipboard();
+
}
LRESULT STDCALL
@@ -1354,6 +1378,10 @@
iF10Key = 1;
else if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) &
0x8000))
SendMessageW( hWnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
+ else if (wParam == VK_SNAPSHOT)
+ {
+ DefWndScreenshot(GetDesktopWindow());
+ }
break;
}
Modified: trunk/reactos/dll/win32/user32/windows/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/i…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/input.c (original)
+++ trunk/reactos/dll/win32/user32/windows/input.c Wed Aug 30 23:35:22 2006
@@ -290,13 +290,12 @@
/*
- * @unimplemented
+ * @implemented
*/
BOOL STDCALL
GetLastInputInfo(PLASTINPUTINFO plii)
{
- UNIMPLEMENTED;
- return FALSE;
+ return NtUserGetLastInputInfo(plii);
}