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


C++ LPDATAOBJECT类代码示例

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


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

示例1: OnDrop

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

示例2: Drop

STDMETHODIMP CToolBarCombo::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect){     
  *pdwEffect=DROPEFFECT_NONE;      
  if (m_pIDataObject == NULL)         
    return E_FAIL;
  DragLeave();      

  FORMATETC formatDetails;     
  STGMEDIUM stmg;     

  // Let's get the text from the "clipboard"
  formatDetails.cfFormat = CF_TEXT;
  formatDetails.dwAspect = DVASPECT_CONTENT;
  formatDetails.lindex = -1;
  formatDetails.ptd = NULL;
  formatDetails.tymed = TYMED_HGLOBAL;

  if (SUCCEEDED(pDataObj->GetData(&formatDetails, &stmg)))
  {  
    char* sClipboard = (char*)GlobalLock(stmg.hGlobal);
    ::SetWindowTextA(m_hWnd,sClipboard);
    AddtoHistory(sClipboard);
    GlobalUnlock(stmg.hGlobal);
    if (stmg.hGlobal != NULL) 
      ReleaseStgMedium(&stmg);         
  }
  *pdwEffect=DROPEFFECT_COPY;
  //search immediately after dragging
  ::PostMessage(GetParent(),kWM_TBCOMBOSEARCH_WEB, 0, 0);
  return NOERROR;     
} 
开发者ID:henrywoo,项目名称:ultraie,代码行数:30,代码来源:ToolBarCombo.cpp

示例3: UtGetIconData

FARINTERNAL UtGetIconData(LPDATAOBJECT lpSrcDataObj, REFCLSID rclsid,
		LPFORMATETC lpforetc, LPSTGMEDIUM lpstgmed)
{
	VDATEHEAP();

	CLSID clsid = rclsid;
	
	lpstgmed->tymed = TYMED_NULL;
	lpstgmed->pUnkForRelease = NULL;
	lpstgmed->hGlobal = NULL;
		
	if (lpSrcDataObj)
	{
	    if (lpSrcDataObj->GetData(lpforetc, lpstgmed) == NOERROR)
		    return NOERROR;
	    
	    if (IsEqualCLSID(clsid, CLSID_NULL))
		    UtGetClassID(lpSrcDataObj, &clsid);
	}
	
	// get data from registration database
	lpstgmed->hGlobal = OleGetIconOfClass(clsid, NULL, TRUE);
		
	if (lpstgmed->hGlobal == NULL)
	    return ResultFromScode(E_OUTOFMEMORY);
	else
	    lpstgmed->tymed = TYMED_MFPICT;

	return NOERROR;
}               
开发者ID:mingpen,项目名称:OpenNT,代码行数:30,代码来源:ole2util.cpp

示例4: Initialize

