Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenclipboard.cpp
Go to the documentation of this file.
00001 /* 00002 * clipboard helper functions 00003 * 00004 * Copyright 2000 Juergen Schmied <juergen.schmied@debitel.de> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 * 00020 * NOTES: 00021 * 00022 * For copy & paste functions within contextmenus does the shell use 00023 * the OLE clipboard functions in combination with dataobjects. 00024 * The OLE32.DLL gets loaded with LoadLibrary 00025 * 00026 * - a right mousebutton-copy sets the following formats: 00027 * classic: 00028 * Shell IDList Array 00029 * Preferred Drop Effect 00030 * Shell Object Offsets 00031 * HDROP 00032 * FileName 00033 * ole: 00034 * OlePrivateData (ClipboardDataObjectInterface) 00035 * 00036 */ 00037 00038 #include <precomp.h> 00039 00040 WINE_DEFAULT_DEBUG_CHANNEL(shell); 00041 00042 /************************************************************************** 00043 * RenderHDROP 00044 * 00045 * creates a CF_HDROP structure 00046 */ 00047 HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00048 { 00049 UINT i; 00050 int size = 0; 00051 WCHAR wszFileName[MAX_PATH]; 00052 HGLOBAL hGlobal = NULL; 00053 DROPFILES *pDropFiles; 00054 int offset; 00055 LPITEMIDLIST *pidls; 00056 00057 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); 00058 00059 pidls = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls)); 00060 if (!pidls) 00061 goto cleanup; 00062 00063 /* get the size needed */ 00064 size = sizeof(DROPFILES); 00065 00066 for (i=0; i<cidl;i++) 00067 { 00068 pidls[i] = ILCombine(pidlRoot, apidl[i]); 00069 SHGetPathFromIDListW(pidls[i], wszFileName); 00070 size += (wcslen(wszFileName) + 1) * sizeof(WCHAR); 00071 } 00072 00073 size += sizeof(WCHAR); 00074 00075 /* Fill the structure */ 00076 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); 00077 if(!hGlobal) 00078 goto cleanup; 00079 00080 pDropFiles = (DROPFILES *)GlobalLock(hGlobal); 00081 offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR); 00082 pDropFiles->pFiles = offset * sizeof(WCHAR); 00083 pDropFiles->fWide = TRUE; 00084 00085 for (i=0; i<cidl;i++) 00086 { 00087 SHGetPathFromIDListW(pidls[i], wszFileName); 00088 wcscpy(((WCHAR*)pDropFiles)+offset, wszFileName); 00089 offset += wcslen(wszFileName) + 1; 00090 ILFree(pidls[i]); 00091 } 00092 00093 ((WCHAR*)pDropFiles)[offset] = 0; 00094 GlobalUnlock(hGlobal); 00095 00096 cleanup: 00097 if(pidls) 00098 HeapFree(GetProcessHeap(), 0, pidls); 00099 00100 return hGlobal; 00101 } 00102 00103 HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00104 { 00105 UINT i; 00106 int offset = 0, sizePidl, size; 00107 HGLOBAL hGlobal; 00108 LPIDA pcida; 00109 00110 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); 00111 00112 /* get the size needed */ 00113 size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */ 00114 size += ILGetSize (pidlRoot); /* root pidl */ 00115 for(i=0; i<cidl; i++) 00116 { 00117 size += ILGetSize(apidl[i]); /* child pidls */ 00118 } 00119 00120 /* fill the structure */ 00121 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); 00122 if(!hGlobal) return hGlobal; 00123 pcida = (LPIDA)GlobalLock (hGlobal); 00124 pcida->cidl = cidl; 00125 00126 /* root pidl */ 00127 offset = sizeof(CIDA) + sizeof (UINT)*(cidl); 00128 pcida->aoffset[0] = offset; /* first element */ 00129 sizePidl = ILGetSize (pidlRoot); 00130 memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl); 00131 offset += sizePidl; 00132 00133 for(i=0; i<cidl; i++) /* child pidls */ 00134 { 00135 pcida->aoffset[i+1] = offset; 00136 sizePidl = ILGetSize(apidl[i]); 00137 memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl); 00138 offset += sizePidl; 00139 } 00140 00141 GlobalUnlock(hGlobal); 00142 return hGlobal; 00143 } 00144 00145 HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00146 { 00147 FIXME("\n"); 00148 return 0; 00149 } 00150 00151 HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00152 { 00153 FIXME("\n"); 00154 return 0; 00155 } 00156 00157 HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00158 { 00159 FIXME("\n"); 00160 return 0; 00161 } 00162 00163 HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00164 { 00165 int size = 0; 00166 char szTemp[MAX_PATH], *szFileName; 00167 LPITEMIDLIST pidl; 00168 HGLOBAL hGlobal; 00169 BOOL bSuccess; 00170 00171 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); 00172 00173 /* get path of combined pidl */ 00174 pidl = ILCombine(pidlRoot, apidl[0]); 00175 if (!pidl) 00176 return 0; 00177 00178 bSuccess = SHGetPathFromIDListA(pidl, szTemp); 00179 SHFree(pidl); 00180 if (!bSuccess) 00181 return 0; 00182 00183 size = strlen(szTemp) + 1; 00184 00185 /* fill the structure */ 00186 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); 00187 if(!hGlobal) return hGlobal; 00188 szFileName = (char *)GlobalLock(hGlobal); 00189 memcpy(szFileName, szTemp, size); 00190 GlobalUnlock(hGlobal); 00191 00192 return hGlobal; 00193 } 00194 00195 HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) 00196 { 00197 int size = 0; 00198 WCHAR szTemp[MAX_PATH], *szFileName; 00199 LPITEMIDLIST pidl; 00200 HGLOBAL hGlobal; 00201 BOOL bSuccess; 00202 00203 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); 00204 00205 /* get path of combined pidl */ 00206 pidl = ILCombine(pidlRoot, apidl[0]); 00207 if (!pidl) 00208 return 0; 00209 00210 bSuccess = SHGetPathFromIDListW(pidl, szTemp); 00211 SHFree(pidl); 00212 if (!bSuccess) 00213 return 0; 00214 00215 size = (wcslen(szTemp)+1) * sizeof(WCHAR); 00216 00217 /* fill the structure */ 00218 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); 00219 if(!hGlobal) return hGlobal; 00220 szFileName = (WCHAR *)GlobalLock(hGlobal); 00221 memcpy(szFileName, szTemp, size); 00222 GlobalUnlock(hGlobal); 00223 00224 return hGlobal; 00225 } 00226 00227 HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags) 00228 { 00229 DWORD * pdwFlag; 00230 HGLOBAL hGlobal; 00231 00232 TRACE("(0x%08x)\n", dwFlags); 00233 00234 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, sizeof(DWORD)); 00235 if(!hGlobal) return hGlobal; 00236 pdwFlag = (DWORD*)GlobalLock(hGlobal); 00237 *pdwFlag = dwFlags; 00238 GlobalUnlock(hGlobal); 00239 return hGlobal; 00240 } Generated on Sat May 26 2012 04:24:52 for ReactOS by
1.7.6.1
|