当前位置: 首页>>代码示例>>C++>>正文


C++ DragQueryFile函数代码示例

本文整理汇总了C++中DragQueryFile函数的典型用法代码示例。如果您正苦于以下问题:C++ DragQueryFile函数的具体用法?C++ DragQueryFile怎么用?C++ DragQueryFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DragQueryFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UNREFERENCED_PARAMETER

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;
}
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:60,代码来源:BookmarksToolbar.cpp

示例2: SetActiveWindow

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);
}
开发者ID:abael,项目名称:pyui4win,代码行数:29,代码来源:MainFrm.cpp

示例3: DragAcceptFiles

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();
	}
}
开发者ID:Koogoo,项目名称:fhash,代码行数:25,代码来源:FilesHashDlg.cpp

示例4: GlobalLock

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;
}
开发者ID:4770K,项目名称:shooter-downloader,代码行数:60,代码来源:ShooterContextMenuExt.cpp

示例5: DragQueryFile

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;
}
开发者ID:codepongo,项目名称:iBurnMgr,代码行数:29,代码来源:MetroWindow.cpp

示例6: Add_File_Events

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
	}
}
开发者ID:Oldes,项目名称:R3A110,代码行数:31,代码来源:host-event.c

示例7: OnDropFile

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) ;
   }
开发者ID:mingpen,项目名称:OpenNT,代码行数:33,代码来源:perfmon.c

示例8: DragQueryFile

//---------------------------------------------------------------------------
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);
}
开发者ID:DmytroBiriukov,项目名称:RefEditor,代码行数:28,代码来源:vocab.cpp

示例9: onDropFile

/*----------*/
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);
}
开发者ID:isseki,项目名称:metacryst,代码行数:31,代码来源:misc.cpp

示例10: HandleFiles

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);
}
开发者ID:suhockii,项目名称:rsa-encryption,代码行数:29,代码来源:Source.cpp

示例11: ASSERT

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);
}
开发者ID:moodboom,项目名称:Reusable,代码行数:32,代码来源:FileEditCtrl.cpp

示例12: DragQueryFile

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);
}
开发者ID:iamduyu,项目名称:TortoiseGit,代码行数:25,代码来源:PatchListCtrl.cpp

示例13: GlobalLock

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;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:60,代码来源:EsteidShlExt.cpp

示例14: DragQueryFile

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 {
开发者ID:chinnyannieb,项目名称:Meus-Projetos,代码行数:35,代码来源:MainForm.cpp

示例15: OnDropFiles

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);
}
开发者ID:yedaoq,项目名称:YedaoqToolSpace,代码行数:30,代码来源:Png2BmpW.cpp


注:本文中的DragQueryFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。