HRESULT CShellMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID)
{
	if(NULL == lpdobj)
	{
		return E_INVALIDARG;
	}

	FORMATETC feFmtEtc	= { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	STGMEDIUM mdmSTG	= { TYMED_HGLOBAL };
				
	if(FAILED(lpdobj->GetData(&feFmtEtc, &mdmSTG)))
	{
		return E_INVALIDARG;
	}

	HDROP hDrop = (HDROP)GlobalLock(mdmSTG.hGlobal);
    if(NULL == hDrop)
	{
        return E_INVALIDARG;
	}

	int nDropCount = ::DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
	
	if(nDropCount > 1)
		m_bMultiFile = true;
	else
		m_bMultiFile = false;

	if(nDropCount == 1)
	{
		::DragQueryFile(hDrop, 0, m_FileName, MAX_PATH);
	}

	return S_OK;
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:35,代码来源:ShellMenu.cpp

示例5: DragEnter

STDMETHODIMP CToolBarCombo::DragEnter(LPDATAOBJECT pDataObj , DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect){     
  m_pIDataObject=NULL;
  ATL::CString sText;

  FORMATETC formatDetails;     
  STGMEDIUM stmg;     

  // Let's get the text from the "clipboard"
  formatDetails.cfFormat = CF_TEXT;
  formatDetails.dwAspect = DVASPECT_CONTENT;
  formatDetails.lindex = -1;
  formatDetails.ptd = NULL;
  formatDetails.tymed = TYMED_HGLOBAL;

  if (SUCCEEDED(pDataObj->GetData(&formatDetails, &stmg)))
  {
    sText = (LPSTR)GlobalLock(stmg.hGlobal);
    GlobalUnlock(stmg.hGlobal);

    if (stmg.hGlobal != NULL) 
      ReleaseStgMedium(&stmg);             
  }

  *pdwEffect=DROPEFFECT_COPY;

  m_pIDataObject=pDataObj;     
  m_pIDataObject->AddRef();      

  return NOERROR;     
}       
开发者ID:henrywoo,项目名称:ultraie,代码行数:30,代码来源:ToolBarCombo.cpp

示例6: Initialize

/// \brief Called by the shell when initializing a context menu or property sheet extension.
/// \param pIDFolder	Specifies the parent folder
/// \param pDataObj		Spefifies the set of items selected in that folder.
/// \param hRegKey		Specifies the type of the focused item in the selection.
/// \return						NOERROR in all cases.
/// Note that at the time this function is called, we don't know
/// (or care) what type of shell extension is being initialized.
/// It could be a context menu or a property sheet.\n
/// Extra: Implements the IShellExtInit member function necessary to support
/// the context menu and property sheet portioins of this shell extension.
STDMETHODIMP CContextMenu::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey)
{
	ODS("CContextMenu::Initialize()");

	// 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();
		
		STGMEDIUM medium;
		FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
		UINT uCount;

		if(SUCCEEDED(m_pDataObj->GetData(&fe, &medium)))
		{
			// Get the file name from the CF_HDROP.
			uCount = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, NULL, 0);
			if(uCount)
				DragQueryFile((HDROP)medium.hGlobal, 0, m_szFile, MAX_MATROSKA_PATH-2);

			ReleaseStgMedium(&medium);
		}
	}

	return NOERROR;
}
开发者ID:Matroska-Org,项目名称:matroskautils,代码行数:43,代码来源:CContextMenu.cpp

示例7: DragEnter

STDMETHODIMP DeskDropTarget::DragEnter(LPDATAOBJECT pDataObject,
    DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
{
    AddRef();
    m_filename[0] = 0;
    if (pDataObject)
    {
        FORMATETC fmte;
        fmte.cfFormat   = CF_HDROP;
        fmte.ptd        = NULL;
        fmte.dwAspect   = DVASPECT_CONTENT;  
        fmte.lindex     = -1;
        fmte.tymed      = TYMED_HGLOBAL;

        STGMEDIUM medium;
        if (SUCCEEDED(pDataObject->GetData(&fmte, &medium)))
        {
            HDROP hDrop = (HDROP)medium.hGlobal;
            DragQueryFile(hDrop, 0, m_filename, sizeof(m_filename));
            DragFinish(hDrop);
            m_flags = is_stylefile(m_filename) ? 2 : 0;
        }
    }
    *pdwEffect = DROPEFFECT_NONE;
    return S_OK;
}
开发者ID:BackupTheBerlios,项目名称:bblean,代码行数:26,代码来源:Desk.cpp

示例8: Initialize

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

示例9: Initialize

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

示例10: Initialize

STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY hRegKey)
{
	FORMATETC	format={CF_HDROP,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
	STGMEDIUM	medium;
	int			i,nLen;
	WCHAR		szDirectory[MAX_PATH];

	HRESULT hr;
	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();
    }

	pDataObj->GetData(&format,&medium);  
	m_nSelected=DragQueryFileW((HDROP&)medium.hGlobal,0xFFFFFFFF,NULL,0);

	if (m_nSelected == -1 || m_nSelected ==0)
	{
		wcscpy(m_szCommand,L"DeleteFileInRecycled");
		return NOERROR;
	}
	m_szCommand[0] = L'\0';
	for(i=0;i<m_nSelected;i++)
	{
		DragQueryFileW((HDROP&)medium.hGlobal,i,szDirectory,MAX_PATH);
		if (i != 0)
			wcscat(m_szCommand,L" ");
		nLen = wcslen(m_szCommand);
		m_szCommand[nLen] = L'"';
		m_szCommand[nLen+1] = L'\0';
		wcscat(m_szCommand,szDirectory);
		nLen = wcslen(m_szCommand);
		m_szCommand[nLen] = L'"';
		m_szCommand[nLen+1] = L'\0';
	}
    return NOERROR;
}
开发者ID:xfxf123444,项目名称:japan,代码行数:47,代码来源:SHEXINIT.CPP

