isf.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 8k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*****************************************************************************
  2.     FILE: isf.h
  3.     DESCRIPTION:
  4.         This is a base class that implements the default behavior of IShellFolder.
  5. *****************************************************************************/
  6. #ifndef _DEFAULT_ISHELLFOLDER_H
  7. #define _DEFAULT_ISHELLFOLDER_H
  8. #include "cowsite.h"
  9. /*****************************************************************************
  10.     CLASS: CBaseFolder
  11.     DESCRIPTION:
  12.         The stuff that tracks the state of a folder.
  13.     The cBusy field tracks how many sub-objects have been created
  14.     (e.g., IEnumIDList) which still contain references to this
  15.     folder's identity.  You cannot change the folder's identity
  16.     (via IPersistFolder::Initialize) while there are outstanding
  17.     subobjects.
  18.     The number of cBusy's never exceeds the number of cRef's, because
  19.     each subobject that requires the folder identity must retain a
  20.     reference to the folder itself.  That way, the folder won't be
  21.     Release()d while the identity is still needed.
  22.     Name Space description (for m_pidlComplete & m_nIDOffsetToOurNameSpaceRoot):
  23.     The name space is provided by the shell to describe resources for the user.
  24.     This class is a base implementation so users can create their own name space
  25.     that is rooted in the shell's name space.  A PIDL is a list of ItemID, each of
  26.     which represent one level in the name space.  The list provides a path thru
  27.     the name space to a specific item.  Example:
  28.     [Desktop][My Computer][C:][Dir1][Dir2][File.htm][#goto_description_secion]
  29.     [Desktop][The Internet][ftp://server/][Dir1][Dir2][file.txt]
  30.     [Desktop][My Computer][PrivateNS lvl1][lvl2][lvl3]...
  31.     (Public Name Space)   (Private Name Space)
  32.     [GNS Level1][GNS Levl2][Pri LVL1][P LVL2][P LVL3]...
  33.     In the example immediately above, this CBaseFolder can create a name space
  34.     under "My Computer" that has 3 levels (lvl1, lvl2, lvl3).  An instance of this
  35.     COM object will be positioned at one level of the sub name space (lvl1, lvl2, or lvl3).
  36.     m_pidlComplete - is the list of ItemIDs from the base [Desktop] to the current location
  37.                 maybe lvl2.
  38.     m_nIDOffsetToOurNameSpaceRoot - is the number of bytes of m_pidlComplete that you need
  39.                 to skip to get to the first ItemID in the private name space (which
  40.                 is the name space owned by this class).
  41. *****************************************************************************/
  42. class CBaseFolder       : public IShellFolder2
  43.                         , public IPersistFolder3
  44.                         , public CObjectWithSite
  45. {
  46. public:
  47.     //////////////////////////////////////////////////////
  48.     // Public Interfaces
  49.     //////////////////////////////////////////////////////
  50.     
  51.     // *** IUnknown ***
  52.     virtual STDMETHODIMP_(ULONG) AddRef(void);
  53.     virtual STDMETHODIMP_(ULONG) Release(void);
  54.     virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  55.     
  56.     // *** IShellFolder ***
  57.     virtual STDMETHODIMP ParseDisplayName(HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName,
  58.                                             ULONG * pchEaten, LPITEMIDLIST * ppidl, ULONG *pdwAttributes);
  59.     virtual STDMETHODIMP EnumObjects(HWND hwndOwner, DWORD grfFlags, LPENUMIDLIST * ppenumIDList);
  60.     virtual STDMETHODIMP BindToObject(LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut);
  61.     virtual STDMETHODIMP BindToStorage(LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvObj);
  62.     virtual STDMETHODIMP CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  63.     virtual STDMETHODIMP CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID * ppvOut);
  64.     virtual STDMETHODIMP GetAttributesOf(UINT cidl, LPCITEMIDLIST * apidl, ULONG * rgfInOut);
  65.     virtual STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut);
  66.     virtual STDMETHODIMP GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
  67.     virtual STDMETHODIMP SetNameOf(HWND hwndOwner, LPCITEMIDLIST pidl, LPCOLESTR lpszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  68.     // *** IShellFolder2 ***
  69.     virtual STDMETHODIMP GetDefaultSearchGUID(GUID *pguid) {return E_NOTIMPL;};
  70.     virtual STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum) {return E_NOTIMPL;};
  71.     virtual STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) {return E_NOTIMPL;};
  72.     virtual STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) {return E_NOTIMPL;};
  73.     virtual STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) {return E_NOTIMPL;};
  74.     virtual STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd) {return E_NOTIMPL;};
  75.     virtual STDMETHODIMP MapColumnToSCID(UINT iCol, SHCOLUMNID *pscid) {return E_NOTIMPL;};
  76.     // *** IPersist ***
  77.     virtual STDMETHODIMP GetClassID(LPCLSID lpClassID);
  78.     // *** IPersistFolder ***
  79.     virtual STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  80.     
  81.     // *** IPersistFolder2 ***
  82.     virtual STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  83.     // *** IPersistFolder3 ***
  84.     virtual STDMETHODIMP InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti);
  85.     virtual STDMETHODIMP GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *ppfti);
  86. public:
  87.     CBaseFolder(LPCLSID pClassID);
  88.     virtual ~CBaseFolder(void);
  89.     // Public Member Functions
  90.     virtual HRESULT _GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut, BOOL fFromCreateViewObject);
  91.     virtual HRESULT _Initialize(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlAliasRoot, int nBytesToPrivate);
  92.     virtual HRESULT _CreateShellView(HWND hwndOwner, void ** ppvObj) = 0;       // PURE
  93.     virtual HRESULT _CreateShellView(HWND hwndOwner, void ** ppvObj, LONG lEvents, FOLDERVIEWMODE fvm, IShellFolderViewCB * psfvCallBack, 
  94.                             LPCITEMIDLIST pidl, LPFNVIEWCALLBACK pfnCallback);
  95.     LPCITEMIDLIST GetPublicTargetPidlReference(void) { return m_pidl;};
  96.     LPITEMIDLIST GetPublicTargetPidlClone(void) { return ILClone(GetPublicTargetPidlReference());};
  97.     LPCITEMIDLIST GetPublicRootPidlReference(void) { return (m_pidlRoot ? m_pidlRoot : m_pidl);};
  98.     LPITEMIDLIST GetPublicRootPidlClone(void) { return ILClone(GetPublicRootPidlReference());};
  99.     LPCITEMIDLIST GetPrivatePidlReference(void);
  100.     LPITEMIDLIST GetPrivatePidlClone(void) { return ILClone(GetPrivatePidlReference());};
  101.     LPITEMIDLIST GetPublicPidlRootIDClone(void);
  102.     LPITEMIDLIST CreateFullPublicPidlFromRelative(LPCITEMIDLIST pidlPrivateSubPidl);
  103.     LPITEMIDLIST CreateFullPrivatePidl(LPCITEMIDLIST pidlPrivateSubPidl);
  104.     LPITEMIDLIST CreateFullPublicPidl(LPCITEMIDLIST pidlPrivatePidl);
  105.     LPCITEMIDLIST GetFolderPidl(void) { return m_pidlRoot;};
  106. protected:
  107.     int                     m_cRef;
  108.     int GetPidlByteOffset(void) { return m_nIDOffsetToPrivate;};
  109. private:
  110.     LPITEMIDLIST            m_pidl;                 // Public Pidl - Complete list of IDs from very base of NameSpace to this name space and into this name space to the point of being rooted.
  111.     LPITEMIDLIST            m_pidlRoot;             // Pidl of Folder Shortcut.
  112.     int                     m_nIDOffsetToPrivate;   // number of bytes from the start of m_pidlComplete to the first ItemID in our name space.
  113.     LPCLSID                 m_pClassID;             // My CLSID
  114. };
  115. #endif // _DEFAULT_ISHELLFOLDER_H