VOID OleStdEnumFmtEtc_Destroy(LPOLESTDENUMFMTETC lpEF) //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- { #ifdef Q_OS_TEMP return; #else LPMALLOC lpMalloc=NULL; ULONG i; if (lpEF != NULL) { if (CoGetMalloc(MEMCTX_TASK, &lpMalloc) == NOERROR) { /* OLE2NOTE: we MUST free any memory that was allocated for ** TARGETDEVICES contained within the FORMATETC elements. */ for (i=0; i<lpEF->m_nCount; i++) { OleStdFree(lpEF->m_lpEtc[i].ptd); } if (lpEF->m_lpEtc != NULL) { lpMalloc->lpVtbl->Free(lpMalloc, lpEF->m_lpEtc); } lpMalloc->lpVtbl->Free(lpMalloc, lpEF); lpMalloc->lpVtbl->Release(lpMalloc); } } #endif } /* OleStdEnumFmtEtc_Destroy()
static void WINAPI Abbreviate(HDC hdc, int nWidth, LPTSTR lpch, int nMaxChars) { /* string is too long to fit; chop it */ /* set up new prefix & determine remaining space in control */ LPTSTR lpszFileName = NULL; LPTSTR lpszCur = CharNext(CharNext(lpch)); lpszCur = FindChar(lpszCur, TEXT('\\')); // algorithm will insert \... so allocate extra 4 LPTSTR lpszNew = (LPTSTR)OleStdMalloc((lstrlen(lpch)+5) * sizeof(TCHAR)); if (lpszNew == NULL) return; if (lpszCur != NULL) // at least one backslash { *lpszNew = (TCHAR)0; *lpszCur = (TCHAR)0; lstrcpy(lpszNew, lpch); *lpszCur = TEXT('\\'); // lpszNew now contains c: or \\servername lstrcat(lpszNew, TEXT("\\...")); // lpszNew now contains c:\... or \\servername\... LPTSTR lpszEnd = lpszNew; while (*lpszEnd != (TCHAR)0) lpszEnd = CharNext(lpszEnd); // lpszEnd is now at the end of c:\... or \\servername\... // move down directories until it fits or no more directories while (lpszCur != NULL) { *lpszEnd = (TCHAR)0; lstrcat(lpszEnd, lpszCur); if (GetTextWSize(hdc, lpszNew) <= nWidth && lstrlen(lpszNew) < nMaxChars) { lstrcpyn(lpch, lpszNew, nMaxChars); OleStdFree(lpszNew); return; } lpszCur = CharNext(lpszCur); // advance past backslash lpszCur = FindChar(lpszCur, TEXT('\\')); } // try just ...filename and then shortening filename lpszFileName = FindReverseChar(lpch, TEXT('\\')); } else lpszFileName = lpch; while (*lpszFileName != (TCHAR)0) { lstrcpy(lpszNew, TEXT("...")); lstrcat(lpszNew, lpszFileName); if (GetTextWSize(hdc, lpszNew) <= nWidth && lstrlen(lpszNew) < nMaxChars) { lstrcpyn(lpch, lpszNew, nMaxChars); OleStdFree(lpszNew); return; } lpszFileName = CharNext(lpszFileName); } OleStdFree(lpszNew); // not even a single character fit *lpch = (TCHAR)0; }