Merge clipboard branch to trunk

svn path=/trunk/; revision=26029
This commit is contained in:
Saveliy Tretiakov 2007-03-08 13:31:33 +00:00
parent 52913c361c
commit 59736af42b
19 changed files with 1851 additions and 328 deletions

View file

@ -431,8 +431,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
TCHAR szBuffer[MAX_PATH];
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath);
if (RegOpenKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"),
if (RegCreateKey(HKEY_CURRENT_USER,
g_szGeneralRegKey,
&hKey) == ERROR_SUCCESS)
{
RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0]));

View file

@ -1,4 +1,3 @@
/*
* file system folder
*
@ -55,6 +54,8 @@
WINE_DEFAULT_DEBUG_CHANNEL (shell);
extern BOOL fileMoving;
/***********************************************************************
* IShellFolder implementation
*/
@ -1232,11 +1233,14 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2,
(LPVOID *) & ppf2);
if (ppf2) {
if (ppf2)
{
LPITEMIDLIST pidl;
if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) {
for (i = 0; i < cidl; i++) {
if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl)))
{
for (i = 0; i < cidl; i++)
{
SHGetPathFromIDListA (pidl, szSrcPath);
PathAddBackslashA (szSrcPath);
_ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath),
@ -1246,7 +1250,43 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
PathAddBackslashA (szDstPath);
_ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath),
MAX_PATH);
MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath);
_ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath), MAX_PATH);
DPRINT1 ("copy %s to %s\n", szSrcPath, szDstPath);
if (fileMoving)
{
fileMoving = FALSE;
SHNotifyMoveFileA(szSrcPath, szDstPath);
}
else
{
SHNotifyCopyFileA(szSrcPath, szDstPath, TRUE);
}
/* FIXME: to work with folders we need SHFileOperation!
SHFILEOPSTRUCTA op;
if (fileMoving)
{
op.wFunc = FO_MOVE;
fileMoving = FALSE;
}
else
{
op.wFunc = FO_COPY;
}
op.pTo = szDstPath;
op.pFrom = szSrcPath;
op.fFlags = FOF_SIMPLEPROGRESS;
op.hwnd = NULL;
op.hNameMappings = NULL;
op.lpszProgressTitle = NULL;
UINT bRes = SHFileOperationA(&op);
DbgPrint("CopyItems SHFileOperationA 0x%08x\n", bRes);
*/
}
SHFree (pidl);
}

View file

