-
Notifications
You must be signed in to change notification settings - Fork 2
/
UserListView.h
279 lines (238 loc) · 7.46 KB
/
UserListView.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
// UserListView.h: interface for the CUserListView class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_USERLISTVIEW_H__F922AD93_304F_11DA_A17D_000103DD18CD__INCLUDED_)
#define AFX_USERLISTVIEW_H__F922AD93_304F_11DA_A17D_000103DD18CD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <no5tl\htmllistbox.h>
#include <no5tl\no5tlbase.h> // simplemap
#include "iuserlistview.h"
using namespace NO5TL;
class CUserListView;
class CUserListBox : \
public NO5TL::CHtmlListBoxImpl<CUserListBox>,
public IDispatchImpl<IDocHostUIHandlerDispatch, &IID_IDocHostUIHandlerDispatch, &LIBID_ATLLib>
{
typedef NO5TL::CHtmlListBoxImpl<CUserListBox> _BaseClass;
struct UserData
{
CUser *m_pUser;
bool m_bExpanded;
UserData(void)
{
m_pUser = NULL;
m_bExpanded = false;
}
};
public:
//DECLARE_WND_SUPERCLASS(NULL,CUserListBox::GetWndClassName())
BEGIN_MSG_MAP(CUserListBox)
MESSAGE_HANDLER(WM_CREATE,OnCreate)
MESSAGE_HANDLER(WM_DESTROY,OnDestroy)
CHAIN_MSG_MAP(_BaseClass)
ALT_MSG_MAP(1)
NOTIFY_CODE_HANDLER(HLBN_SELCHANGED,OnSelChanged)
NOTIFY_CODE_HANDLER(HLBN_COMPAREITEM,OnCompareItem)
NOTIFY_CODE_HANDLER(HLBN_DELETEITEM,OnDeleteItem)
NOTIFY_CODE_HANDLER(HLBN_CLICK,OnItemClick)
NOTIFY_CODE_HANDLER(HLBN_DBLCLK,OnItemDoubleClick)
END_MSG_MAP()
int AddUser(CUser *pUser);
int FindUser(CUser *pUser);
int FindUser(LPCTSTR name);
void UpdateUser(CUser *pUser);
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//
LRESULT OnSelChanged(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
LRESULT OnCompareItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
LRESULT OnDeleteItem(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
LRESULT OnItemClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
LRESULT OnItemDoubleClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);
// IDocHostUIHandlerDispatch
STDMETHOD(ShowContextMenu)(
/* [in] */ DWORD dwID,
/* [in] */ DWORD x,
/* [in] */ DWORD y,
/* [in] */ IUnknown *pcmdtReserved,
/* [in] */ IDispatch *pdispReserved,
/* [retval][out] */ HRESULT *dwRetVal);
STDMETHOD(GetHostInfo)(
/* [out][in] */ DWORD *pdwFlags,
/* [out][in] */ DWORD *pdwDoubleClick)
{
return S_FALSE;
}
STDMETHOD(ShowUI)(
/* [in] */ DWORD dwID,
/* [in] */ IUnknown *pActiveObject,
/* [in] */ IUnknown *pCommandTarget,
/* [in] */ IUnknown *pFrame,
/* [in] */ IUnknown *pDoc,
/* [retval][out] */ HRESULT *dwRetVal)
{
return S_FALSE;
}
STDMETHOD(HideUI)( void)
{
return S_FALSE;
}
STDMETHOD(UpdateUI)( void)
{
return S_FALSE;
}
STDMETHOD(EnableModeless)(
/* [in] */ VARIANT_BOOL fEnable)
{
return S_FALSE;
}
STDMETHOD(OnDocWindowActivate)(
/* [in] */ VARIANT_BOOL fActivate)
{
return S_FALSE;
}
STDMETHOD(OnFrameWindowActivate)(
/* [in] */ VARIANT_BOOL fActivate)
{
return S_FALSE;
}
STDMETHOD(ResizeBorder)(
/* [in] */ long left,
/* [in] */ long top,
/* [in] */ long right,
/* [in] */ long bottom,
/* [in] */ IUnknown *pUIWindow,
/* [in] */ VARIANT_BOOL fFrameWindow)
{
return S_FALSE;
}
STDMETHOD(TranslateAccelerator)(
/* [in] */ DWORD hWnd,
/* [in] */ DWORD nMessage,
/* [in] */ DWORD wParam,
/* [in] */ DWORD lParam,
/* [in] */ BSTR bstrGuidCmdGroup,
/* [in] */ DWORD nCmdID,
/* [retval][out] */ HRESULT *dwRetVal)
{
return S_FALSE;
}
STDMETHOD(GetOptionKeyPath)(
/* [out] */ BSTR *pbstrKey,
/* [in] */ DWORD dw)
{
return S_FALSE;
}
STDMETHOD(GetDropTarget)(
/* [in] */ IUnknown *pDropTarget,
/* [out] */ IUnknown **ppDropTarget)
{
return S_FALSE;
}
STDMETHOD(GetExternal)(
/* [out] */ IDispatch **ppDispatch)
{
*ppDispatch = NULL;
return S_FALSE;
}
STDMETHOD(TranslateUrl)(
/* [in] */ DWORD dwTranslate,
/* [in] */ BSTR bstrURLIn,
/* [out] */ BSTR *pbstrURLOut)
{
return S_FALSE;
}
STDMETHOD(FilterDataObject)(
/* [in] */ IUnknown *pDO,
/* [out] */ IUnknown **ppDORet)
{
return S_FALSE;
}
// IUnknown
STDMETHOD(QueryInterface)(REFIID iid,LPVOID *ppvObj)
{
HRESULT hr = S_OK;
*ppvObj = NULL;
if(InlineIsEqualUnknown(iid)){
*ppvObj = static_cast<IUnknown *>(this);
}
else if(InlineIsEqualGUID(iid,IID_IDispatch))
{
*ppvObj = static_cast<IDispatch *>(this);
}
else if(InlineIsEqualGUID(iid,IID_IDocHostUIHandlerDispatch)){
*ppvObj = static_cast<IDocHostUIHandlerDispatch *>(this);
}
else
hr = E_NOINTERFACE;
if(SUCCEEDED(hr)){
IUnknown *p = static_cast<IUnknown *>(this);
p->AddRef();
}
return hr;
}
STDMETHOD_(ULONG,AddRef)(void)
{
return 1;
}
STDMETHOD_(ULONG,Release)(void)
{
return 1;
}
CUserListBox(CUserListView *pOutter):m_pOutter(pOutter),m_client_images(false)
{
//
}
private:
void FormatText(bool bsel,UserData *p,CString &out);
void FormatInfotagString(CUser *pUser,CString &out);
void FormatYmsgInfo(CUser *pUser,CString &out);
BOOL OnImageClicked(NO5TL::CHtmlElement &el,NO5TL::HLBITEM &item);
BOOL OnInputClicked(NO5TL::CHtmlElement &el,NO5TL::HLBITEM &item);
BOOL LoadClientImageNames(void);
//
CString m_ImgUser;
CString m_ImgUserSel;
CString m_ImgUp;
CString m_ImgCam;
CUserListView *m_pOutter;
NO5TL::CNo5SimpleMap<CString,CString> m_client_images;
friend CUserListView;
};
class CUserListView : \
public CWindowImpl<CUserListView>,
public IUserListView
{
typedef CWindowImpl<CUserListView> _BaseClass;
public:
CUserListView();
virtual ~CUserListView();
BEGIN_MSG_MAP(CUserListView)
MESSAGE_HANDLER(WM_CREATE,OnCreate)
MESSAGE_HANDLER(WM_DESTROY,OnDestroy)
MESSAGE_HANDLER(WM_SIZE,OnSize)
CHAIN_MSG_MAP_ALT_MEMBER(m_lb,1)
END_MSG_MAP()
// Handler prototypes (uncomment arguments if needed):
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
// IUserListView
virtual void AddUser(CUser *p);
virtual void RemoveUser(LPCSTR user);
virtual void RemoveAll(void);
virtual void AddUsers(CUserList &users);
virtual void SetSink(IUserListViewEvents *pSink);
virtual void UpdateUser(CUser *pUser);
private:
IUserListViewEvents *m_pSink;
CUserListBox m_lb;
friend CUserListBox;
void OnContextMenu(CUser *pUser,POINT &pt);
};
#endif // !defined(AFX_USERLISTVIEW_H__F922AD93_304F_11DA_A17D_000103DD18CD__INCLUDED_)