Revert r23810, r23811, r23813. The clipboard changes are in the clipboard branch for now.

svn path=/trunk/; revision=23823
This commit is contained in:
Thomas Bluemel 2006-08-30 20:40:07 +00:00
parent 15d6307da5
commit a65807043a
10 changed files with 109 additions and 807 deletions

View file

@ -148,8 +148,6 @@ void FreeChangeNotifications(void);
BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI);
BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI);
BOOL SHELL_ConfirmDialog(int nKindOfDialog, LPCSTR szDir);
DWORD SHNotifyMoveFileA(LPCSTR src, LPCSTR dest);
DWORD SHNotifyCopyFileA(LPCSTR src, LPCSTR dest, BOOL bFailIfExists);
/* 16-bit functions */
void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b);

View file

@ -1154,8 +1154,6 @@ ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName,
return hres;
}
extern BOOL fileMoving;
/****************************************************************************
* ISFHelper_fnDeleteItems
*
@ -1170,7 +1168,7 @@ ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
BOOL bConfirm = TRUE;
TRACE ("(%p)(%u %p)\n", This, cidl, apidl);
/* deleting multiple items so give a slightly different warning */
if (cidl != 1) {
char tmp[8];
@ -1180,7 +1178,7 @@ ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
return E_FAIL;
bConfirm = FALSE;
}
for (i = 0; i < cidl; i++) {
strcpy (szPath, This->sPathTarget);
PathAddBackslashA (szPath);
@ -1238,8 +1236,7 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
LPITEMIDLIST pidl;
if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) {
for (i = 0; i < cidl; i++)
{
for (i = 0; i < cidl; i++) {
SHGetPathFromIDListA (pidl, szSrcPath);
PathAddBackslashA (szSrcPath);
_ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath),
@ -1247,43 +1244,9 @@ ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl,
strcpy (szDstPath, This->sPathTarget);
PathAddBackslashA (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);
}
/*
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);
*/
_ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath),
MAX_PATH);
MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath);
}
SHFree (pidl);
}
@ -1595,11 +1558,9 @@ static HRESULT WINAPI
ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject,
DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
{
DWORD dwEffect = *pdwEffect;
IGenericSFImpl *This = impl_from_IDropTarget(iface);
FIXME ("(%p) object dropped(%d)\n", This, dwKeyState);
FIXME ("(%p) object dropped\n", This);
return E_NOTIMPL;
}

View file

@ -478,65 +478,6 @@ 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]
*
@ -708,29 +649,7 @@ 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

