I'm trying to implement explorer-like frame in my application. This must work under WinXP too.
I've implemented IShellBrowser
in my window-class + i've implemented IUnknown
interface.
My class atributs:
IShellViewPtr m_shView;
HWND m_wndHolder;
CListViewCtrl view;
Here is the code of WM_CREATE
handler
m_hWndClient = view.Create(m_hWnd, rcDefault, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); // view isn't null after it
CMessageLoop* pLoop = _Module.GetMessageLoop();
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
IShellFolderPtr pParentFolder;
ATLVERIFY(SHGetDesktopFolder(&pParentFolder) == S_OK); // OK
FOLDERSETTINGS fs;
fs.fFlags = FVM_DETAILS;
fs.ViewMode = FVM_LIST;
ATLVERIFY(pParentFolder->CreateViewObject(view, IID_IShellView, (void**)&m_shView) == S_OK); // OK
RECT r;
GetClientRect(&r);
ATLVERIFY(m_shView->CreateViewWindow(NULL, &fs, static_cast<IShellBrowser*>(this), &r, &m_wndHolder) == S_OK); // OK
ATLVERIFY(m_shView->UIActivate(SVUIA_ACTIVATE_NOFOCUS) == S_OK); // OK
After the application is started i have explorer-like frame in it.
I want to handle double click event in order to navigate through the folders in the frame. I expect that after double-clicking my implementation of BrowseObject
will be called, but it doesn't happened. Instead of this folders are opened in system explorer.
Please help. Thank you.
I've solved the problem.
First you have to
IServiceProvider
interface if your class. Implementation should look like this:Also you have to add
IServiceProvider
support in yourQueryInterface
method.After you'll inherit
IServiceProvider
, you can't cast you class toIUnknown
using juststatic_cast<IUnknown*>(this)
, so you need to write something like i did.After that
BrowseObject
should be called fine.