コード例 #1
0
HRESULT __stdcall CBookmarksToolbarDropHandler::DragEnter(IDataObject *pDataObject,
	DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
{
	UNREFERENCED_PARAMETER(grfKeyState);

	bool m_bValid = false;
	bool m_bAllFolders = true;

	FORMATETC ftc = {CF_HDROP,0,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
	STGMEDIUM stg;

	HRESULT hr = pDataObject->GetData(&ftc,&stg);

	if(hr == S_OK)
	{
		DROPFILES *pdf = reinterpret_cast<DROPFILES *>(GlobalLock(stg.hGlobal));

		if(pdf != NULL)
		{
			m_bValid = true;

			UINT nDroppedFiles = DragQueryFile(reinterpret_cast<HDROP>(pdf),0xFFFFFFFF,NULL,NULL);

			for(UINT i = 0;i < nDroppedFiles;i++)
			{
				TCHAR szFullFileName[MAX_PATH];
				DragQueryFile(reinterpret_cast<HDROP>(pdf),i,szFullFileName,
					SIZEOF_ARRAY(szFullFileName));

				if(!PathIsDirectory(szFullFileName))
				{
					m_bAllFolders = false;
					break;
				}
			}

			GlobalUnlock(stg.hGlobal);
		}

		ReleaseStgMedium(&stg);
	}

	if(m_bValid &&
		m_bAllFolders)
	{
		*pdwEffect = DROPEFFECT_COPY;

		m_bAcceptData = true;
	}
	else
	{
		*pdwEffect = DROPEFFECT_NONE;

		m_bAcceptData = false;
	}

	m_pDropTargetHelper->DragEnter(m_hToolbar,pDataObject,reinterpret_cast<POINT *>(&pt),*pdwEffect);

	return S_OK;
}
コード例 #2
0
ファイル: MainFrm.cpp プロジェクト: abael/pyui4win
void CMainFrame::OnDropFiles( HDROP hDropInfo )
{
	SetActiveWindow();      // activate us first !

	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);

	CString strFile;
	UINT nFilesCount=DragQueryFile(hDropInfo,INFINITE,NULL,0);
	for(UINT i=0; i<nFilesCount; i++)
	{
		int pathLen = DragQueryFile(hDropInfo, i, strFile.GetBuffer(MAX_PATH), MAX_PATH);
		strFile.ReleaseBuffer(pathLen);
		DWORD dwFileAttr = ::GetFileAttributes(strFile);
		if ((dwFileAttr & FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY)
		{
			//目录,需要递归里面包含的文件
		}
		else
		{
			CString strExt=strFile.Mid(strFile.GetLength()-4,4);
			if (strExt.CompareNoCase(_T(".xml"))==0)
			{
				pApp->OpenDocumentFile(strFile);
			}
		}
	}
	DragFinish(hDropInfo);
}
コード例 #3
0
ファイル: FilesHashDlg.cpp プロジェクト: Koogoo/fhash
void CFilesHashDlg::OnDropFiles(HDROP hDropInfo)
{
	if(!m_thrdData.threadWorking)
	{
		unsigned int i;
		TCHAR szDragFilename[MAX_PATH];
		DragAcceptFiles(FALSE);

		m_thrdData.nFiles = DragQueryFile(hDropInfo, -1, NULL, 0);
		ClearFilePaths();

		for(i=0; i < m_thrdData.nFiles; i++)
		{
			DragQueryFile(hDropInfo, i, szDragFilename, sizeof(szDragFilename));
			CString tmp;
			tmp.Format(_T("%s"), szDragFilename);
			m_thrdData.fullPaths.push_back(tmp);
		}

		DragFinish(hDropInfo);
		DragAcceptFiles(TRUE);

		DoMD5();
	}
}
コード例 #4
0
STDMETHODIMP CShooterContextMenuExt::Initialize ( 
  LPCITEMIDLIST pidlFolder,
  LPDATAOBJECT pDataObj,
  HKEY hProgID )
{
	TCHAR     szFile[MAX_PATH];
	FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM stg = { TYMED_HGLOBAL };
	HDROP     hDrop;

	// Look for CF_HDROP data in the data object.
	if ( FAILED( pDataObj->GetData ( &fmt, &stg ) ))
	{
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;
	}

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock ( stg.hGlobal );

	// Make sure it worked.
	if ( NULL == hDrop )
	{
		ReleaseStgMedium ( &stg );
		return E_INVALIDARG;
	}

	// Sanity check - make sure there is at least one filename.
	UINT uNumFiles = DragQueryFile ( hDrop, 0xFFFFFFFF, NULL, 0 );
	HRESULT hr = S_OK;

	if ( 0 == uNumFiles )
	{
		GlobalUnlock ( stg.hGlobal );
		ReleaseStgMedium ( &stg );
		return E_INVALIDARG;
	}

	// Get the name of the first file and store it in our member variable m_szFile.
	m_bHasDir = false;

	for(UINT uFile = 0 ; uFile < uNumFiles ; uFile++)
	{
		if(0 == DragQueryFile(hDrop, uFile, szFile, MAX_PATH))
			continue;

		ATLTRACE("Checking file <%s>\n", szFile);

		m_fileList.push_back(szFile);

		if(IsDir(szFile))
			m_bHasDir = true;
	}


	GlobalUnlock ( stg.hGlobal );
	ReleaseStgMedium ( &stg );

	return hr;
}
コード例 #5
0
ファイル: MetroWindow.cpp プロジェクト: codepongo/iBurnMgr
LRESULT MetroWindow::OnDropfiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
	WCHAR iPath[MAX_UNC_PATH] = { 0 };
	UINT nFileCnt = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, NULL, 0);
	if (DragQueryFile((HDROP)wParam, nFileCnt - 1, iPath, MAX_UNC_PATH))
	{
		std::wstring wstr = iPath;
		std::wstring::size_type pos = wstr.rfind(L".iso");
		if (pos != wstr.length() - 4)
			return 1;
		::SetWindowText(GetDlgItem(IDC_EDIT_IMAGE), wstr.c_str());
		ProcessInfo = L"Manager Task Rate:";
		JobStatusRate = L"Task not start";
		MTNotices = L"Notices> Enviroment Inspection:\n" + envinfo;
		m_proge.SetPos(0);
		HANDLE hFile;
		LARGE_INTEGER FileSize;
		hFile = CreateFile(wstr.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if (hFile != INVALID_HANDLE_VALUE)
		{
			GetFileSizeEx(hFile, &FileSize);
			swprintf_s(SizeStr, L" %lld Bytes ||%4.1f KB ||%4.2f MB ||%4.2f GB\0", FileSize.QuadPart, (float)FileSize.QuadPart / 1024, (float)FileSize.QuadPart / (1024 * 1024), (float)FileSize.QuadPart / (1024 * 1024 * 1024));
			SendMessage(WM_PAINT, 0, 0);
		}
		CloseHandle(hFile);
		//::MessageBox(m_hWnd, iPath, L"Drag the image file is:", MB_OK | MB_ICONASTERISK);
	}
	return 0;
}
コード例 #6
0
ファイル: host-event.c プロジェクト: Oldes/R3A110
static void Add_File_Events(REBGOB *gob, REBINT flags, HDROP drop)
{
	REBEVT evt;
	REBINT num;
	REBINT len;
	REBINT i;
	REBCHR* buf;
	POINT xy;

	//Get the mouse position
	DragQueryPoint(drop, &xy);

	evt.type  = EVT_DROP_FILE;
	evt.flags = (u8) (flags | (1<<EVF_HAS_XY));
	evt.model = EVM_GUI;
	evt.data = xy.x | xy.y<<16;


	num = DragQueryFile(drop, -1, NULL, 0);

	for (i = 0; i < num; i++){
		len = DragQueryFile(drop, i, NULL, 0);
		buf = OS_Make(len+1);
		DragQueryFile(drop, i, buf, len+1);
		//Reb_Print("DROP: %s", buf);
		buf[len] = 0;
		// ?! convert to REBOL format? E.g.: evt.ser = OS_To_REBOL_File(buf, &len);
		OS_Free(buf);
		if (!RL_Event(&evt)) break;	// queue is full
	}
}
コード例 #7
0
/* Windows 3.1 drag-drop feature */
void
text_drag_drop(TW *tw, HDROP hdrop)
{
    char *szFile;
    int i, cFiles;
    unsigned int Len, error;
    const char *p;
    if ( (tw->DragPre==NULL) || (tw->DragPost==NULL) )
	    return;

    cFiles = DragQueryFile(hdrop, (UINT)(-1), (LPSTR)NULL, 0);
    for (i=0; i<cFiles; i++) {
	Len = DragQueryFile(hdrop, i, NULL, 0);
	szFile = (char *)malloc(Len+1);
	if (szFile != 0) {
	    error = DragQueryFile(hdrop, i, szFile, Len+1);
	    if (error != 0) {
		for (p=tw->DragPre; *p; p++)
		    SendMessage(tw->hwnd,WM_CHAR,*p,1L);
		for (p=szFile; *p; p++) {
		    if (*p == '\\')
			SendMessage(tw->hwnd,WM_CHAR,'/',1L);
		    else 
			SendMessage(tw->hwnd,WM_CHAR,*p,1L);
		}
		for (p=tw->DragPost; *p; p++)
		    SendMessage(tw->hwnd,WM_CHAR,*p,1L);
	    }
	    free(szFile);
	}
    }
    DragFinish(hdrop);
}
コード例 #8
0
ファイル: perfmon.c プロジェクト: mingpen/OpenNT
void OnDropFile (DWORD wParam)
   {
   TCHAR FileName [FilePathLen + 1] ;
   LPTSTR         pFileNameStart ;
   HANDLE         hFindFile ;
   WIN32_FIND_DATA FindFileInfo ;
   int            NameOffset ;
   int            NumOfFiles = 0 ;

   NumOfFiles = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0) ;
   if (NumOfFiles > 0)
      {
      // we only open the first file for now
      DragQueryFile((HDROP) wParam, 0, FileName, FilePathLen) ;

      pFileNameStart = ExtractFileName (FileName) ;
      NameOffset = pFileNameStart - FileName ;

      // convert short filename to long NTFS filename if necessary
      hFindFile = FindFirstFile (FileName, &FindFileInfo) ;
      if (hFindFile && hFindFile != INVALID_HANDLE_VALUE)
         {
         // append the file name back to the path name
         lstrcpy (&FileName[NameOffset], FindFileInfo.cFileName) ;
         FindClose (hFindFile) ;
         }

      FileOpen (hWndMain, (int)0, (LPTSTR)FileName) ;
      PrepareMenu (GetMenu (hWndMain));
      }

   DragFinish ((HDROP) wParam) ;
   }
