44 , m_countOfSelected(0), m_itemOfSelected(-1), m_eraseBkGndOffset(2)
56 return _super::GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
69 _super::EnsureVisible(item,
false);
87 m_eraseBkGndOffset = f;
177 ::FillRect(dc, &rect, ::GetSysColorBrush(COLOR_WINDOW));
192 virtual BOOL
OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* _pResult)
194 if ( message == WM_NOTIFY )
196 LPNMHDR lpNmHdr =
reinterpret_cast<LPNMHDR
>(lParam);
197 if ( lpNmHdr->hwndFrom == m_hWnd)
199 LPNMLISTVIEW lpLv =
reinterpret_cast<LPNMLISTVIEW
>(lParam);
200 if ( lpLv->hdr.code == NM_CUSTOMDRAW )
202 LPNMLVCUSTOMDRAW lpLvCd =
reinterpret_cast<LPNMLVCUSTOMDRAW
>(lParam);
203 *_pResult = m_OnCustomDraw(lpLvCd);
206 else if ( lpLv->hdr.code == LVN_ITEMCHANGED )
208 SetTimer(TIMERID_CHANGED, 50, NULL);
212 return _super::OnChildNotify(message, wParam, lParam, _pResult);
225 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
231 CHeaderCtrl* H = GetHeaderCtrl();
234 HDC hdc =
reinterpret_cast<HDC
>(wParam);
236 _super::GetClientRect(clientRect);
237 CRect rect = clientRect;
238 int headerHeight = 0;
240 H->GetClientRect(&rc);
241 headerHeight = rc.Height();
242 rect.top += headerHeight;
243 if ( _super::GetItemCount() != 0 )
246 _super::GetItemRect(_super::GetTopIndex(), &rc, LVIR_BOUNDS);
248 int y = _super::GetItemCount() - _super::GetTopIndex();
250 rect.top += y * rc.Height() + m_eraseBkGndOffset;
252 if ( _super::GetItemRect (0, rc, LVIR_BOUNDS) )
254 if ( rc.right < clientRect.right)
257 rc.right = clientRect.right;
258 rc.top = clientRect.top;
259 rc.bottom = rect.top;
277 LRESULT r = _super::WindowProc(message, wParam, lParam);
283 if ( wParam == TIMERID_CHANGED )
285 KillTimer(TIMERID_CHANGED);
286 int count = _super::GetSelectedCount();
287 int item = _super::GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
288 if ( m_countOfSelected != count || m_itemOfSelected != item )
290 m_countOfSelected = count;
291 m_itemOfSelected = item;
297 KillTimer(TIMERID_CHANGED);
300 return _super::WindowProc(message, wParam, lParam);
310 ASSERT0( (_super::GetStyle() & LVS_OWNERDRAWFIXED) == 0,
"AbstractCustomListCtrl",
"Ownerデータは OFFにしてください。" );
311 _super::PreSubclassWindow();
312 _super::SetExtendedStyle(LVS_EX_FULLROWSELECT);
316 enum { TIMERID_CHANGED = 100 };
318 LRESULT m_OnItemPaintSub(LPNMLVCUSTOMDRAW P,
int subItemNo)
322 pa.itemNo =
ToDword(P->nmcd.dwItemSpec);
323 pa.subItemNo = subItemNo;
324 pa.state = P->nmcd.uItemState;
325 pa.textColor = P->clrText;
326 pa.backColor = P->clrTextBk;
327 _super::GetSubItemRect(pa.itemNo, subItemNo, LVIR_BOUNDS, pa.rect);
328 if ( m_isReportView && subItemNo == 0 )
330 pa.rect.right = pa.rect.left + _super::GetColumnWidth(subItemNo);
332 if ( m_isReportView && (pa.rect.right < 0 || pa.rect.left > m_clientWidth) )
335 return CDRF_SKIPDEFAULT;
339 pa.state |= CDIS_SELECTED;
343 pa.state &= ~CDIS_SELECTED;
346 P->clrText = pa.textColor;
347 P->clrTextBk = pa.backColor;
351 LRESULT m_OnCustomDraw(LPNMLVCUSTOMDRAW P)
353 switch ( P->nmcd.dwDrawStage )
356 m_isReportView = (
GetStyle() & LVS_TYPEMASK) == LVS_REPORT;
357 m_clientWidth = 0x8000;
358 if ( m_isReportView )
362 m_clientWidth = rc.right;
365 return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT;
368 return CDRF_DODEFAULT;
369 case CDDS_ITEMPOSTPAINT:
373 pa.itemNo =
ToDword(P->nmcd.dwItemSpec);
375 pa.state = P->nmcd.uItemState;
376 pa.textColor = P->clrText;
377 pa.backColor = P->clrTextBk;
378 _super::GetItemRect(pa.itemNo, pa.rect, LVIR_BOUNDS);
382 case CDDS_ITEMPREPAINT:
383 if ( ! m_isReportView )
385 return m_OnItemPaintSub(P, 0) | CDRF_NOTIFYPOSTPAINT;
387 return CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
388 case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
389 return m_OnItemPaintSub(P, P->iSubItem);
391 return CDRF_DODEFAULT;
395 int m_countOfSelected;
396 int m_itemOfSelected;
398 int m_eraseBkGndOffset;
DWORD GetStyle(void) const
[取得] ウィンドウスタイル取得.
virtual void OnItemPainted(const TDrawParam *pParam)=0
[通知] アイテム描画終わり.
int GetItemCount() const
[取得] アイテム数取得
int GetTopIndex() const
[取得] 一番上表示のアイテム
int GetCountPerPage() const
[取得] 垂直方向に表示されるアイテム数
UINT GetSelectedCount() const
[取得] 選択アイテム数取得.
POSITION GetFirstSelectedItemPosition() const
[取得] 選択アイテム検索.
int GetNextItem(int nItem, int nFlags) const
[取得] アイテム検索
virtual void OnEndItemPaint(HDC dc)=0
[通知] 描画終了.
BOOL SetItemState(int nItem, UINT nState, UINT nMask)
[設定] アイテム状態設定
void SetEraseBkGndOffset(int f=2)
[設定] BGクリア調整値設定.
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT *_pResult)
[通知] for notifications from parent
CAbstractCustomListCtrl(void)
コンストラクタ
void SetSelectedItem(int item)
[設定] 選択アイテム設定.
virtual void PreSubclassWindow(void)
[通知] subclassing/unsubclassing functions.
virtual void OnSelectItemChanged(int item)
[通知] 選択変更通知.
virtual LRESULT OnItemPainting(TDrawParam *pParam)=0
[通知] アイテム描画.
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
int GetSelectedItem(void) const
[取得] 選択アイテム取得.
int GetNextSelectedItem(POSITION &_pos) const
[取得] 選択アイテム検索.
UINT GetItemState(int nItem, UINT nMask) const
[取得] アイテム状態取得
virtual void OnBeginItemPaint(HDC dc)=0
[通知] 描画開始.
@ LVIS_ACTIVATING
Not currently supported.
@ LVIS_STATEIMAGEMASK
The item's state image index is retrieved by a mask.
@ LVIS_CUT
The item is marked for a cut-and-paste operation.
@ LVIS_FOCUSED
The item has the focus, so it is surrounded by a standard focus rectangle. Although more than one ite...
@ LVIS_SELECTED
The item is selected. The appearance of a selected item depends on whether it has the focus and also ...
@ LVIS_OVERLAYMASK
The item's overlay image index is retrieved by a mask.
@ LVIS_DROPHILITED
The item is highlighted as a drag-and-drop target.
virtual void OnDrawBackground(HDC dc, const RECT &rect)
[通知] 背景描画通知.
DWORD ToDword(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
COLORREF textColor
テキストカラー
DWORD subItemNo
サブアイテムナンバー