Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProgram keeps looping [Solved] Pin
CounterClockWise11-Apr-14 14:13
CounterClockWise11-Apr-14 14:13 
AnswerRe: Program keeps looping Pin
Richard Andrew x6411-Apr-14 16:26
professionalRichard Andrew x6411-Apr-14 16:26 
GeneralRe: Program keeps looping Pin
CounterClockWise11-Apr-14 16:41
CounterClockWise11-Apr-14 16:41 
QuestionDraw two monitors syncron Pin
_Flaviu10-Apr-14 22:11
_Flaviu10-Apr-14 22:11 
AnswerRe: Draw two monitors syncron Pin
Richard MacCutchan10-Apr-14 22:41
mveRichard MacCutchan10-Apr-14 22:41 
AnswerRe: Draw two monitors syncron Pin
pasztorpisti11-Apr-14 6:17
pasztorpisti11-Apr-14 6:17 
GeneralRe: Draw two monitors syncron Pin
_Flaviu13-Apr-14 22:23
_Flaviu13-Apr-14 22:23 
Question[MFC Desktop Application for enumerating Virtual customized folder and files] Windows 8 Address Bar icon problem Pin
Nirmal K P10-Apr-14 19:39
Nirmal K P10-Apr-14 19:39 
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 want to create own pidl for folder and its contents.

When I will open a particular folder, application's should inherit Win-8 Windows explorer.

I want to set customized icon for folder on top left corner(On Win-8) and at the root of address bar.


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.


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.

1. IExtractIcon interface is called from GetUIObjectOf method correctly.
2. GetIconLocation method gives correct output Index for Icon.
3. Extract function gives correct output for hIcon.

But problem is that Icon assigned to displayed was not correctly displayed at AddressBar and Caption Bar(Top-left corner).

Currently, Icon is displayed on AddressBar and Caption Bar(Top-left corner) was empty file icon.

when I set :

C++
HRESULT ExtIcon::ExtractImpl(UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall)
{
   phiconLarge = NULL;
   phiconSmall= NULL;
}


I got folder icon on the AddressBar and Caption Bar.
--------------------------------------------------------------------------------------
C++
STDMETHODIMP ShellFolderImpl::GetUIObjectOf ( HWND , UINT uCount,
                                               LPCITEMIDLIST* pPidl, REFIID riid,
                                               LPUINT, 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)
        pExtractIcon->Release();
        return hr;
    }
    catch(...){}

    return E_NOINTERFACE;
}


Extract Icon handler is as :

C++
// 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
// Windows 8: 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)


modified 11-Apr-14 8:01am.

QuestionUse PlaySound api caused memory loading? Pin
cedricvictor10-Apr-14 16:02
cedricvictor10-Apr-14 16:02 
AnswerRe: Use PlaySound api caused memory loading? Pin
Richard Andrew x6410-Apr-14 17:19
professionalRichard Andrew x6410-Apr-14 17:19 
QuestionMS Word Automation - I get so far - now what? Pin
Bryan Anslow10-Apr-14 9:43
Bryan Anslow10-Apr-14 9:43 
AnswerRe: MS Word Automation - I get so far - now what? Pin
Richard MacCutchan10-Apr-14 22:39
mveRichard MacCutchan10-Apr-14 22:39 
SuggestionRe: MS Word Automation - I get so far - now what? Pin
David Crow11-Apr-14 4:40
David Crow11-Apr-14 4:40 
QuestionList And iterator Pin
Hamza Bin Amin10-Apr-14 2:49
Hamza Bin Amin10-Apr-14 2:49 
AnswerRe: List And iterator Pin
Maximilien10-Apr-14 10:21
Maximilien10-Apr-14 10:21 
SuggestionRe: List And iterator Pin
David Crow10-Apr-14 15:49
David Crow10-Apr-14 15:49 
Questionavoiding or skipping Divide by zero showing junk values Pin
manoharbalu10-Apr-14 0:50
manoharbalu10-Apr-14 0:50 
AnswerRe: avoiding or skipping Divide by zero crashes Pin
Heng Xiangzhong10-Apr-14 1:00
Heng Xiangzhong10-Apr-14 1:00 
AnswerRe: avoiding or skipping Divide by zero crashes Pin
Heng Xiangzhong10-Apr-14 1:01
Heng Xiangzhong10-Apr-14 1:01 
GeneralRe: avoiding or skipping Divide by zero crashes Pin
manoharbalu10-Apr-14 1:51
manoharbalu10-Apr-14 1:51 
GeneralRe: e: avoiding or skipping Divide by zero crashes Pin
Richard MacCutchan10-Apr-14 2:22
mveRichard MacCutchan10-Apr-14 2:22 
AnswerRe: avoiding or skipping Divide by zero showing junk values Pin
Munchies_Matt10-Apr-14 5:53
Munchies_Matt10-Apr-14 5:53 
AnswerRe: avoiding or skipping Divide by zero showing junk values Pin
User 5924111-Apr-14 19:07
User 5924111-Apr-14 19:07 
QuestionCDHtmlDialog: Changing HTML File Dynamically Pin
Don Guy9-Apr-14 11:31
Don Guy9-Apr-14 11:31 
QuestionSetWindowText() style question Pin
econy9-Apr-14 4:24
econy9-Apr-14 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.