-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMiniExplorerWnd.h
120 lines (99 loc) · 2.74 KB
/
MiniExplorerWnd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#pragma once
#include <atlbase.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlapp.h>
#include <atlcrack.h>
#include <Shlobj.h>
#include <set>
template <class T>
class Registered
{
public:
Registered(T* pThis)
: m_pThis(pThis)
{
ATLVERIFY(m_pThis != nullptr);
if (m_pThis != nullptr)
s_registry.insert(m_pThis);
}
~Registered()
{
ATLVERIFY(m_pThis != nullptr);
s_registry.erase(m_pThis);
}
static const std::set<T*>& get() { return s_registry; }
private:
T* m_pThis;
static std::set<T*> s_registry;
};
typedef CWinTraits<WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES | WS_EX_APPWINDOW /*| WS_EX_TOOLWINDOW*/> CMiniExplorerTraits;
struct MiniExplorerSettings
{
FOLDERVIEWMODE ViewMode;
FOLDERFLAGS flags;
int iIconSize;
};
class CMiniExplorerWnd : public CWindowImpl<CMiniExplorerWnd, CWindow, CMiniExplorerTraits>,
public Registered<CMiniExplorerWnd>
{
public:
static LPCTSTR GetWndCaption()
{
return _T("Mini Explorer");
}
CMiniExplorerWnd(int id, CComPtr<IShellFolder> pShellFolder)
: Registered<CMiniExplorerWnd>(this)
, m_id(id), m_pShellFolder(pShellFolder)
, m_dwCookie(0)
{
ATLVERIFY(m_pShellFolder != nullptr);
}
BEGIN_MSG_MAP(CMiniExplorerWnd)
MSG_WM_CREATE(OnCreate)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_SIZE(OnSize)
MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
MSG_WM_SETFOCUS(OnSetFocus)
MSG_WM_DPICHANGED(OnDpiChanged)
MSG_WM_SYSCOMMAND(OnSysCommand)
END_MSG_MAP()
int GetId() const
{
return m_id;
}
void SetId(int id);
void GetPidl(_Outptr_ PIDLIST_ABSOLUTE* ppidl) const
{
ATLVERIFY(SUCCEEDED(SHGetIDListFromObject(m_pShellFolder, ppidl)));
}
void OnFinalMessage(_In_ HWND /*hWnd*/) override
{
delete this;
}
HRESULT TranslateAccelerator(MSG* pmsg)
{
return m_pShellView->TranslateAccelerator(pmsg);
}
private:
int OnCreate(LPCREATESTRUCT lpCreateStruct);
void OnDestroy();
void OnSize(UINT nType, CSize size);
void OnEnterSizeMove();
void OnExitSizeMove();
void OnSetFocus(CWindow wndOld);
void OnDpiChanged(UINT nDpiX, UINT nDpiY, PRECT pRect);
void OnSysCommand(UINT nID, CPoint point);
int m_id;
CComPtr<IShellFolder> m_pShellFolder;
CComPtr<IShellView> m_pShellView;
#ifdef USE_EXPLORER_BROWSER
CComPtr<IExplorerBrowser> m_pExplorerBrowser;
#else
CComPtr<IShellBrowser> m_pShellBrowser;
CWindow m_hViewWnd;
#endif
CComPtr<DShellFolderViewEvents> m_pEvents;
DWORD m_dwCookie;
};