Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

MFC Desktop Application

$
0
0

Hi,

I am developing a MFC application on Windows 8.1 using VS-2005. Requirement is to customize Folder Explorer for a specific purpose. I will create own pidl for folder and its contents. When I will open a particular folder, my application will inherit Win-8 Window explorer and I want to set customized icon for folder on top left corner(On Win-8) and at the root of address bar.

[View-1]

Here if I will click Watch icon this should be explored and watch icon should be placed at red marked rectangles. and its virtual content should be placed on Shell view part of the folder.

I am using GetBindToObject, GetUIObjectOf, CreateViewObject, GetIconLocation and Extract method in ShellFolderImpl class. Please give me some sample source code or idea to do that. I have already studied URL - [ http://msdn.microsoft.com/en-us/library/windows/desktop/cc144093%28v=vs.85%29.aspx ] but it is not working.

Currently I am getting view like this

[View-2]

This method is in ShellFolderImpl class

BindToObject, CreateViewObject, etc functions are working correctly.......
Icon index and Icon is loaded correctly. bcz I saved created icon from Extract method.
But emplty icon is placed at specified place on folder as given in above image.
---------------------------------------------------------------------------------------------
STDMETHODIMP ShellFolderImpl::GetUIObjectOf ( HWND /*hwndOwner*/, UINT uCount,
                                               LPCITEMIDLIST* pPidl, REFIID riid,
                                               LPUINT /*puReserved*/, void** ppvReturn )
{

    try
    {

    *ppvReturn = NULL;

    if( uCount != 1 )
       return E_FAIL;

    // IExtractIcon
    if( IsEqualIID(riid, IID_IExtractIconA)|| IsEqualIID(riid, IID_IExtractIconW))
    {
        CComObject<ExtIcon>* pExtractIcon;
        HRESULT hr = CComObject<ExtIcon>::CreateInstance ( &pExtractIcon );
        if (FAILED(hr))
            return hr;
        
    
        // Tight its lifetime with this object (the IShellFolder object)
        pExtractIcon->Init(GetUnknown());
        
        pExtractIcon->AddRef();
        pExtractIcon->SetMyPIDL((LPITEMIDLIST)*pPidl);
        
        // Return the requested interface to the caller
        hr = pExtractIcon->QueryInterface(riid, ppvReturn);
        
        // We do no more need our ref (note that the object will not die because the QueryInterface above, AddRef'd it)
        pExtractIcon->Release();
        return hr;
    }
    catch(...){}

    return E_NOINTERFACE;
}
--------------------------------------------------------------------------
// ExtIcon.h : Declaration of the ExtIcon

#pragma once
#include "resource.h"  
#include "PluginRes.h"// main symbols
#include "pidlmgr.h"
#include "ExplorerPlugIn.h"


// ExtIcon

// IExtractIconA
// Windows XP, Vista: IExtractIconW
// Windows 7: IExtractIconA
class ATL_NO_VTABLE ExtIcon :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<ExtIcon, &CLSID_ExtIcon>,
    public IDispatchImpl<IExtIcon, &IID_IExtIcon, &LIBID_ExplorerPlugInLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
    public IExtractIconA,
    public IExtractIconW
{
public:
    ExtIcon()
    {
    }
    ExtIcon(LPCITEMIDLIST pidl);



DECLARE_REGISTRY_RESOURCEID(IDR_EXTICON)


BEGIN_COM_MAP(ExtIcon)
    COM_INTERFACE_ENTRY_IID(IID_IExtractIconA, IExtractIconA)
    COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW)
    COM_INTERFACE_ENTRY(IExtIcon)
    COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()


    DECLARE_PROTECT_FINAL_CONSTRUCT()

    HRESULT FinalConstruct()
    {
        return S_OK;
    }
    
    void FinalRelease()
    {
    }

public:
    // IExtractIconA
    STDMETHOD(GetIconLocation)(THIS_ UINT, LPSTR, UINT, int* piIndex, UINT* pwFlags)
    {
        return GetIconLocationImpl(piIndex, pwFlags);
    }
    STDMETHOD(Extract)(THIS_ LPCSTR, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT)
    {
        return ExtractImpl(nIconIndex, phiconLarge, phiconSmall);
    }
    // IExtractIconW
    STDMETHOD(GetIconLocation)(THIS_ UINT, LPWSTR, UINT, int* piIndex, UINT* pwFlags)
    {
        return GetIconLocationImpl(piIndex, pwFlags);
    }
    STDMETHOD(Extract)(THIS_ LPCWSTR, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT)
    {
        return ExtractImpl(nIconIndex, phiconLarge, phiconSmall);
    }

    // Ensure the owner object is not freed before this one
    void Init(IUnknown *pUnkOwner);

    void SetMyPIDL(LPITEMIDLIST pidl)
    {
        m_pidl = pidl;
    }
    //CExtIcon( LPCITEMIDLIST /*pidl*/ );
    enum BoxType
    {
        PUBLIC,
        PRIVATE
    };

private:
    HRESULT GetIconLocationImpl(int*, UINT*);
    HRESULT ExtractImpl(UINT, HICON*, HICON*);

    CPidlMgr* m_pPidlMgr;
    LPITEMIDLIST m_pidl;
    BOOL m_bIsOpenIcon;
    protected:
         CComPtr<IUnknown> m_UnkOwnerPtr;
   DWORD m_ObjRefCount;

};

OBJECT_ENTRY_AUTO(__uuidof(ExtIcon), ExtIcon)

Sorry currently I am unable to add image file with message bcz of the message :

[Body text cannot contain images or links until we are able to verify your account.]

Thanks.


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>