#include "PropSyntax.h"
#include "ssapi.h" // BSP - Includes for Visual Source Safe COM interface
#include "multimon.h"
+#include "paths.h"
#ifdef _DEBUG
#define new DEBUG_NEW
ON_WM_CLOSE()
ON_COMMAND(ID_VIEW_WHITESPACE, OnViewWhitespace)
ON_UPDATE_COMMAND_UI(ID_VIEW_WHITESPACE, OnUpdateViewWhitespace)
-
+ ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
while (ptr != NULL);
}
+/////////////////////////////////////////////////////////////////////////////
+//
+// OnDropFiles code from CDropEdit
+// Copyright 1997 Chris Losinger
+//
+// shortcut expansion code modified from :
+// CShortcut, 1996 Rob Warner
+//
+void CMainFrame::OnDropFiles(HDROP dropInfo)
+{
+ // Get the number of pathnames that have been dropped
+ UINT wNumFilesDropped = DragQueryFile(dropInfo, 0xFFFFFFFF, NULL, 0);
+ CString files[2];
+ int fileCount = 0;
+
+ // get all file names. but we'll only need the first one.
+ for (WORD x = 0 ; x < wNumFilesDropped; x++)
+ {
+ // Get the number of bytes required by the file's full pathname
+ UINT wPathnameSize = DragQueryFile(dropInfo, x, NULL, 0);
+
+ // Allocate memory to contain full pathname & zero byte
+ char * npszFile = (char *) LocalAlloc(LPTR, wPathnameSize += 1);
+
+ // If not enough memory, skip this one
+ if (npszFile == NULL) continue;
+
+ // Copy the pathname into the buffer
+ DragQueryFile(dropInfo, x, npszFile, wPathnameSize);
+
+ if (x < 2)
+ {
+ files[x] = npszFile;
+ fileCount++;
+ }
+ // clean up
+ LocalFree(npszFile);
+ }
+
+ // Free the memory block containing the dropped-file information
+ DragFinish(dropInfo);
+
+ for (int i = 0; i < fileCount; i++)
+ {
+ // if this was a shortcut, we need to expand it to the target path
+ CString expandedFile = ExpandShortcut(files[i]);
+
+ // if that worked, we should have a real file name
+ if (expandedFile != _T(""))
+ files[i] = expandedFile;
+ }
+
+ if (m_pMergeDoc != NULL)
+ {
+ // Save files and update dirview status if needed
+ if (!m_pMergeDoc->SaveHelper())
+ return;
+ }
+
+ // If Ctrl pressed, do recursive compare
+ BOOL ctrlKey = ::GetAsyncKeyState(VK_CONTROL);
+ DoFileOpen(files[0], files[1], ctrlKey);
+}
afx_msg void OnClose();
afx_msg void OnViewWhitespace();
afx_msg void OnUpdateViewWhitespace(CCmdUI* pCmdUI);
+ afx_msg void OnDropFiles(HDROP dropInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
+ // Enable drag&drop files
+ pMainFrame->ModifyStyleEx(NULL, WS_EX_ACCEPTFILES);
pMainFrame->m_hMenuDefault=pMainFrame->NewDefaultMenu();
return curdir[0];
}
+//////////////////////////////////////////////////////////////////
+// use IShellLink to expand the shortcut
+// returns the expanded file, or "" on error
+//
+// original code was part of CShortcut
+// 1996 by Rob Warner
+// rhwarner@southeast.net
+// http://users.southeast.net/~rhwarner
+CString ExpandShortcut(CString &inFile)
+{
+ CString outFile = "";
+
+ // Make sure we have a path
+ ASSERT(inFile != _T(""));
+
+ IShellLink* psl;
+ HRESULT hres;
+ LPTSTR lpsz = inFile.GetBuffer(MAX_PATH);
+
+ // Create instance for shell link
+ hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellLink, (LPVOID*) &psl);
+ if (SUCCEEDED(hres))
+ {
+ // Get a pointer to the persist file interface
+ IPersistFile* ppf;
+ hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
+ if (SUCCEEDED(hres))
+ {
+ // Make sure it's ANSI
+ WORD wsz[MAX_PATH];
+ ::MultiByteToWideChar(CP_ACP, 0, lpsz, -1, wsz, MAX_PATH);
+
+ // Load shortcut
+ hres = ppf->Load(wsz, STGM_READ);
+ if (SUCCEEDED(hres)) {
+ WIN32_FIND_DATA wfd;
+ // find the path from that
+ HRESULT hres = psl->GetPath(outFile.GetBuffer(MAX_PATH),
+ MAX_PATH,
+ &wfd,
+ SLGP_UNCPRIORITY);
+
+ outFile.ReleaseBuffer();
+ }
+ ppf->Release();
+ }
+ psl->Release();
+ }
+
+ inFile.ReleaseBuffer();
+
+ // if this fails, outFile == ""
+ return outFile;
+}
void paths_normalize(CString & sPath);
CString paths_GetLongPath(const CString & sPath);
TCHAR paths_GetCurrentDrive();
+CString ExpandShortcut(CString &inFile);
#endif // paths_h_included
2003-03-09 Kimmo
PATCH: [ 699839 ] Add same binaries to dir compare status
WinMerge: MainFrm.h MainFrm.cpp
+ PATCH: [ 699893 ] Add drag&drop of files/paths to main window
+ Note: Press down Ctrl when dropping dirs for recursive compare
+ WinMerge: MainFrm.h MainFrm.cpp Merge.cpp paths.h paths.cpp
2003-03-07 Perry
PATCH: [ 699580 ] Fix paths.cpp