@ -478,6 +478,65 @@ static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
return GetLastError();
}
DWORD SHNotifyMoveFileA(LPCSTR src, LPCSTR dest)
{
BOOL ret;
LPWSTR destW;
ret = MoveFileA(src, dest);
if (!ret)
{
DWORD dwAttr;
SHELL32_AnsiToUnicodeBuf(dest, &destW, 0);
dwAttr = SHFindAttrW(destW, FALSE);
SHELL32_FreeUnicodeBuf(destW);
if (INVALID_FILE_ATTRIBUTES == dwAttr)
{
/* Source file may be write protected or a system file */
dwAttr = GetFileAttributesA(src);
if (IsAttrib(dwAttr, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
if (SetFileAttributesA(src, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
ret = MoveFileA(src, dest);
}
}
if (ret)
{
//SHChangeNotify(SHCNE_RENAMEITEM, SHCNF_PATHA, src, dest);
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHA, dest, NULL);
SHChangeNotify(SHCNE_DELETE, SHCNF_PATHA, src, NULL);
return ERROR_SUCCESS;
}
return GetLastError();
}
/************************************************************************
* SHNotifyCopyFile [internal]
*
* Copies a file. Also triggers a change notify if one exists.
*
* PARAMS
* src [I] path to source file to move
* dest [I] path to target file to move to
* bFailIfExists [I] if TRUE, the target file will not be overwritten if
* a file with this name already exists
*
* RETURNS
* ERROR_SUCCESS if successful
*/
DWORD SHNotifyCopyFileA(LPCSTR src, LPCSTR dest, BOOL bFailIfExists)
{
BOOL ret;
ret = CopyFileA(src, dest, bFailIfExists);
if (ret)
{
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHA, dest, NULL);
return ERROR_SUCCESS;
}
return GetLastError();
}
/*************************************************************************
* SHCreateDirectory [SHELL32.165]
*
@ -650,6 +709,30 @@ static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
return dwAttr;
}
/*
DWORD SHFindAttrA(LPSTR pName, BOOL fileOnly)
{
WIN32_FIND_DATAA wfd;
BOOL b_FileMask = fileOnly && (NULL != StrPBrkA(pName, wWildcardChars));
DWORD dwAttr = INVALID_FILE_ATTRIBUTES;
HANDLE hFind = FindFirstFileA(pName, &wfd);
if (INVALID_HANDLE_VALUE != hFind)
{
do
{
if (b_FileMask && IsAttribDir(wfd.dwFileAttributes))
continue;
dwAttr = wfd.dwFileAttributes;
break;
}
while (FindNextFileA(hFind, &wfd));
FindClose(hFind);
}
return dwAttr;
}
*/
/*************************************************************************
*
* SHFileStrICmp HelperFunction for SHFileOperationW

View file

@ -18,6 +18,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#define COBJMACROS
@ -38,6 +39,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
extern BOOL fileMoving;
/**************************************************************************
* IContextMenu Implementation
*/
@ -215,6 +218,192 @@ static void DoNewFolder(
}
}
/***************************************************************************/
static BOOL DoLink(LPCSTR pSrcFile, LPCSTR pDstFile)
{
IShellLinkA *psl = NULL;
IPersistFile *pPf = NULL;
HRESULT hres;
WCHAR widelink[MAX_PATH];
BOOL ret = FALSE;
CoInitialize(0);
hres = CoCreateInstance( &CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IShellLinkA,
(LPVOID )&psl);
if(SUCCEEDED(hres))
{
hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile, (LPVOID *)&pPf);
if(FAILED(hres))
{
ERR("failed QueryInterface for IPersistFile %08lx\n", hres);
goto fail;
}
DPRINT1("shortcut point to %s\n", pSrcFile);
hres = IShellLinkA_SetPath(psl, pSrcFile);
if(FAILED(hres))
{
ERR("failed Set{IDList|Path} %08lx\n", hres);
goto fail;
}
MultiByteToWideChar(CP_ACP, 0, pDstFile, -1, widelink, MAX_PATH);
/* create the short cut */
hres = IPersistFile_Save(pPf, widelink, TRUE);
if(FAILED(hres))
{
ERR("failed IPersistFile::Save %08lx\n", hres);
IPersistFile_Release(pPf);
IShellLinkA_Release(psl);
goto fail;
}
hres = IPersistFile_SaveCompleted(pPf, widelink);
IPersistFile_Release(pPf);
IShellLinkA_Release(psl);
DPRINT1("shortcut %s has been created, result=%08lx\n", pDstFile, hres);
ret = TRUE;
}
else
{
DPRINT1("CoCreateInstance failed, hres=%08lx\n", hres);
}
fail:
CoUninitialize();
return ret;
}
static BOOL MakeLink(IContextMenu2 *iface)
{
BgCmImpl *This = (BgCmImpl *)iface;
BOOL bSuccess = FALSE;
IDataObject * pda;
TRACE("\n");
if(SUCCEEDED(OleGetClipboard(&pda)))
{
STGMEDIUM medium;
FORMATETC formatetc;
TRACE("pda=%p\n", pda);
/* Set the FORMATETC structure*/
InitFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
/* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(pda, &formatetc, &medium)))
{
LPITEMIDLIST * apidl;
LPITEMIDLIST pidl;
IShellFolder *psfFrom = NULL, *psfDesktop;
LPIDA lpcida = GlobalLock(medium.u.hGlobal);
TRACE("cida=%p\n", lpcida);
apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
/* bind to the source shellfolder */
SHGetDesktopFolder(&psfDesktop);
if(psfDesktop)
{
IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
IShellFolder_Release(psfDesktop);
}
if (psfFrom)
{
/* get source and destination shellfolder */
IPersistFolder2 *ppfdst = NULL;
IPersistFolder2 *ppfsrc = NULL;
IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppfdst);
IShellFolder_QueryInterface(psfFrom, &IID_IPersistFolder2, (LPVOID*)&ppfsrc);
DPRINT1("[%p,%p]\n",ppfdst,ppfsrc);
/* do the link/s */
/* hack to get desktop path */
if ( (ppfdst && ppfsrc) || (This->bDesktop && ppfsrc) )
{
int i;
char szSrcPath[MAX_PATH];
char szDstPath[MAX_PATH];
BOOL ret = FALSE;
LPITEMIDLIST pidl2;
char filename[MAX_PATH];
char linkFilename[MAX_PATH];
char srcFilename[MAX_PATH];
IPersistFolder2_GetCurFolder(ppfsrc, &pidl2);
SHGetPathFromIDListA (pidl2, szSrcPath);
if (This->bDesktop)
{
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &pidl2);
SHGetPathFromIDListA (pidl2, szDstPath);
}
else
{
IPersistFolder2_GetCurFolder(ppfdst, &pidl2);
SHGetPathFromIDListA (pidl2, szDstPath);
}
for (i = 0; i < lpcida->cidl; i++)
{
_ILSimpleGetText (apidl[i], filename, MAX_PATH);
DPRINT1("filename %s\n", filename);
lstrcpyA(linkFilename, szDstPath);
PathAddBackslashA(linkFilename);
lstrcatA(linkFilename, "Shortcut to ");
lstrcatA(linkFilename, filename);
lstrcatA(linkFilename, ".lnk");
DPRINT1("linkFilename %s\n", linkFilename);
lstrcpyA(srcFilename, szSrcPath);
PathAddBackslashA(srcFilename);
lstrcatA(srcFilename, filename);
DPRINT1("srcFilename %s\n", srcFilename);
ret = DoLink(srcFilename, linkFilename);
if (ret)
{
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHA, linkFilename, NULL);
}
}
}
if(ppfdst) IPersistFolder2_Release(ppfdst);
if(ppfsrc) IPersistFolder2_Release(ppfsrc);
IShellFolder_Release(psfFrom);
}
_ILFreeaPidl(apidl, lpcida->cidl);
SHFree(pidl);
/* release the medium*/
ReleaseStgMedium(&medium);
}
IDataObject_Release(pda);
}
return bSuccess;
}
/**************************************************************************
* DoPaste
*/
@ -261,16 +450,27 @@ static BOOL DoPaste(
{
/* get source and destination shellfolder */
ISFHelper *psfhlpdst, *psfhlpsrc;
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
if (This->bDesktop)
{
/* unimplemented
SHGetDesktopFolder(&psfDesktop);
IFSFolder_Constructor(psfDesktop, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
IShellFolder_QueryInterface(psfhlpdst, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
*/
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
}
else
{
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
}
IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc);
/* do the copy/move */
if (psfhlpdst && psfhlpsrc)
{
ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl);
/* FIXME handle move
ISFHelper_DeleteItems(psfhlpsrc, lpcida->cidl, apidl);
*/
}
if(psfhlpdst) ISFHelper_Release(psfhlpdst);
if(psfhlpsrc) ISFHelper_Release(psfhlpsrc);
@ -285,30 +485,7 @@ static BOOL DoPaste(
}
IDataObject_Release(pda);
}
#if 0
HGLOBAL hMem;
OpenClipboard(NULL);
hMem = GetClipboardData(CF_HDROP);
if(hMem)
{
char * pDropFiles = (char *)GlobalLock(hMem);
if(pDropFiles)
{
int len, offset = sizeof(DROPFILESTRUCT);
while( pDropFiles[offset] != 0)
{
len = strlen(pDropFiles + offset);
TRACE("%s\n", pDropFiles + offset);
offset += len+1;
}
}
GlobalUnlock(hMem);
}
CloseClipboard();
#endif
return bSuccess;
}
@ -373,6 +550,10 @@ static HRESULT WINAPI ISVBgCm_fnInvokeCommand(
DoPaste(iface);
break;
case FCIDM_SHVIEW_INSERTLINK:
MakeLink(iface);
break;
case FCIDM_SHVIEW_PROPERTIES:
if (This->bDesktop) {
ShellExecuteA(lpcmi->hwnd, "open", "rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL);

View file

@ -39,6 +39,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/* ugly hack for cut&psate files */
BOOL fileMoving = FALSE;
/**************************************************************************
* IContextMenu Implementation
*/
@ -373,6 +376,8 @@ static BOOL DoCopyOrCut(
LPSHELLVIEW lpSV;
LPDATAOBJECT lpDo;
fileMoving = bCut;
TRACE("(%p)->(wnd=%p,bCut=0x%08x)\n",This, hwnd, bCut);
/* get the active IShellView */

View file

@ -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)

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$
*
* 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 *****************************************************************/
/*
@ -40,7 +28,8 @@
BOOL STDCALL
OpenClipboard(HWND hWndNewOwner)
{
return NtUserOpenClipboard(hWndNewOwner, 0);
BOOL ret = NtUserOpenClipboard(hWndNewOwner, 0);
return ret;
}
/*
@ -49,7 +38,9 @@ OpenClipboard(HWND hWndNewOwner)
BOOL STDCALL
CloseClipboard(VOID)
{
return NtUserCloseClipboard();
BOOL ret;
ret = NtUserCloseClipboard();
return ret;
}
/*
@ -58,7 +49,8 @@ CloseClipboard(VOID)
INT STDCALL
CountClipboardFormats(VOID)
{
return NtUserCountClipboardFormats();
INT ret = NtUserCountClipboardFormats();
return ret;
}
/*
@ -67,7 +59,7 @@ CountClipboardFormats(VOID)
BOOL STDCALL
EmptyClipboard(VOID)
{
return NtUserEmptyClipboard();
return NtUserEmptyClipboard();
}
/*
@ -76,7 +68,8 @@ EmptyClipboard(VOID)
UINT STDCALL
EnumClipboardFormats(UINT format)
{
return NtUserEnumClipboardFormats(format);
UINT ret = NtUserEnumClipboardFormats(format);
return ret;
}
/*
@ -85,7 +78,31 @@ EnumClipboardFormats(UINT format)
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 @@ GetClipboardData(UINT uFormat)
INT STDCALL
GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
{
LPWSTR lpBuffer;
UNICODE_STRING FormatName;
INT Length;
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;
}
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 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
INT STDCALL
GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount)
{
UNICODE_STRING FormatName;
ULONG Ret;
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;
FormatName.Length = 0;
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = (PWSTR)lpszFormatName;
Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
return Ret;
}
/*
@ -177,7 +198,8 @@ GetOpenClipboardWindow(VOID)
INT STDCALL
GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
{
return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
INT ret = NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
return ret;
}
/*
@ -186,18 +208,41 @@ GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
BOOL STDCALL
IsClipboardFormatAvailable(UINT format)
{
return NtUserIsClipboardFormatAvailable(format);
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 +251,48 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
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 +301,54 @@ RegisterClipboardFormatW(LPCWSTR lpszFormat)
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)
{
/* GlobalLock should return 0 for GDI handles
pMem = GlobalLock(hMem);
if (pMem)
{
// not a GDI handle
GlobalUnlock(hMem);
return ret;
}
else
{
*/
/* check if this GDI handle is a HBITMAP */
/* GetObject for HBITMAP not implemented in ReactOS */
//if (GetObject(hMem, 0, NULL) == sifeof(BITMAP))
//{
return NtUserSetClipboardData(CF_BITMAP, hMem, 0);
//}
/*}*/
}
size = GlobalSize(hMem);
pMem = GlobalLock(hMem);
if ((pMem) && (size))
{
size = GlobalSize(hMem);
ret = NtUserSetClipboardData(uFormat, pMem, size);
//should i unlock hMem?
GlobalUnlock(hMem);
}
else
{
DPRINT1("SetClipboardData failed\n");
}
return ret;
}
/*
@ -237,3 +368,35 @@ ChangeClipboardChain(HWND hWndRemove, HWND 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
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();
}
@ -1349,7 +1373,12 @@ User32DefWindowProc(HWND hWnd,
}
else if (wParam == VK_SNAPSHOT)
{
DefWndScreenshot(hWnd);
HWND hwnd = hWnd;
while (GetParent(hwnd) != NULL)
{
hwnd = GetParent(hwnd);
}
DefWndScreenshot(hwnd);
}
}
else if( wParam == VK_F10 )

View file

@ -54,6 +54,8 @@ extern "C" {
#define HCBT_KEYSKIPPED 7
#define HCBT_SYSCOMMAND 8
#define HCBT_SETFOCUS 9
/* Predefined Clipboard Formats */
#define CF_TEXT 1
#define CF_BITMAP 2
#define CF_METAFILEPICT 3
@ -68,9 +70,24 @@ extern "C" {
#define CF_WAVE 12
#define CF_UNICODETEXT 13
#define CF_ENHMETAFILE 14
#define CF_HDROP 15
#define CF_LOCALE 16
#define CF_MAX 17
#if(WINVER >= 0x0400)
#define CF_HDROP 15
#define CF_LOCALE 16
#endif
#if(WINVER >= 0x0500)
#define CF_DIBV5 17
#endif
#if(WINVER >= 0x0500)
#define CF_MAX 18
#elif(WINVER >= 0x0400)
#define CF_MAX 17
#else
#define CF_MAX 15
#endif
#define CF_OWNERDISPLAY 128
#define CF_DSPTEXT 129
#define CF_DSPBITMAP 130
@ -80,6 +97,7 @@ extern "C" {
#define CF_PRIVATELAST 767
#define CF_GDIOBJFIRST 768
#define CF_GDIOBJLAST 1023
#define HKL_NEXT 1
#define HKL_PREV 0
#define KLF_ACTIVATE 1

View file

@ -122,7 +122,12 @@ NtUserEnableMenuItem(
HMENU hMenu,
UINT uIDEnableItem,
UINT uEnable);
UINT
NTAPI
NtUserEnumClipboardFormats(
UINT format);
DWORD
NTAPI
NtUserInsertMenuItem(
@ -1038,6 +1043,11 @@ NTAPI
NtUserGetKeyState(
DWORD Unknown0);
BOOL
NTAPI
NtUserGetLastInputInfo(
PLASTINPUTINFO plii);
DWORD
NTAPI
NtUserGetListBoxInfo(
@ -1439,6 +1449,11 @@ NtUserRegisterClassEx(
WNDPROC wpExtra,
DWORD Flags,
HMENU hMenu);
UINT
NTAPI
NtUserRegisterClipboardFormat(
PUNICODE_STRING format);
BOOL
NTAPI

View file

@ -1,7 +1,48 @@
#ifndef _WIN32K_CLIPBOARD_H
#define _WIN32K_CLIPBOARD_H
#include "window.h"
VOID FASTCALL IntIncrementSecuenceNumber(VOID);
typedef struct _ClipboardChainElement
{
PWINDOW_OBJECT window;
struct _ClipboardChainElement *next;
} CLIPBOARDCHAINELEMENT, *PCLIPBOARDCHAINELEMENT;
typedef struct _ClipboardElement
{
UINT format;
HANDLE hData;
DWORD size; // data may be delayed o synth render
struct _ClipboardElement *next;
} CLIPBOARDELEMENT, *PCLIPBOARDELEMENT;
typedef struct _CLIPBOARDSYSTEM
{
PW32THREAD ClipboardThread;
PW32THREAD ClipboardOwnerThread;
PWINDOW_OBJECT ClipboardWindow;
PWINDOW_OBJECT ClipboardViewerWindow;
PWINDOW_OBJECT ClipboardOwnerWindow;
BOOL sendDrawClipboardMsg;
BOOL recentlySetClipboard;
BOOL delayedRender;
UINT lastEnumClipboardFormats;
DWORD ClipboardSequenceNumber;
PCLIPBOARDCHAINELEMENT WindowsChain;
PCLIPBOARDELEMENT ClipboardData;
PCHAR synthesizedData;
DWORD synthesizedDataSize;
} CLIPBOARDSYSTEM, *PCLIPBOARDSYSTEM;
/*
UINT FASTCALL
IntEnumClipboardFormats(UINT format);
*/
#endif /* _WIN32K_CLIPBOARD_H */

View file

@ -2,6 +2,7 @@
#define _WIN32K_WINSTA_H
#include "msgqueue.h"
#include "clipboard.h"
#define WINSTA_ROOT_NAME L"\\Windows\\WindowStations"
#define WINSTA_ROOT_NAME_LENGTH 23
@ -45,7 +46,10 @@ typedef struct _WINSTATION_OBJECT
ULONG Flags;
struct _DESKTOP_OBJECT* ActiveDesktop;
/* FIXME: Clipboard */
PCLIPBOARDSYSTEM Clipboard;
DWORD ClipboardSequenceNumber;
} WINSTATION_OBJECT, *PWINSTATION_OBJECT;
extern WINSTATION_OBJECT *InputWindowStation;

File diff suppressed because it is too large Load diff

View file

@ -308,10 +308,10 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_SETCARETBLINKTIME:
RETURN( (DWORD)IntSetCaretBlinkTime((UINT)Param));
/*
case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
RETURN( (DWORD)IntEnumClipboardFormats((UINT)Param));
RETURN( (DWORD)NtUserEnumClipboardFormats((UINT)Param));
*/
case ONEPARAM_ROUTINE_GETWINDOWINSTANCE:
{
PWINDOW_OBJECT Window;

View file

@ -32,7 +32,6 @@
RTL_ATOM FASTCALL
IntAddAtom(LPWSTR AtomName)
{
PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status = STATUS_SUCCESS;
RTL_ATOM Atom;
@ -41,9 +40,9 @@ IntAddAtom(LPWSTR AtomName)
SetLastNtError(Status);
return (RTL_ATOM)0;
}
WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation;
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
AtomName, &Atom);
Status = RtlAddAtomToAtomTable(gAtomTable, AtomName, &Atom);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
@ -55,7 +54,6 @@ IntAddAtom(LPWSTR AtomName)
ULONG FASTCALL
IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
{
PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status = STATUS_SUCCESS;
ULONG Size = nSize;
@ -64,9 +62,9 @@ IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
SetLastNtError(Status);
return 0;
}
WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation;
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
nAtom, NULL, NULL, lpBuffer, &Size);
Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size);
if (Size < nSize)
*(lpBuffer + Size) = 0;
if (!NT_SUCCESS(Status))

View file

@ -30,7 +30,7 @@
#include <w32k.h>
#define NDEBUG
#define YDEBUG
#include <debug.h>
/* dialog resources appear to pass this in 16 bits, handle them properly */
@ -461,6 +461,8 @@ static LRESULT co_UserFreeWindow(PWINDOW_OBJECT Window,
UserDerefObject(Window);
IntClipboardFreeWindow(Window);
return 0;
}
@ -1888,17 +1890,19 @@ co_IntCreateWindowEx(DWORD dwExStyle,
/* Calculate the non-client size. */
MaxPos.x = Window->WindowRect.left;
MaxPos.y = Window->WindowRect.top;
DPRINT("IntCreateWindowEx(): About to get non-client size.\n");
/* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */
Result = co_WinPosGetNonClientSize(Window,
&Window->WindowRect,
&Window->ClientRect);
IntGdiOffsetRect(&Window->WindowRect,
MaxPos.x - Window->WindowRect.left,
MaxPos.y - Window->WindowRect.top);
if (NULL != ParentWindow)
{
/* link the window into the parent's child list */

View file

@ -969,6 +969,8 @@ co_WinPosSetWindowPos(
}
WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect);
//DPRINT1("co_WinPosDoNCCALCSize");
/* Relink windows. (also take into account shell window in hwndShellWindow) */
if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != UserGetShellWindow())
@ -1385,7 +1387,8 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
break;
case SW_SHOWNOACTIVATE:
Swp |= SWP_NOZORDER;
//Swp |= SWP_NOZORDER;
Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
/* Fall through. */
case SW_SHOWNORMAL:
case SW_SHOWDEFAULT:
@ -1408,6 +1411,7 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
}
ShowFlag = (Cmd != SW_HIDE);
if (ShowFlag != WasVisible)
{
co_IntSendMessage(Window->hSelf, WM_SHOWWINDOW, ShowFlag, 0);
@ -1477,6 +1481,7 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
MAKELONG(Window->ClientRect.left,
Window->ClientRect.top));
IntEngWindowChanged(Window, WOC_RGN_CLIENT);
}
/* Activate the window if activation is not requested and the window is not minimized */

View file

@ -517,7 +517,13 @@ NtUserCreateWindowStation(
CurInfo->DblClickHeight = 4;
WindowStationObject->SystemCursor = CurInfo;
if (!IntSetupClipboard(WindowStationObject))
{
DPRINT1("WindowStation: Error Setting up the clipboard!!!\n");
}
if (!IntSetupCurIconHandles(WindowStationObject))
{
DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");

View file

@ -342,6 +342,7 @@ NtUserEnableScrollBar 3
NtUserEndDeferWindowPosEx 2
NtUserEndMenu 0
NtUserEndPaint 2
NtUserEnumClipboardFormats 1
NtUserEnumDisplayDevices 4
NtUserEnumDisplayMonitors 5
NtUserEnumDisplaySettings 4
@ -461,6 +462,7 @@ NtUserReleaseDC 2
NtUserRealChildWindowFromPoint 3
NtUserRedrawWindow 4
NtUserRegisterClassEx 6
NtUserRegisterClipboardFormat 1
NtUserRegisterHotKey 4
NtUserRegisterTasklist 1
NtUserRegisterWindowMessage 1