SOL9 Sample: SolExplorerBrowser
|
1 Screenshot
2 Source code
/*
* SolExplorerBrowser.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9 2.0
// 2012/11/03
// This is a simple sample program to browse folders, which is based on
// ExplorerBrowser and ExplorerBrowserEvents classes.
#include <sol\ApplicationView.h>
#include <sol\shell\ExplorerBrowser.h>
#include <sol\shell\ExplorerBrowserEvents.h>
#include <sol\shell\ShellItem.h>
#include <sol\shell\ShellItemArray.h>
#include "resource.h"
namespace SOL {
class SolExplorerBrowser :public ApplicationView {
private:
//Inner Class ------------------------------------
//<ExplorerBrowserEventsListener>
class ExplorerBrowserEventsListener :public ExplorerBrowserEvents {
private:
SolExplorerBrowser* solExplorerBrowser;
public:
ExplorerBrowserEventsListener()
:solExplorerBrowser(NULL)
{
}
public:
void setApplicationView(SolExplorerBrowser* view)
{
solExplorerBrowser = view;
}
public:
virtual HRESULT STDMETHODCALLTYPE OnNavigationComplete(
/* [in */ PCIDLIST_ABSOLUTE pidlFolder)
{
const TCHAR* title = _T("SolExplorerBrowser");
solExplorerBrowser->setText(title);
try {
ShellItem shellItem(pidlFolder);
_bstr_t name = shellItem.getDisplayName();
TCHAR caption[1024];
_stprintf_s(caption, CountOf(caption), _T("%s - %s"), (const TCHAR*)_bstr_t(name), title );
solExplorerBrowser->setText(caption);
} catch (...) {
}
return S_OK;
}
};
//</ExplorerBrowserEventsListener>
private:
ExplorerBrowser explorerBrowser;
ExplorerBrowserEventsListener eventListener;
public:
/**
* Constructor
*/
SolExplorerBrowser(Application& applet, const TCHAR* name, Args& args)
:ApplicationView(applet, name, args)
{
explorerBrowser.initialize(*this);
explorerBrowser.browseToFolder(FOLDERID_Desktop);
eventListener.setApplicationView(this);
explorerBrowser.advise(
static_cast<IExplorerBrowserEvents *>(&eventListener));
addCallback(XmNmenuCallback, IDM_EXIT, this,
(Callback)&ApplicationView::exit, NULL);
addCallback(XmNmenuCallback, IDM_VERSION, this,
(Callback)&SolExplorerBrowser::version, NULL);
addEventHandler(WM_SIZE, this,
(Handler)&SolExplorerBrowser::size, NULL);
addEventHandler(WM_CLOSE, this,
(Handler)&SolExplorerBrowser::close, NULL);
restorePlacement();
//explorerBrowser.browseToPath(_T("C:\\"));
}
private:
void version(Action& action)
{
showMessageDialog(_T("Version"),
_T("SolExplorerBrowser Version 1.0.0.0\r\nCopyright(C) 2012 Antillia.com"),
MB_OK|MB_ICONINFORMATION);
}
private:
long close(Event& event)
{
savePlacement();
explorerBrowser.unadvise();
explorerBrowser.destroy();
return defaultProc(event);
}
private:
long size(Event& event)
{
int w, h;
event.getSize(w, h);
explorerBrowser.reshape(0, 0, w, h);
return 0;
}
public:
ExplorerBrowser& getExplorerBrowser()
{
return explorerBrowser;
}
};
}
//
void Main(int argc, TCHAR** argv)
{
OleInitialize(NULL);
ModuleFileName module(argv[0]);
const TCHAR* name = module.getFileName();
try {
Application applet(name, argc, argv);
Args args;
args.set(XmNclassStyle, NO_REDRAW);
args.set(XmNwidth, 600);
args.set(XmNheight, 500);
SolExplorerBrowser SolExplorerBrowser(applet, name, args);
SolExplorerBrowser.realize();
applet.run();
} catch (Exception& ex) {
caught(ex);
} catch (...) {
caught(UnknownException());
}
OleUninitialize();
}
Last modified: 1 Feb 2017
Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.