示例11: Initialize

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;
}
开发者ID:thecocce,项目名称:renameit,代码行数:59,代码来源:SimpleShlExt.cpp

示例12: Initialize

STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) {
  HRESULT hres = 0;
  if (m_pDataObj)
    m_pDataObj->Release();
  if (pDataObj) {
    m_pDataObj = pDataObj;
    pDataObj->AddRef();
  }
  return NOERROR;
}
开发者ID:TodWulff,项目名称:npp-community,代码行数:10,代码来源:nppcm.cpp

示例13: Initialize

// *** IShellExtInit methods ***
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST /*pIDFolder*/, LPDATAOBJECT pDataObj, HKEY /*hRegKey*/) {
	if (m_pDataObj) {
		m_pDataObj->Release();
		m_pDataObj = NULL;
	}
	if (pDataObj) {
		m_pDataObj = pDataObj;
		pDataObj->AddRef();
	}
	return NOERROR;
}
开发者ID:Tanjas5,项目名称:npp,代码行数:12,代码来源:NppShell.cpp

示例14: Initialize

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

示例15: Initialize

STDMETHODIMP CDeskBand::Initialize(LPCITEMIDLIST pIDFolder,
                                   LPDATAOBJECT pDataObj,
                                   HKEY /* hRegKey */)
{
    m_ContextItems.clear();
    m_ContextDirectory.clear();
    // get selected files/folders
    if (pDataObj)
    {
        STGMEDIUM medium;
        FORMATETC fmte = {(CLIPFORMAT)g_shellidlist,
            (DVTARGETDEVICE FAR *)NULL,
            DVASPECT_CONTENT,
            -1,
            TYMED_HGLOBAL};
        HRESULT hres = pDataObj->GetData(&fmte, &medium);

        if (SUCCEEDED(hres) && medium.hGlobal)
        {
            //Enumerate PIDLs which the user has selected
            CIDA* cida = (CIDA*)GlobalLock(medium.hGlobal);
            ItemIDList parent( GetPIDLFolder (cida));

            int count = cida->cidl;
            for (int i = 0; i < count; ++i)
            {
                ItemIDList child (GetPIDLItem (cida, i), &parent);
                tstring str = child.toString();
                if (str.empty() == false)
                {
                    m_ContextItems[str] = ENABLED_VIEWPATH|ENABLED_FOLDERSELECTED|ENABLED_FILESELECTED;
                }
            }
            GlobalUnlock(medium.hGlobal);

            ReleaseStgMedium ( &medium );
            if (medium.pUnkForRelease)
            {
                IUnknown* relInterface = (IUnknown*)medium.pUnkForRelease;
                relInterface->Release();
            }
        }
    }

    // get folder background
    if (pIDFolder)
    {
        ItemIDList list(pIDFolder);
        m_ContextDirectory = list.toString();
    }

    return NOERROR;
}
开发者ID:SpivEgin,项目名称:stexbar,代码行数:53,代码来源:ContextMenu.cpp


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