コード例 #9
0
ファイル: vocab.cpp プロジェクト: DmytroBiriukov/RefEditor
//---------------------------------------------------------------------------
void __fastcall TRefEditForm::WMDropFiles(TWMDropFiles &message)
{
  AnsiString FileName;
  FileName.SetLength(MAX_PATH);

  int Count = DragQueryFile((HDROP)message.Drop, 0xFFFFFFFF, NULL, MAX_PATH);

  // index through the files and query the OS for each file name...
  for (int index = 0; index < Count; ++index)
  {
    // the following code gets the FileName of the dropped file.  I know it
    // looks cryptic but that's only because it is.  Hey, Why do you think
    // Delphi and C++ Builder are so popular anyway?
    FileName.SetLength(DragQueryFile((HDROP)message.Drop, index,
      FileName.c_str(), MAX_PATH));

    // examine the filename's extension.
    // If it's a Word file then ...
    if (UpperCase(ExtractFileExt(FileName)) == ".DOC")

    {
      ListBox_Words->Items->Add(FileName);
    }
  }
  // tell the OS that we're finished...
  DragFinish((HDROP) message.Drop);
}
コード例 #10
0
ファイル: misc.cpp プロジェクト: isseki/metacryst
/*----------*/
void	onDropFile(HDROP hDrop)
{
    DWORD	i, nb, len;
    wchar_t	wbuf[MAX_PATH+32];
    wchar_t* wp;

    nb = DragQueryFile(hDrop, (DWORD)-1, NULL, 0);
    for(i = 0 ; i < nb ; i++) {
	len = DragQueryFile(hDrop, i, NULL, 0);
	if(len < 1 || len > MAX_PATH)
	    continue;
	wp = wbuf + 1;
	if(! DragQueryFile(hDrop, i, wp, MAX_PATH))
	    continue;
	wp[len] = 0;
	while(*wp > 0x20) wp++;
	if(*wp) {
	    wp = wbuf;
	    len++;
	    wp[0] = wp[len++] = L'\"';
	}
	else {
	    wp = wbuf + 1;
	}
	wp[len++] = L' ';

	__write_console_input(wp, len);
    }
    DragFinish(hDrop);
}
コード例 #11
0
ファイル: Source.cpp プロジェクト: suhockii/rsa-encryption
void HandleFiles(WPARAM wParam) 
{
	// DragQueryFile() takes a LPWSTR for the name so we need a TCHAR string
	TCHAR szName[MAX_PATH];

	// Here we cast the wParam as a HDROP handle to pass into the next functions
	HDROP hDrop = (HDROP)wParam;

	// This functions has a couple functionalities.  If you pass in 0xFFFFFFFF in
	// the second parameter then it returns the count of how many filers were drag
	// and dropped.  Otherwise, the function fills in the szName string array with
	// the current file being queried.
	int count = DragQueryFile(hDrop, 0xFFFFFFFF, szName, MAX_PATH);

	// Here we go through all the files that were drag and dropped then display them
	for (int i = 0; i < count; i++)
	{
		// Grab the name of the file associated with index "i" in the list of files dropped.
		// Be sure you know that the name is attached to the FULL path of the file.
		DragQueryFile(hDrop, i, szName, MAX_PATH);

		// Bring up a message box that displays the current file being processed
		MessageBox(GetForegroundWindow(), szName, "Current file received", MB_OK);
	}

	// Finally, we destroy the HDROP handle so the extra memory
	// allocated by the application is released.
	DragFinish(hDrop);
}
コード例 #12
0
ファイル: FileEditCtrl.cpp プロジェクト: moodboom/Reusable
void CFileEditCtrl::OnDropFiles(HDROP hDropInfo) 
{
	// handles drag and drop file entry, control must have the
	// WS_EX_ACCEPTFILES extended style set.
	CString szSeperator;
#if defined FEC_NORESOURCESTRINGS
	szSeperator = FEC_IDS_SEPERATOR;
#else
	szSeperator.LoadString(FEC_IDS_SEPERATOR);
#endif
	ASSERT (_tcslen(szSeperator) == 1);			// must be one character only
	szSeperator += _T(" ");						// get the file seperator character
	CString szDroppedFiles;						// buffer to contain all the dropped files

	TCHAR lpstrDropBuffer[_MAX_PATH];
	UINT nDropCount = DragQueryFile(hDropInfo,0xffffffff,NULL,0);
	if (nDropCount && (m_bFindFolder || (!m_bFindFolder && !(m_pCFileDialog->m_ofn.Flags & OFN_ALLOWMULTISELECT))))
		nDropCount = 1;
	if (nDropCount)
	{
		DragQueryFile(hDropInfo, 0, lpstrDropBuffer, _MAX_PATH);
		szDroppedFiles = lpstrDropBuffer;
	}
	for (UINT x = 1; x < nDropCount; x++)
	{
		DragQueryFile(hDropInfo, x, lpstrDropBuffer, _MAX_PATH);
		szDroppedFiles += szSeperator;
		szDroppedFiles += lpstrDropBuffer;
	}
	DragFinish (hDropInfo);
	SetWindowText (szDroppedFiles);
}
コード例 #13
0
ファイル: PatchListCtrl.cpp プロジェクト: iamduyu/TortoiseGit
void CPatchListCtrl::OnDropFiles(HDROP hDropInfo)
{
	UINT nNumFiles = DragQueryFile(hDropInfo, 0xFFFFFFFF, nullptr, 0);
	for (UINT i = 0; i < nNumFiles; ++i)
	{
		CString file;
		DragQueryFile(hDropInfo, i, file.GetBufferSetLength(MAX_PATH), MAX_PATH);
		file.ReleaseBuffer();
		if (PathIsDirectory(file))
			continue;

		// no duplicates
		LVFINDINFO lvInfo;
		lvInfo.flags = LVFI_STRING;
		lvInfo.psz = file;
		if (FindItem(&lvInfo, -1) != -1)
			continue;

		int index = InsertItem(GetItemCount(), file);
		if (index >= 0)
			SetCheck(index, true);
	}
	DragFinish(hDropInfo);
	SetColumnWidth(0, LVSCW_AUTOSIZE);
}
コード例 #14
0
ファイル: EsteidShlExt.cpp プロジェクト: Krabi/idkaart_public
STDMETHODIMP CEsteidShlExt::Initialize (
	LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID )
{
	FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM stg = { TYMED_HGLOBAL };
	HDROP     hDrop;
	TCHAR szFile[MAX_PATH];
	HRESULT hr = S_OK;
	m_Files.clear();

	// Look for CF_HDROP data in the data object.
	if (FAILED(pDataObj->GetData(&fmt, &stg))) {
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;
	}

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock(stg.hGlobal);

	// Make sure it worked.
	if (hDrop == NULL) {
		ReleaseStgMedium(&stg);
		return E_INVALIDARG;
	}

	// Sanity check - make sure there is at least one filename.
	UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
	if (nFiles == 0) {
		GlobalUnlock(stg.hGlobal);
		ReleaseStgMedium(&stg);
		return E_INVALIDARG;
	}

	for (UINT i = 0; i < nFiles; i++) {
		// Get path length in chars
		UINT len = DragQueryFile(hDrop, i, NULL, 0);
		if (len == 0 || len >= MAX_PATH)
			continue;

		// Get the name of the file
		if (DragQueryFile(hDrop, i, szFile, len+1) == 0)
			continue;

		tstring str = tstring(szFile);
		if (str.empty())
			continue;

		m_Files.push_back(str);
	}

	if (m_Files.empty()) {
		// Don't show menu if no items were found
		hr = E_INVALIDARG;
	}

	GlobalUnlock(stg.hGlobal);
	ReleaseStgMedium(&stg);

	return hr;
}
コード例 #15
0
void __fastcall TfrmMain::WMDropFiles(TWMDropFiles& Message)
{
  int Count = DragQueryFile(reinterpret_cast<void*>(Message.Drop), 0xFFFFFFFF, NULL, 0);
  try
  {
    char FileBuf[MAX_PATH+1];
    if (Count > 0)
    {
      TStringList* FileList = new TStringList();
      try
      {
        for (int i = 0; i < Count; i++)
        {
          DragQueryFile(reinterpret_cast<void*>(Message.Drop), i, FileBuf, sizeof(FileBuf));
          FileList->Add(FileBuf);
        }
        FileList->Sort();
        reSource->Lines->BeginUpdate();
        try
        {
          reSource->Lines->Clear();
          for (int i = 0; i < FileList->Count; i++)
            reSource->Lines->Add(StringFromFile(FileList->Strings[i]));
        }
        __finally
        {
          reSource->Lines->EndUpdate();
        }
      }
      __finally
      {
        delete FileList;
      }
    }
  } __finally {
コード例 #16
0
ファイル: Png2BmpW.cpp プロジェクト: yedaoq/YedaoqToolSpace
void OnDropFiles(HDROP hdrop)
{
	if(!hdrop)
		return;

	int filesDropped = DragQueryFile(hdrop, 0xffffffff, NULL, 0);	//获取拖拽文件的个数

	TCHAR pathDropped[1024];

	for(int i = 0; i < filesDropped; ++i)
	{
		ZeroMemory(pathDropped, sizeof(pathDropped));
		DragQueryFile(hdrop, i, pathDropped, 1024);

		if (0 == _tcsicmp(::PathFindExtension(pathDropped), TEXT(".bmp")))
		{
			_tcscpy(pathOut, pathDropped);
		}
		else
		{
			::StringCbCopy(pathOut, sizeof(pathOut), pathDropped);
			::PathRemoveExtension(pathOut);
			::PathAddExtension(pathOut, TEXT(".bmp"));

			Png2AlphaBitmap(pathDropped, pathOut);
		}
	}

	DragFinish(hdrop);
}
コード例 #17
0
ファイル: drop_files.cpp プロジェクト: eledot/aseprite
static LRESULT CALLBACK ase_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
  switch (msg) {

    case WM_DROPFILES:
      {
        ScopedLock lock(*dropped_files_mutex);
        HDROP hdrop = (HDROP)(wparam);
        int index, count, length;

        count = DragQueryFile(hdrop, 0xFFFFFFFF, NULL, 0);
        for (index=0; index<count; ++index) {
          length = DragQueryFile(hdrop, index, NULL, 0);
          if (length > 0) {
            TCHAR* lpstr = new TCHAR[length+1];
            DragQueryFile(hdrop, index, lpstr, length+1);
            dropped_files->push_back(lpstr);
            delete[] lpstr;
          }
        }

        DragFinish(hdrop);
      }
      break;

  }
  return ::CallWindowProc(base_wnd_proc, hwnd, msg, wparam, lparam);
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Kerisa/ExtractGames
void OnDropFiles(HDROP hDrop, HWND hDlg, thread_param* ptp)
{
	struct CB cb;
	TCHAR FileName[MAXPATH];
	DWORD i;
	DWORD FileNum;

	cb.cnt = 0;
	cb.filter = 0;
	cb.ptp = ptp;


	GetDlgItemText(hDlg, IDC_EXEPATH, g_ExePath, MAX_PATH);
	GetDlgItemText(hDlg, IDC_KEYPATH, g_KeyPath, MAX_PATH);

	if (!g_ExePath[0] || !g_KeyPath[0])
	{
		AppendMsg(L"路径不合法\r\n");
		return;
	}

	FileNum  = DragQueryFile(hDrop, -1, NULL, 0);

	for (i=0; i<FileNum; ++i)
	{
		DragQueryFile(hDrop, i, (LPTSTR)FileName, MAXPATH);
		AppendFileToQueue(FileName, callback, &cb);
	}
	DragFinish(hDrop);

	return;
}
コード例 #19
0
ファイル: win32ui.c プロジェクト: jacadym/fuse-emulator
static void
handle_drop( HDROP hDrop )
{
  size_t bufsize;
  char *namebuf;

  /* Check that only one file was dropped */
  if( DragQueryFile( hDrop, ~0UL, NULL, 0 ) == 1) {
    bufsize = DragQueryFile( hDrop, 0, NULL, 0 ) + 1;
    if( ( namebuf = malloc( bufsize ) ) ) {
      DragQueryFile( hDrop, 0, namebuf, bufsize );

      fuse_emulation_pause();

      utils_open_file( namebuf, tape_can_autoload(), NULL );

      free( namebuf );

      display_refresh_all();

      fuse_emulation_unpause();
    }
  }
  DragFinish( hDrop );
}
コード例 #20
0
ファイル: FTPWindow.cpp プロジェクト: Praymundo/NppFTP
HRESULT FTPWindow::OnDrop(LPDATAOBJECT pDataObj, DWORD /*grfKeyState*/, POINTL /*pt*/, LPDWORD pdwEffect) {
	TreeView_Select(m_treeview.GetHWND(), NULL, TVGN_DROPHILITE);

	STGMEDIUM medium;
	FORMATETC formatetc;
	formatetc.cfFormat = CF_HDROP;
	formatetc.tymed = TYMED_HGLOBAL;
	formatetc.dwAspect = 0;
	formatetc.lindex = -1;
	formatetc.ptd = NULL;;

	HRESULT dataRes = pDataObj->GetData(&formatetc, &medium);
	if (dataRes == S_OK) {
		*pdwEffect = DROPEFFECT_COPY;
		HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);

		TCHAR pathToFile[MAX_PATH];
		int filesDropped = DragQueryFile(hdrop, 0xffffffff, NULL, 0);
		for (int i = 0; i < filesDropped; ++i) {
			if (DragQueryFile(hdrop, i, pathToFile, MAX_PATH) != 0) {
				//pathToFile is not checked. If it doesnt exist or its a directory or link, CreateFile either allows a handle to be opened or not
				m_ftpSession->UploadFile(pathToFile, m_currentDropObject->GetPath(), true, 1);	//1: User specified location
			}
		}


		GlobalUnlock(medium.hGlobal);
		GlobalFree(medium.hGlobal);
	}

	return S_OK;
}
コード例 #21
0
ファイル: SimpleShlExt.cpp プロジェクト: thecocce/renameit
HRESULT CSimpleShlExt::Initialize (LPCITEMIDLIST pidlFolder,
								   LPDATAOBJECT pDataObj,
								   HKEY hProgID )
{
	LPTSTR		lpszBuffer;
	FORMATETC	fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM	stg = { TYMED_HGLOBAL };
	HDROP		hDrop;
	UINT		uNumFiles,
				i;				

	// Look for CF_HDROP data in the data object.
	if (FAILED( pDataObj->GetData(&fmt, &stg) ))
		// Nope! Return an "invalid argument" error back to Explorer.
		return E_INVALIDARG;

	// Get a pointer to the actual data.
	hDrop = (HDROP) GlobalLock ( stg.hGlobal );

	// Make sure it worked.
	if (hDrop == NULL)
		return E_INVALIDARG;

	// Get the number of files selected
	// and make sure there is at least one file
	if ((uNumFiles = DragQueryFile( hDrop, 0xFFFFFFFF, NULL, 0 )) == 0)
	{
		GlobalUnlock( stg.hGlobal );
		ReleaseStgMedium( &stg );
		return E_INVALIDARG;
	}

	// Create buffer
	if (m_szFiles != NULL)
		delete [] m_szFiles;
	m_nFilesLength = 1;
	for (i=0; i<uNumFiles; ++i)
		m_nFilesLength += DragQueryFile(hDrop, i, NULL, 0) + 1;
	lpszBuffer = m_szFiles = new TCHAR[m_nFilesLength];
	if (m_szFiles == NULL)
	{
		GlobalUnlock( stg.hGlobal );
		ReleaseStgMedium( &stg );
		return E_INVALIDARG;
	}

	// Append all files into the buffer seperated by '\0'.
	for (i=0; i<uNumFiles; ++i)
	{
		lpszBuffer += DragQueryFile(hDrop, i, lpszBuffer, MAX_PATH);
		*lpszBuffer++ = _T('\0');
	}
	*lpszBuffer = _T('\0');	// End by a double '\0'.

	GlobalUnlock ( stg.hGlobal );
	ReleaseStgMedium ( &stg );

	return S_OK;
}
コード例 #22
0
ファイル: EzShortcutDlg.cpp プロジェクト: elky84/ez_shortcut
void CEzShortcutDlg::OnDropFiles(HDROP hDropInfo)
{
	TCHAR szPathName[MAX_PATH];

	// 드롭된 파일의 갯수
	int nFiles=DragQueryFile(hDropInfo, 0xFFFFFFFF, szPathName, MAX_PATH);
	if( nFiles != 1)
	{
		AfxMessageBox(_T("This application is not support multi-file drag & drop"));
		return;
	}

	for(int index=0 ; index < nFiles ; index++)
	{
		DragQueryFile(hDropInfo, index, szPathName, MAX_PATH);     // 파일의 경로 얻어옴
		std::wstring strExt = light::get_file_ext(szPathName);

		if( strExt == _T("lnk" ))
		{
			IShellLink *link;
			IPersistFile *pfile;
			BSTR szLinkPath;
			CString szPrePath;
			TCHAR szBuffer[MAX_PATH];

			CString fname = szPathName;
			if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&link))) 
			{
				link->QueryInterface(IID_IPersistFile, (void **)&pfile);
				szLinkPath = fname.AllocSysString();
				pfile->Load(szLinkPath, STGM_READ);
				SysFreeString(szLinkPath);
				link->Resolve(NULL, NULL);
				link->GetPath(szBuffer, MAX_PATH, NULL, 0);

				// 리스트 박스나 메세지 박스로 해당 경로 값을 불러온다. (szBuffer)
				_tcsncpy_s(szPathName , szBuffer, _TRUNCATE);
				pfile->Release();
				link->Release();
			}
		}
		
		SHORTCUT_INFO ShortcutInfo(GetSafeHwnd());
		ShortcutInfo.m_strShortcutName = light::get_file_name_without_ext(szPathName);
		ShortcutInfo.m_strProgramPath = szPathName;
		if( true == OnEditShortcutDlg(ShortcutInfo) )
		{
			AddShortCutInfo(ShortcutInfo);
			RebuildShortcutList();
			AutoSave();
		}
	}

	DragFinish(hDropInfo);

	CDialog::OnDropFiles(hDropInfo);
}
コード例 #23
0
ファイル: notepad.c プロジェクト: tjyang/kitty-remix
void Notepad_OnDropFiles(HWND hwnd, HDROP hDropInfo, char * filename ) {
	int nb, taille ;
	nb=DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0 );
	if( nb> 0 ) {
		taille=DragQueryFile(hDropInfo, 0, NULL, 0 )+1;
		DragQueryFile(hDropInfo, 0, filename, taille );
		}
	DragFinish(hDropInfo);
	}
