本文整理汇总了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;
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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
}
}
示例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) ;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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 {
示例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);
}