Author: pborobia Date: Fri Sep 1 06:46:29 2006 New Revision: 23851
URL: http://svn.reactos.org/svn/reactos?rev=23851&view=rev Log: * Added clipboard implementation in user32 * Added clipboard entries in nci tool * Added lost clipboard definitions * Shut up debug
Modified: branches/clipboard/dll/win32/user32/include/user32p.h branches/clipboard/dll/win32/user32/windows/clipboard.c branches/clipboard/include/reactos/win32k/ntuser.h branches/clipboard/subsystems/win32/win32k/ntuser/clipboard.c branches/clipboard/tools/nci/w32ksvc.db
Modified: branches/clipboard/dll/win32/user32/include/user32p.h URL: http://svn.reactos.org/svn/reactos/branches/clipboard/dll/win32/user32/inclu... ============================================================================== --- branches/clipboard/dll/win32/user32/include/user32p.h (original) +++ branches/clipboard/dll/win32/user32/include/user32p.h Fri Sep 1 06:46:29 2006 @@ -76,8 +76,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: branches/clipboard/dll/win32/user32/windows/clipboard.c URL: http://svn.reactos.org/svn/reactos/branches/clipboard/dll/win32/user32/windo... ============================================================================== --- branches/clipboard/dll/win32/user32/windows/clipboard.c (original) +++ branches/clipboard/dll/win32/user32/windows/clipboard.c Fri Sep 1 06:46:29 2006 @@ -1,20 +1,25 @@ - /* $Id$ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/clipboard.c * PURPOSE: Input * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) + * Pablo Borobia pborobia@gmail.com * UPDATE HISTORY: * 09-05-2001 CSH Created + * */
/* INCLUDES ******************************************************************/
#include <user32.h>
+#define NDEBUG + #include <wine/debug.h>
+#define QUERY_SIZE 0 + /* FUNCTIONS *****************************************************************/
/* @@ -23,7 +28,8 @@ BOOL STDCALL OpenClipboard(HWND hWndNewOwner) { - return NtUserOpenClipboard(hWndNewOwner, 0); + BOOL ret = NtUserOpenClipboard(hWndNewOwner, 0); + return ret; }
/* @@ -32,7 +38,9 @@ BOOL STDCALL CloseClipboard(VOID) { - return NtUserCloseClipboard(); + BOOL ret; + ret = NtUserCloseClipboard(); + return ret; }
/* @@ -41,7 +49,8 @@ INT STDCALL CountClipboardFormats(VOID) { - return NtUserCountClipboardFormats(); + INT ret = NtUserCountClipboardFormats(); + return ret; }
/* @@ -50,7 +59,7 @@ BOOL STDCALL EmptyClipboard(VOID) { - return NtUserEmptyClipboard(); + return NtUserEmptyClipboard(); }
/* @@ -59,7 +68,8 @@ UINT STDCALL EnumClipboardFormats(UINT format) { - return NtUserEnumClipboardFormats(format); + UINT ret = NtUserEnumClipboardFormats(format); + return ret; }
/* @@ -68,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; }
/* @@ -77,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); }
/* @@ -107,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; + }
/* @@ -160,7 +198,8 @@ INT STDCALL GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats) { - return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats); + INT ret = NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats); + return ret; }
/* @@ -169,18 +208,41 @@ 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; }
/* @@ -189,9 +251,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; }
/* @@ -200,7 +301,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; + }
/* @@ -220,3 +355,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: branches/clipboard/include/reactos/win32k/ntuser.h URL: http://svn.reactos.org/svn/reactos/branches/clipboard/include/reactos/win32k... ============================================================================== --- branches/clipboard/include/reactos/win32k/ntuser.h (original) +++ branches/clipboard/include/reactos/win32k/ntuser.h Fri Sep 1 06:46:29 2006 @@ -122,7 +122,12 @@ HMENU hMenu, UINT uIDEnableItem, UINT uEnable); - + +UINT +NTAPI +NtUserEnumClipboardFormats( + UINT format); + DWORD NTAPI NtUserInsertMenuItem( @@ -1439,6 +1444,11 @@ WNDPROC wpExtra, DWORD Flags, HMENU hMenu); + +UINT +NTAPI +NtUserRegisterClipboardFormat( + PUNICODE_STRING format);
BOOL NTAPI
Modified: branches/clipboard/subsystems/win32/win32k/ntuser/clipboard.c URL: http://svn.reactos.org/svn/reactos/branches/clipboard/subsystems/win32/win32... ============================================================================== --- branches/clipboard/subsystems/win32/win32k/ntuser/clipboard.c (original) +++ branches/clipboard/subsystems/win32/win32k/ntuser/clipboard.c Fri Sep 1 06:46:29 2006 @@ -9,7 +9,7 @@
#include <w32k.h>
-#define DEBUG +#define NDEBUG #include <debug.h>
#define DATA_DELAYED_RENDER 0 @@ -472,7 +472,7 @@ if (sendDrawClipboardMsg && WindowsChain) { /* only send message to the first window in the chain, then they'll do the chain */ - /* commented because it makes a crash in co_MsqSendMessage + /* commented because it makes a crash in co_MsqSendMessage ASSERT(WindowsChain->window); ASSERT(WindowsChain->window->hSelf); DPRINT1("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", WindowsChain->window->hSelf);
Modified: branches/clipboard/tools/nci/w32ksvc.db URL: http://svn.reactos.org/svn/reactos/branches/clipboard/tools/nci/w32ksvc.db?r... ============================================================================== --- branches/clipboard/tools/nci/w32ksvc.db (original) +++ branches/clipboard/tools/nci/w32ksvc.db Fri Sep 1 06:46:29 2006 @@ -341,6 +341,7 @@ NtUserEndDeferWindowPosEx 2 NtUserEndMenu 0 NtUserEndPaint 2 +NtUserEnumClipboardFormats 1 NtUserEnumDisplayDevices 4 NtUserEnumDisplayMonitors 5 NtUserEnumDisplaySettings 4 @@ -459,6 +460,7 @@ NtUserRealChildWindowFromPoint 3 NtUserRedrawWindow 4 NtUserRegisterClassEx 6 +NtUserRegisterClipboardFormat 1 NtUserRegisterHotKey 4 NtUserRegisterTasklist 1 NtUserRegisterWindowMessage 1