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

svn path=/trunk/; revision=23810
This commit is contained in:
Pablo Borobia 2006-08-30 19:35:22 +00:00
parent 3d10f77c92
commit 5a624910f1
4 changed files with 239 additions and 61 deletions

View file

@ -75,10 +75,10 @@
#define NtUserSetCaretBlinkTime(uMSeconds) \ #define NtUserSetCaretBlinkTime(uMSeconds) \
(BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME) (BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
/*
#define NtUserEnumClipboardFormats(format) \ #define NtUserEnumClipboardFormats(format) \
(UINT)NtUserCallOneParam(format, ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS) (UINT)NtUserCallOneParam(format, ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS)
*/
#define NtUserWindowFromDC(hDC) \ #define NtUserWindowFromDC(hDC) \
(HWND)NtUserCallOneParam((DWORD)hDC, ONEPARAM_ROUTINE_WINDOWFROMDC) (HWND)NtUserCallOneParam((DWORD)hDC, ONEPARAM_ROUTINE_WINDOWFROMDC)

View file

@ -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$ /* $Id$
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/clipboard.c * FILE: lib/user32/windows/clipboard.c
* PURPOSE: Input * PURPOSE: Input
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Pablo Borobia <pborobia@gmail.com>
* UPDATE HISTORY: * UPDATE HISTORY:
* 09-05-2001 CSH Created * 09-05-2001 CSH Created
*
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include <user32.h> #include <user32.h>
#define DEBUG
#include <wine/debug.h> #include <wine/debug.h>
#define QUERY_SIZE 0
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/* /*
@ -40,7 +28,8 @@
BOOL STDCALL BOOL STDCALL
OpenClipboard(HWND hWndNewOwner) OpenClipboard(HWND hWndNewOwner)
{ {
return NtUserOpenClipboard(hWndNewOwner, 0); BOOL ret = NtUserOpenClipboard(hWndNewOwner, 0);
return ret;
} }
/* /*
@ -49,7 +38,9 @@ OpenClipboard(HWND hWndNewOwner)
BOOL STDCALL BOOL STDCALL
CloseClipboard(VOID) CloseClipboard(VOID)
{ {
return NtUserCloseClipboard(); BOOL ret;
ret = NtUserCloseClipboard();
return ret;
} }
/* /*
@ -58,7 +49,8 @@ CloseClipboard(VOID)
INT STDCALL INT STDCALL
CountClipboardFormats(VOID) CountClipboardFormats(VOID)
{ {
return NtUserCountClipboardFormats(); INT ret = NtUserCountClipboardFormats();
return ret;
} }
/* /*
@ -67,7 +59,7 @@ CountClipboardFormats(VOID)
BOOL STDCALL BOOL STDCALL
EmptyClipboard(VOID) EmptyClipboard(VOID)
{ {
return NtUserEmptyClipboard(); return NtUserEmptyClipboard();
} }
/* /*
@ -76,7 +68,8 @@ EmptyClipboard(VOID)
UINT STDCALL UINT STDCALL
EnumClipboardFormats(UINT format) EnumClipboardFormats(UINT format)
{ {
return NtUserEnumClipboardFormats(format); UINT ret = NtUserEnumClipboardFormats(format);
return ret;
} }
/* /*
@ -85,7 +78,31 @@ EnumClipboardFormats(UINT format)
HANDLE STDCALL HANDLE STDCALL
GetClipboardData(UINT uFormat) 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 @@ GetClipboardData(UINT uFormat)
INT STDCALL INT STDCALL
GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount) GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
{ {
LPWSTR lpBuffer; LPWSTR lpBuffer;
UNICODE_STRING FormatName; UNICODE_STRING FormatName;
INT Length; INT Length;
ANSI_STRING ClassName;
ClassName.MaximumLength = cchMaxCount;
ClassName.Buffer = lpszFormatName;
lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR)); lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR));
if (!lpBuffer)
{ if (!lpBuffer)
SetLastError(ERROR_OUTOFMEMORY); {
return 0; SetLastError(ERROR_OUTOFMEMORY);
} return 0;
}
FormatName.Length = 0; FormatName.Length = 0;
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR); FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = lpBuffer; FormatName.Buffer = lpBuffer;
/* we need a UNICODE string */
Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount); 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 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
INT STDCALL INT STDCALL
GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount) GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount)
{ {
UNICODE_STRING FormatName; UNICODE_STRING FormatName;
ULONG Ret; ULONG Ret;
FormatName.Length = 0; FormatName.Length = 0;
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR); FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = (PWSTR)lpszFormatName; FormatName.Buffer = (PWSTR)lpszFormatName;
Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount); Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
DPRINT("GetClipboardFormatNameW(%x): returning %S\n", format, lpszFormatName); return Ret;
return Ret;
} }
/* /*
@ -177,7 +198,8 @@ GetOpenClipboardWindow(VOID)
INT STDCALL INT STDCALL
GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats) GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
{ {
return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats); INT ret = NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
return ret;
} }
/* /*
@ -186,18 +208,42 @@ GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
BOOL STDCALL BOOL STDCALL
IsClipboardFormatAvailable(UINT format) IsClipboardFormatAvailable(UINT format)
{ {
return NtUserIsClipboardFormatAvailable(format); BOOL ret = NtUserIsClipboardFormatAvailable(format);
return ret;
} }
/* /*
* @implemented * @implemented
*/ */
UINT STDCALL UINT STDCALL
RegisterClipboardFormatA(LPCSTR lpszFormat) RegisterClipboardFormatA(LPCSTR lpszFormat)
{ {
ULONG Ret = RegisterWindowMessageA(lpszFormat); UINT ret = 0;
DPRINT("RegisterClipboardFormatA(%s) - %x\n", lpszFormat, Ret); UNICODE_STRING usFormat = {0};
return Ret;
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 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
UINT STDCALL UINT STDCALL
RegisterClipboardFormatW(LPCWSTR lpszFormat) RegisterClipboardFormatW(LPCWSTR lpszFormat)
{ {
ULONG Ret = RegisterWindowMessageW(lpszFormat); UINT ret = 0;
DPRINT("RegisterClipboardFormatW(%S) - %x\n", lpszFormat, Ret); UNICODE_STRING usFormat = {0};
return Ret;
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 @@ RegisterClipboardFormatW(LPCWSTR lpszFormat)
HANDLE STDCALL HANDLE STDCALL
SetClipboardData(UINT uFormat, HANDLE hMem) 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 @@ ChangeClipboardChain(HWND hWndRemove, HWND hWndNewNext)
{ {
return NtUserChangeClipboardChain(hWndRemove, hWndNewNext); 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;
}

View file

@ -984,7 +984,31 @@ static void DefWndPrint( HWND hwnd, HDC hdc, ULONG uFlags)
VOID FASTCALL VOID FASTCALL
DefWndScreenshot(HWND hWnd) 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 LRESULT STDCALL
@ -1354,6 +1378,10 @@ User32DefWindowProc(HWND hWnd,
iF10Key = 1; iF10Key = 1;
else if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000)) else if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
SendMessageW( hWnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' ); SendMessageW( hWnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
else if (wParam == VK_SNAPSHOT)
{
DefWndScreenshot(GetDesktopWindow());
}
break; break;
} }

View file

@ -290,13 +290,12 @@ return (int)NtUserCallOneParam((DWORD) nTypeFlag, ONEPARAM_ROUTINE_GETKEYBOARDT
/* /*
* @unimplemented * @implemented
*/ */
BOOL STDCALL BOOL STDCALL
GetLastInputInfo(PLASTINPUTINFO plii) GetLastInputInfo(PLASTINPUTINFO plii)
{ {
UNIMPLEMENTED; return NtUserGetLastInputInfo(plii);
return FALSE;
} }