78 _super::SetMaxLine(maxLine);
102 if ( ! _super::PostMessage(WM_CLB_POSTSTRING, nIndex,
reinterpret_cast<LPARAM
>(P)) )
121 return m_InsertString(nIndex, P);
144 virtual int GetText(
int nIndex, LPTSTR lpszBuffer)
const
159 virtual void GetText(
int nIndex, CString& rString)
const
163 rString = m_lineDatas[nIndex];
177 _super::SetMaxLine(l);
180 m_Settle(
ToInt((index < 0) ? (datas.
GetSize() - 1) : index));
201 LPTSTR P =
new TCHAR[len];
212 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
214 if ( lpDrawItemStruct->CtlType != ODT_LISTBOX || lpDrawItemStruct->hwndItem != _super::GetSafeHwnd() )
218 UINT index = lpDrawItemStruct->itemID;
223 LPTSTR P = m_lineDatas[index];
224 HDC dc = lpDrawItemStruct->hDC;
225 COLORREF textColor = 0;
226 HBRUSH backBrush = NULL;
227 if ( (lpDrawItemStruct->itemState & ODS_SELECTED) == 0 )
229 textColor = ::GetSysColor(COLOR_WINDOWTEXT);
230 backBrush = ::GetSysColorBrush(COLOR_WINDOW);
234 textColor = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
235 backBrush = ::GetSysColorBrush(COLOR_HIGHLIGHT);
237 COLORREF currentTextColor = ::SetTextColor(dc, textColor);
238 int currentBkMode = ::SetBkMode(dc, TRANSPARENT);
239 ::FillRect(dc, &(lpDrawItemStruct->rcItem), backBrush);
240 RECT rect = lpDrawItemStruct->rcItem;
241 rect.top += m_margin;
242 ::DrawText(dc, P, -1, &rect, DT_SINGLELINE | DT_NOPREFIX);
243 if ( (lpDrawItemStruct->itemState & ODS_FOCUS) != 0 )
245 ::SetTextColor(dc, 0);
246 ::DrawFocusRect(dc, &(lpDrawItemStruct->rcItem));
248 ::SetBkMode(dc, currentBkMode);
249 ::SetTextColor(dc, currentTextColor);
270 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
272 int index =
ToInt(wParam);
277 LRESULT r = _super::WindowProc(message, wParam, lParam);
285 if ( m_clientSize.cx < 0 )
288 _super::GetClientRect(rc);
289 m_clientSize.cy = rc.Height();
290 m_clientSize.cx = rc.Width();
292 HDC dc =
reinterpret_cast<HDC
>(wParam);
293 int y = (_super::GetCount() - _super::GetTopIndex()) * m_itemHeight;
294 int h = m_clientSize.cy;
301 HBRUSH b =
static_cast<HBRUSH
>(::GetCurrentObject(dc, OBJ_BRUSH));
302 ::FillRect(dc, CRect(0, y, m_clientSize.cx, h), b);
307 m_clientSize.cy = HIWORD(lParam);
308 m_clientSize.cx = LOWORD(lParam);
312 _super::RedrawWindow();
314 case WM_CLB_POSTSTRING:
316 LPTSTR P =
reinterpret_cast<LPTSTR
>(lParam);
317 m_InsertString(index, P);
334 STRLIB::Copy(
reinterpret_cast<TCHAR*
>(lParam), m_lineDatas[index]);
338 case LB_DELETESTRING:
339 if ( lParam != MAGIC_LPARAM )
343 m_lineDatas.
Remove(index);
349 case LB_RESETCONTENT:
350 if ( lParam != MAGIC_LPARAM )
352 if ( m_lineDatas.
GetSize() > 0 )
361 UINT wm = WM_CLB_POSTSTRING;
363 while ( ::PeekMessage(&msg, _super::GetSafeHwnd(), wm, wm, PM_REMOVE) )
365 if ( msg.message == wm )
367 LPTSTR P =
reinterpret_cast<LPTSTR
>(msg.lParam);
374 return _super::WindowProc(message, wParam, lParam);
385 DWORD dwStyle = _super::GetStyle();
386 ASSERT( (dwStyle & LBS_OWNERDRAWFIXED) != 0 );
387 ASSERT( (dwStyle & LBS_HASSTRINGS) == 0 );
388 ASSERT( (dwStyle & LBS_MULTICOLUMN) == 0 );
389 ASSERT( m_lineDatas.
GetSize() == 0 );
391 ASSERT( (dwStyle & LBS_NODATA) != 0 );
394 _super::PreSubclassWindow();
403 _super::PostNcDestroy();
408 MAGIC_LPARAM =
'Tllb'
411 void m_Settle(
int index = -1)
415 _super::SendMessage(LB_SETCOUNT, l ,0);
419 _super::SendMessage(LB_RESETCONTENT, 0, MAGIC_LPARAM);
423 size_t ll = _super::GetCount();
429 _super::SendMessage(LB_ADDSTRING, 0,
reinterpret_cast<LPARAM
>(_T(
"")));
436 _super::SendMessage(LB_DELETESTRING, 0, MAGIC_LPARAM);
440 ASSERT( l == _super::GetCount() );
444 _super::SetTopIndex(index);
446 if ( m_itemHeight < 0 )
449 _super::GetFont()->GetLogFont(&lf);
450 m_itemHeight = lf.lfHeight;
451 if ( m_itemHeight < 0 )
453 m_itemHeight = -m_itemHeight;
455 m_itemHeight += m_margin * 2;
456 _super::SetItemHeight(0, m_itemHeight);
458 _super::DelayedRedraw();
462 int m_InsertString(
int index, LPTSTR lpszItem)
465 INDEX r = m_lineDatas.
Add(p);
466 if ( r == INVALID_INDEX )
468 int ml = _super::GetMaxLine();
469 int ll = (ml > 1000) ? 20 : 5;
471 r = m_lineDatas.
Add(p);
473 if ( r != INVALID_INDEX )
#define loop(VAR, CNT)
loop構文.
virtual size_t GetSize(void) const
[取得] 要素数取得
void SetQueueSize(size_t size)
[設定] リングキューサイズ指定.
virtual bool Remove(INDEX index)
[削除] 要素一つ削除.
virtual size_t TakeElements(size_t size, TYP *P=NULL)
[取得] 複数要素取り出し.
virtual bool RemoveAll(void)
[削除] データ全削除.
virtual INDEX Add(const TYP &t)
[追加] 要素追加.
size_t GetQueueSize(void) const
[取得] リングキューサイズ取得.
CRingQueueT< CArrayPtrHandleT< TCHAR > > CDatas
データ管理型
void SetMaxLine(int maxLine)
[設定] 最大ライン数設定.
void PostString(int nIndex, LPCTSTR lpszItem)
[追加] 文字列追加.
virtual int GetText(int nIndex, LPTSTR lpszBuffer) const
[取得] 文字列取得.
static LPTSTR CloneString(LPCTSTR lpszText)
[作成] 文字列クローン作成.
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
[通知] オーナードロー通知.
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
[通知] オーナードロー計算通知.
virtual void PostNcDestroy(void)
[通知] 破棄終了後通知
void SetMargin(DWORD m)
[設定] マージン設定
virtual void PreSubclassWindow(void)
[通知] subclassing/unsubclassing functions.
const CDatas & GetAllString(void) const
[取得] 全文字列取得.
int InsertString(int nIndex, LPCTSTR lpszItem)
[追加] 文字列追加.
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
CLightListBox(void)
コンストラクタ
void SetAllString(const CDatas &datas, int index=-1)
[設定] 全文字列設定.
int AddString(LPCTSTR lpszItem)
[追加] 文字列追加.
virtual void GetText(int nIndex, CString &rString) const
[取得] 文字列取得.
int GetMaxLine(void) const
[取得] 最大ライン数取得.
size_t GetLen(LPCSTR lpsz)
[計算] 文字列長計算(ASCII/SJIS用)
void Copy(LPSTR _dst, LPCSTR src)
[複製] 文字列コピー(ASCII/SJIS用)
int ToInt(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー
bool IsInRange(INDEX index) const
[確認] INDEXの有効確認.