コード例 #24
0
ファイル: convmain.cpp プロジェクト: Akehi/RTKLIB
// callback on file drag and drop -------------------------------------------
void __fastcall TMainWindow::DropFiles(TWMDropFiles msg)
{
    char *p,str[1024];
    
    if (DragQueryFile((HDROP)msg.Drop,0xFFFFFFFF,NULL,0)<=0) return;
    DragQueryFile((HDROP)msg.Drop,0,str,sizeof(str));
    InFile->Text=str;
    SetOutFiles(InFile->Text);
}
コード例 #25
0
ファイル: SHEXINIT.CPP プロジェクト: xfxf123444/japan
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY hRegKey)
{
	if (pDataObj == 0)
	{
		return E_INVALIDARG;
	}
	HRESULT hr = E_FAIL;
	FORMATETC	format={CF_HDROP,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
	STGMEDIUM	medium;
	int			i;
	TCHAR		szDirectory[MAX_PATH];

	TCHAR szAppData[MAX_PATH];

	/*hr = */SHGetSpecialFolderPath(NULL, szAppData,CSIDL_COMMON_DESKTOPDIRECTORY ,FALSE);
    // Initialize can be called more than once
    if (m_pDataObj)
    	m_pDataObj->Release();
    // duplicate the object pointer and registry handle
    if (pDataObj)
    {
    	m_pDataObj = pDataObj;
    	pDataObj->AddRef();
    }
	GatherAppData();

	if (SUCCEEDED(pDataObj->GetData(&format,&medium)))
	{
		HDROP hDrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
		if (hDrop)
		{
			m_nSelected=DragQueryFile((HDROP&)medium.hGlobal,0xFFFFFFFF,NULL,0);
			for(i=0;i<m_nSelected;i++)
			{
				DragQueryFile((HDROP&)medium.hGlobal,i,szDirectory,MAX_PATH);
				if(i==0)
				{
					_tcscpy(m_szCommand,szDirectory);
					_tcscat(m_szCommand,_T("*"));
				}
				else
				{
					_tcscat(m_szCommand,szDirectory);
					_tcscat(m_szCommand,_T("*"));
				}
				hr = S_OK;
			}
			GlobalUnlock(medium.hGlobal);
		}

	}

    return hr;
}
コード例 #26
0
LRESULT HandleDropFiles(HDROP hDrop, CefRefPtr<ClientHandler> handler, CefRefPtr<CefBrowser> browser) {
    UINT fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
    for (UINT i = 0; i < fileCount; i++) {
        wchar_t filename[MAX_PATH];
        DragQueryFile(hDrop, i, filename, MAX_PATH);
        std::wstring pathStr(filename);
        replace(pathStr.begin(), pathStr.end(), '\\', '/');
        handler->SendOpenFileCommand(browser, CefString(pathStr));
    }
    return 0;
}
コード例 #27
0
ファイル: DrmShlExt.cpp プロジェクト: Ochieng/drm
//
//   FUNCTION: CDrmShlExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, 
//             HKEY)
//
//   PURPOSE: Initializes the context menu extension.
//
IFACEMETHODIMP CDrmShlExt::Initialize(
    LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID)
{
    HRESULT hr = E_INVALIDARG;
    
    if (NULL == pDataObj)
    {
        return hr;
    }

    FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
    STGMEDIUM stm;

    // pDataObj contains the objects being acted upon. In this project, 
    // we get an HDROP handle for enumerating the selected files.
    if (SUCCEEDED(pDataObj->GetData(&fe, &stm)))
    {
        // Get an HDROP handle.
        HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));
        if (hDrop != NULL)
        {
            // Determine how many files are involved in this operation.
            UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
            if (nFiles != 0)
            {
                // Get the name of the first file.
                if (0 != DragQueryFile(hDrop, 0, m_szFileName, MAX_PATH))
                {
                    hr = S_OK;
                }

                // [-or-]
				//store the list of filenames in our list				
				wchar_t tmpFile[MAX_PATH]; //temporary string to hold a file
				for(UINT i = 0; i < nFiles; i++)
				{
					if (0 == DragQueryFile(hDrop, i, tmpFile, MAX_PATH))
						hr = E_INVALIDARG;
					else
						this->fileList.push_front(tmpFile);
				}
                //hr = S_OK;
            }

            GlobalUnlock(stm.hGlobal);
        }

        ReleaseStgMedium(&stm);
    }

    // If any value other than S_OK is returned from the method, the context 
    // menu is not displayed.
    return hr;
}
コード例 #28
0
/* Determines the drop effect based on the
location of the source and destination
directories.
Note that the first dropped file is taken
as representative of the rest (meaning that
if the files come from different drives,
whether this operation is classed as a copy
or move is only based on the location of the
first file). */
BOOL CMyTreeView::CheckItemLocations(IDataObject *pDataObject,HTREEITEM hItem,
int iDroppedItem)
{
	FORMATETC	ftc;
	STGMEDIUM	stg;
	DROPFILES	*pdf = NULL;
	LPITEMIDLIST	pidlDest = NULL;
	TCHAR		szDestDirectory[MAX_PATH];
	TCHAR		szFullFileName[MAX_PATH];
	HRESULT		hr;
	BOOL		bOnSameDrive = FALSE;
	int			nDroppedFiles;

	ftc.cfFormat	= CF_HDROP;
	ftc.ptd			= NULL;
	ftc.dwAspect	= DVASPECT_CONTENT;
	ftc.lindex		= -1;
	ftc.tymed		= TYMED_HGLOBAL;

	hr = pDataObject->GetData(&ftc,&stg);

	if(hr == S_OK)
	{
		pdf = (DROPFILES *)GlobalLock(stg.hGlobal);

		if(pdf != NULL)
		{
			/* Request a count of the number of files that have been dropped. */
			nDroppedFiles = DragQueryFile((HDROP)pdf,0xFFFFFFFF,NULL,NULL);

			if(iDroppedItem < nDroppedFiles)
			{
				pidlDest = BuildPath(hItem);

				if(pidlDest != NULL)
				{
					/* Determine the name of the first dropped file. */
					DragQueryFile((HDROP)pdf,iDroppedItem,szFullFileName,
						SIZEOF_ARRAY(szFullFileName));

					GetDisplayName(pidlDest,szDestDirectory,SIZEOF_ARRAY(szDestDirectory),SHGDN_FORPARSING);

					bOnSameDrive = PathIsSameRoot(szDestDirectory,szFullFileName);

					CoTaskMemFree(pidlDest);
				}
			}

			GlobalUnlock(stg.hGlobal);
		}
	}

	return bOnSameDrive;
}
コード例 #29
0
void MainDialog::OnDropFiles(HDROP hdrop)
{
	ATL::CString path;
	UINT len = DragQueryFile(hdrop, 0, NULL, 0);
	char *pch = path.GetBufferSetLength(len);
	if(DragQueryFile(hdrop, 0, pch, len + 1)) {
		m_xml = pch;
		DoDataExchange(false, IDC_XML);
		EnableDlgItem(IDC_START);
	}
	DragFinish(hdrop);
}
コード例 #30
-1
ファイル: drop_target.cpp プロジェクト: olaolsso/pixiple
std::vector<ComPtr<IShellItem>> get_shell_items(IDataObject* object) {
	auto format = FORMATETC{CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
	STGMEDIUM stgm;
	if (FAILED(object->GetData(&format, &stgm)))
		return {};

	auto hdrop = reinterpret_cast<HDROP>(stgm.hGlobal);
	auto n_paths = DragQueryFile(hdrop, 0xffffffff, nullptr, 0);

	std::vector<ComPtr<IShellItem>> items;
	for (UINT i = 0; i < n_paths; i++) {
		auto buffer_size = er = DragQueryFile(hdrop, i, nullptr, 0);
		std::vector<wchar_t> buffer(buffer_size + 1);
		buffer[buffer_size] = L'\0';
		er = DragQueryFile(hdrop, i, buffer.data(), numeric_cast<UINT>(buffer.size()));

		ComPtr<IShellItem> si;
		er = SHCreateItemFromParsingName(
			buffer.data(), nullptr, IID_IShellItem, reinterpret_cast<void**>(&si));
		items.push_back(si);
	}
	ReleaseStgMedium(&stgm);

	return items;
}