@ -38,8 +38,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
extern BOOL fileMoving;
/**************************************************************************
* IContextMenu Implementation
*/
@ -217,198 +215,6 @@ 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];
DbgPrint("&&&");
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);
DbgPrint("filename %s\n", filename);
lstrcpyA(linkFilename, szDstPath);
PathAddBackslashA(linkFilename);
//lstrcatA(linkFilename, "Shortcut to ");
lstrcatA(linkFilename, filename);
lstrcatA(linkFilename, ".lnk");
DbgPrint("linkFilename %s\n", linkFilename);
lstrcpyA(srcFilename, szSrcPath);
PathAddBackslashA(srcFilename);
lstrcatA(srcFilename, filename);
DbgPrint("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
*/
@ -420,19 +226,19 @@ static BOOL DoPaste(
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)))
if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium)))
{
LPITEMIDLIST * apidl;
LPITEMIDLIST pidl;
@ -442,7 +248,7 @@ static BOOL DoPaste(
TRACE("cida=%p\n", lpcida);
apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
/* bind to the source shellfolder */
SHGetDesktopFolder(&psfDesktop);
if(psfDesktop)
@ -455,28 +261,17 @@ static BOOL DoPaste(
{
/* get source and destination shellfolder */
ISFHelper *psfhlpdst, *psfhlpsrc;
if (This->bDesktop)
{
/* unimplemented*/
SHGetDesktopFolder(&psfDesktop);
IFSFolder_Constructor(psfDesktop, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
IShellFolder_QueryInterface(psfhlpdst, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
}
else
{
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
}
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlpdst);
IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (LPVOID*)&psfhlpsrc);
DPRINT1("[%p,%p]\n",psfhlpdst,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);
IShellFolder_Release(psfFrom);
@ -490,7 +285,30 @@ 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;
}
@ -517,6 +335,7 @@ static HRESULT WINAPI ISVBgCm_fnInvokeCommand(
IShellView_GetWindow(lpSV, &hWndSV);
}
}
if(HIWORD(lpcmi->lpVerb))
{
TRACE("%s\n",lpcmi->lpVerb);
@ -554,10 +373,6 @@ 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,10 +39,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/* ugly hack for cut&psate files */
BOOL fileMoving = FALSE;
/**************************************************************************
* IContextMenu Implementation
*/
@ -102,7 +98,7 @@ IContextMenu2 *ISvItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl
{
cm->bAllValues &= (_ILIsValue(apidl[u]) ? 1 : 0);
}
TRACE("(%p)->()\n",cm);
return (IContextMenu2*)cm;
@ -378,10 +374,9 @@ static BOOL DoCopyOrCut(
LPDATAOBJECT lpDo;
TRACE("(%p)->(wnd=%p,bCut=0x%08x)\n",This, hwnd, bCut);
fileMoving = bCut;
/* get the active IShellView */
if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER, 0, 0)))
if ((lpSB = (LPSHELLBROWSER)SendMessageA(hwnd, CWM_GETISHELLBROWSER,0,0)))
{
if (SUCCEEDED(IShellBrowser_QueryActiveShellView(lpSB, &lpSV)))
{

View file

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

View file

@ -1,25 +1,37 @@
/*
* 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 DEBUG
#include <wine/debug.h>
#define QUERY_SIZE 0
/* FUNCTIONS *****************************************************************/
/*
@ -28,8 +40,7 @@
BOOL STDCALL
OpenClipboard(HWND hWndNewOwner)
{
BOOL ret = NtUserOpenClipboard(hWndNewOwner, 0);
return ret;
return NtUserOpenClipboard(hWndNewOwner, 0);
}
/*
@ -38,9 +49,7 @@ OpenClipboard(HWND hWndNewOwner)
BOOL STDCALL
CloseClipboard(VOID)
{
BOOL ret;
ret = NtUserCloseClipboard();
return ret;
return NtUserCloseClipboard();
}
/*
@ -49,8 +58,7 @@ CloseClipboard(VOID)
INT STDCALL
CountClipboardFormats(VOID)
{
INT ret = NtUserCountClipboardFormats();
return ret;
return NtUserCountClipboardFormats();
}
/*
@ -59,7 +67,7 @@ CountClipboardFormats(VOID)
BOOL STDCALL
EmptyClipboard(VOID)
{
return NtUserEmptyClipboard();
return NtUserEmptyClipboard();
}
/*
@ -68,8 +76,7 @@ EmptyClipboard(VOID)
UINT STDCALL
EnumClipboardFormats(UINT format)
{
UINT ret = NtUserEnumClipboardFormats(format);
return ret;
return NtUserEnumClipboardFormats(format);
}
/*
@ -78,31 +85,7 @@ EnumClipboardFormats(UINT format)
HANDLE STDCALL
GetClipboardData(UINT uFormat)
{
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;
return NtUserGetClipboardData(uFormat, 0);
}
/*
@ -111,32 +94,28 @@ GetClipboardData(UINT uFormat)
INT STDCALL
GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
{
LPWSTR lpBuffer;
UNICODE_STRING FormatName;
INT Length;
ANSI_STRING ClassName;
ClassName.MaximumLength = cchMaxCount;
ClassName.Buffer = lpszFormatName;
LPWSTR lpBuffer;
UNICODE_STRING FormatName;
INT Length;
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);
HEAP_strcpyWtoA(lpszFormatName, FormatName.Buffer, Length);
return strlen(lpszFormatName);
return Length;
}
/*
@ -145,15 +124,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);
return 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;
}
/*
@ -198,8 +177,7 @@ GetOpenClipboardWindow(VOID)
INT STDCALL
GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
{
INT ret = NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
return ret;
return NtUserGetPriorityClipboardFormat(paFormatPriorityList, cFormats);
}
/*
@ -208,42 +186,18 @@ GetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats)
BOOL STDCALL
IsClipboardFormatAvailable(UINT format)
{
BOOL ret = NtUserIsClipboardFormatAvailable(format);
return ret;
return NtUserIsClipboardFormatAvailable(format);
}
/*
* @implemented
*/
UINT STDCALL
RegisterClipboardFormatA(LPCSTR lpszFormat)
{
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;
ULONG Ret = RegisterWindowMessageA(lpszFormat);
DPRINT("RegisterClipboardFormatA(%s) - %x\n", lpszFormat, Ret);
return Ret;
}
/*
@ -252,48 +206,9 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
UINT STDCALL
RegisterClipboardFormatW(LPCWSTR lpszFormat)
{
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;
ULONG Ret = RegisterWindowMessageW(lpszFormat);
DPRINT("RegisterClipboardFormatW(%S) - %x\n", lpszFormat, Ret);
return Ret;
}
/*
@ -302,41 +217,7 @@ HGLOBAL renderLocale (DWORD Locale)
HANDLE STDCALL
SetClipboardData(UINT uFormat, HANDLE hMem)
{
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;
return NtUserSetClipboardData(uFormat, hMem, 0);
}
/*
@ -356,35 +237,3 @@ 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,31 +984,7 @@ 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();
}
LRESULT STDCALL
@ -1378,10 +1354,6 @@ User32DefWindowProc(HWND hWnd,
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;
}

View file

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

View file

@ -18,20 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _WIN32_WINNT 0x0501
#include "wine/test.h"
#include "windows.h"
static BOOL is_win9x = FALSE;
static DWORD sn; /* to test Secuence Number */
#define test_last_error(expected_error) \
do \
{ \
if (!is_win9x) \
ok(GetLastError() == expected_error, \
"Last error should be set to %ld, not %ld\n", \
"Last error should be set to %d, not %ld\n", \
expected_error, GetLastError()); \
} while (0)
@ -58,12 +55,7 @@ static void test_ClipboardOwner(void)
ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
test_last_error(ERROR_CLIPBOARD_NOT_OPEN);
SetLastError(0xdeadbeef);
ok(OpenClipboard(0), "OpenClipboard failed\n");
test_last_error((long)0xdeadbeef);
ok(OpenClipboard(0), "OpenClipboard failed\n");
test_last_error((long)0xdeadbeef);
ok(!GetClipboardOwner(), "clipboard should still be not owned\n");
ok(!OpenClipboard(hWnd1), "OpenClipboard should fail since clipboard already opened\n");
ret = CloseClipboard();
@ -86,114 +78,15 @@ static void test_ClipboardOwner(void)
"OpenClipboard should fail without setting last error value\n");
ret = CloseClipboard();
ok(ret, "CloseClipboard error %ld\n", GetLastError());
ok( ret, "CloseClipboard error %ld\n", GetLastError());
ok(GetClipboardOwner() == hWnd1, "clipboard should still be owned\n");
ret = DestroyWindow(hWnd1);
ok(ret, "DestroyWindow error %ld\n", GetLastError());
ok( ret, "DestroyWindow error %ld\n", GetLastError());
ret = DestroyWindow(hWnd2);
ok(ret, "DestroyWindow error %ld\n", GetLastError());
ok( ret, "DestroyWindow error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n");
hWnd1 = CreateWindowExA(0, "static", NULL, WS_POPUP,
0, 0, 10, 10, 0, 0, 0, NULL);
ok(hWnd1 != 0, "CreateWindowExA error %ld\n", GetLastError());
trace("hWnd1 = %p\n", hWnd1);
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
ret = DestroyWindow(hWnd1);
ok(ret, "DestroyWindow error %ld\n", GetLastError());
ok(OpenClipboard(0), "OpenClipboard should not fail\n");
ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
DWORD asn = GetClipboardSequenceNumber();
ok(asn == sn + 2, "GetClipboardSequenceNumber() returns %d, not %d\n", (int)asn, (int)sn + 2);
}
static void test_EnumClipboardFormats(void)
{
SetLastError(0xdeadbeef);
ok(!EnumClipboardFormats(0), "EnumClipboardFormats failed\n");
test_last_error(ERROR_CLIPBOARD_NOT_OPEN);
UINT j = 0;
UINT i = 1;
/*
ok( OpenClipboard(NULL), "OpenClipboard error %ld\n", GetLastError());
ok(!(j = EnumClipboardFormats(0)), "EnumClipboardFormats failed\n");
while (j!=0)
{
j = EnumClipboardFormats(j);
i++;
}
ok(!(j != CountClipboardFormats()), "EnumClipboardFormats failed\n");
*/
ok(OpenClipboard(NULL), "OpenClipboard error %ld\n", GetLastError());
ok(EmptyClipboard(), "EmptyClipboard error %ld\n", GetLastError());
WCHAR *s = L"Pedor";
HGLOBAL hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 7 * sizeof(WCHAR));
PCHAR dst = GlobalLock(hdst);
memcpy(dst, s, 6 * sizeof(WCHAR));
GlobalUnlock(hdst);
ok(SetClipboardData(CF_UNICODETEXT, hdst) != 0, "SetClipboardData error %ld\n", GetLastError());
/* this test is very bogus, depends on data entered, need more test ;)
ok((j = EnumClipboardFormats(0)), "EnumClipboardFormats failed \n");
while (j!=0)
{
j = EnumClipboardFormats(j);
i++;
}
ok(j != CountClipboardFormats(), "EnumClipboardFormats failed\n");
ok(j != 1, "EnumClipboardFormats must be 1\n");
*/
ok( CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
ok(OpenClipboard(NULL), "OpenClipboard error %ld\n", GetLastError());
ok((j = EnumClipboardFormats(0)), "EnumClipboardFormats failed (%ld)\n", GetLastError());
while (j!=0)
{
j = EnumClipboardFormats(j);
i++;
}
ok(j != CountClipboardFormats(), "EnumClipboardFormats failed\n");
ok( CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
DWORD asn = GetClipboardSequenceNumber();
ok(asn == sn + 7, "GetClipboardSequenceNumber() returns %d, not %d\n", (int)asn, (int)sn + 7);
}
static void test_Owner(void)
{
HWND hWnd1;
BOOL ret;
/* get owner */
ok(OpenClipboard(0), "OpenClipboard should not fail\n");
ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
hWnd1 = CreateWindowExA(0, "static", NULL, WS_POPUP,
0, 0, 10, 10, 0, 0, 0, NULL);
ok(hWnd1 != 0, "CreateWindowExA error %ld\n", GetLastError());
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
HGLOBAL hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 7 * sizeof(WCHAR));
ok((int)SetClipboardData(CF_UNICODETEXT, hdst), "SetClipboardData error we can't put data if not be the owner (%ld)\n", GetLastError());
ok(CloseClipboard(), "CloseClipboard error %ld\n", GetLastError());
ret = DestroyWindow(hWnd1);
ok(ret, "DestroyWindow error %ld\n", GetLastError());
/* tets secuence number*/
DWORD asn = GetClipboardSequenceNumber();
ok(asn == sn + 8, "GetClipboardSequenceNumber() returns %d, not %d\n", (int)asn, (int)sn + 8);
}
static void test_RegisterClipboardFormatA(void)
@ -204,14 +97,6 @@ static void test_RegisterClipboardFormatA(void)
int len;
BOOL ret;
SetLastError(0xdeadbeef);
ok(!(format_id = RegisterClipboardFormatA(0)), "RegisterClipboardFormat should fail\n");
test_last_error(ERROR_INVALID_PARAMETER);
SetLastError(0xdeadbeef);
ok(!(format_id = RegisterClipboardFormatA("")), "RegisterClipboardFormat should fail\n");
test_last_error(ERROR_INVALID_NAME);
format_id = RegisterClipboardFormatA("my_cool_clipboard_format");
ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
@ -222,11 +107,6 @@ static void test_RegisterClipboardFormatA(void)
ok(len == lstrlenA("my_cool_clipboard_format"), "wrong format name length %d\n", len);
ok(!lstrcmpA(buf, "my_cool_clipboard_format"), "wrong format name \"%s\"\n", buf);
WCHAR buf2[256];
len = GetClipboardFormatNameW(format_id, buf2, 256);
ok(len == lstrlenW(L"my_cool_clipboard_format"), "wrong format name length %d\n", len);
ok(!lstrcmpW(buf2, L"my_cool_clipboard_format"), "wrong format name \"%S\"\n", buf2);
lstrcpyA(buf, "foo");
SetLastError(0xdeadbeef);
len = GetAtomNameA((ATOM)format_id, buf, 256);
@ -274,8 +154,6 @@ todo_wine
}
#endif
ok(!GetClipboardFormatNameA(1, buf, 256), "GetClipboardFormatNameA should fail\n");
ret = OpenClipboard(0);
ok( ret, "OpenClipboard error %ld\n", GetLastError());
@ -305,100 +183,14 @@ todo_wine
SetLastError(0xdeadbeef);
ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n");
test_last_error(ERROR_CLIPBOARD_NOT_OPEN);
DWORD asn = GetClipboardSequenceNumber();
ok(asn == sn + 1, "GetClipboardSequenceNumber() returns %d, not %d\n", (int)asn, (int)sn + 1);
}
static void test_RegisterClipboardFormatW(void)
{
ATOM atom_id;
UINT format_id, format_id2;
WCHAR buf[256];
int len;
BOOL ret;
SetLastError(0xdeadbeef);
ok(!(format_id = RegisterClipboardFormatW(0)), "RegisterClipboardFormatW should fail\n");
test_last_error(ERROR_INVALID_PARAMETER);
SetLastError(0xdeadbeef);
ok(!(format_id = RegisterClipboardFormatW(L"")), "RegisterClipboardFormatW should fail\n");
test_last_error(ERROR_INVALID_NAME);
format_id = RegisterClipboardFormatW(L"my_cool_clipboard_format");
ok(format_id > 0xc000 && format_id < 0xffff, "invalid clipboard format id %04x\n", format_id);
format_id2 = RegisterClipboardFormatW(L"MY_COOL_CLIPBOARD_FORMAT");
ok(format_id2 == format_id, "invalid clipboard format id %04x\n", format_id2);
len = GetClipboardFormatNameW(format_id, buf, 256);
ok(len == lstrlenW(L"my_cool_clipboard_format"), "wrong format name length %d\n", len);
ok(!lstrcmpW(buf, L"my_cool_clipboard_format"), "wrong format name \"%S\"\n", buf);
lstrcpyW(buf, L"foo");
SetLastError(0xdeadbeef);
len = GetAtomNameW((ATOM)format_id, buf, 256);
ok(len == 0, "GetAtomNameA should fail\n");
test_last_error(ERROR_INVALID_HANDLE);
lstrcpyW(buf, L"foo");
SetLastError(0xdeadbeef);
len = GlobalGetAtomNameW((ATOM)format_id, buf, 256);
ok(len == 0, "GlobalGetAtomNameA should fail\n");
test_last_error(ERROR_INVALID_HANDLE);
SetLastError(0xdeadbeef);
atom_id = FindAtomW(L"my_cool_clipboard_format");
ok(atom_id == 0, "FindAtomA should fail\n");
test_last_error(ERROR_FILE_NOT_FOUND);
ok(!GetClipboardFormatNameW(1, buf, 256), "GetClipboardFormatNameA should fail\n");
ret = OpenClipboard(0);
ok( ret, "OpenClipboard error %ld\n", GetLastError());
trace("# of formats available: %d\n", CountClipboardFormats());
format_id = 0;
while ((format_id = EnumClipboardFormats(format_id)))
{
ok(IsClipboardFormatAvailable(format_id), "format %04x was listed as available\n", format_id);
len = GetClipboardFormatNameW(format_id, buf, 256);
trace("%04x: %S\n", format_id, len ? buf : L"");
}
ret = EmptyClipboard();
ok(ret, "EmptyClipboard error %ld\n", GetLastError());
ret = CloseClipboard();
ok(ret, "CloseClipboard error %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n");
test_last_error(ERROR_CLIPBOARD_NOT_OPEN);
DWORD asn = GetClipboardSequenceNumber();
ok(asn == sn + 9, "GetClipboardSequenceNumber() returns %d, not %d\n", (int)asn, (int)sn + 9);
}
START_TEST(clipboard)
{
SetLastError(0xdeadbeef);
FindAtomW(NULL);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) is_win9x = TRUE;
sn = GetClipboardSequenceNumber();
trace("Current Secuence Number: %d\n", (int)sn);
test_RegisterClipboardFormatA();
test_ClipboardOwner();
test_EnumClipboardFormats();
test_Owner();
test_RegisterClipboardFormatW();
/*
ok(0, "GetClipboardSequenceNumber() returns 0x%x\n", GetClipboardSequenceNumber());
*/
}