49 , m_textColor(::GetSysColor(COLOR_WINDOWTEXT)), m_backColor(::GetSysColor(COLOR_BTNFACE))
50 , m_hCursor(NULL), m_isWidthVariable(true), m_textStyle(DT_LEFT | DT_VCENTER), m_hasCapture(false)
51 , m_isPartialOk(false)
72 m_isPartialOk = isPartialOk;
92 m_phHeaderDrawer.
Null();
93 if ( pDrawer != NULL )
95 m_phHeaderDrawer = pDrawer->
Clone();
111 m_offset.x = offsetX;
112 m_offset.y = offsetY;
113 if ( pBkDrawer != NULL )
115 m_phBkDrawer = pBkDrawer->
Clone();
117 if ( ::IsWindow(_super::GetSafeHwnd()) )
119 _super::Invalidate(FALSE);
133 if ( m_pBuddyCtrl == NULL )
135 if ( pCtrl != NULL && ::IsWindow(pCtrl->
GetSafeHwnd()) )
140 pCtrl->
ModifyStyleEx(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, 0);
141 SetWindowPos(pCtrl, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
142 bool isVisible = (
GetStyle() & WS_VISIBLE) != 0;
144 SetFont(pCtrl->GetFont());
146 m_headerWidth = down_cast<int>(headerWidth);
147 m_isWidthVariable = isWidthVariable;
148 m_pBuddyCtrl = pCtrl;
164 m_headerWidth = down_cast<int>(headerWidth);
165 m_isWidthVariable = isWidthVariable;
175 return m_headerWidth;
185 if ( m_pBuddyCtrl != NULL )
203 m_params[item].phDraw = draw.
Clone();
221 m_params[item].phDraw.Null();
222 m_params[item].text = lpszText;
239 if ( m_pBuddyCtrl != NULL )
241 int r = m_pBuddyCtrl->
InsertItem(item, _T(
""));
280 if ( m_pBuddyCtrl != NULL )
284 if ( rc.PtInRect(pt) )
286 CHeaderCtrl* pHead = m_pBuddyCtrl->GetHeaderCtrl();
289 pHead->GetWindowRect(rc);
290 if ( pt.y >= rc.Height() )
292 r = m_pBuddyCtrl->HitTest(CPoint(0, pt.y));
316 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
320 case CMyHooker::WM_RHC_HOOKMESSAGE:
338 m_Draw(CPaintDC(
this));
341 if ( m_isWidthVariable )
344 if ( m_IsDragSpace(pos) )
346 ::SetCursor(::LoadCursor(NULL, IDC_SIZEWE));
349 m_captureStartPos = CPoint(lParam);
350 m_captureStartHeaderWidth = m_headerWidth;
358 m_hasCapture =
false;
365 m_hasCapture =
false;
366 m_headerWidth = m_captureStartHeaderWidth;
371 if ( m_isWidthVariable )
373 if ( m_hCursor == NULL )
375 m_hCursor = ::GetCursor();
380 ::SetCursor(::LoadCursor(NULL, IDC_SIZEWE));
381 int x = m_captureStartHeaderWidth + pos.x - m_captureStartPos.x;
384 int l = rc.Width() - 5;
395 if ( m_pBuddyCtrl != NULL )
397 m_pBuddyCtrl->GetHeaderCtrl()->RedrawWindow();
400 else if ( m_IsDragSpace(pos) )
402 ::SetCursor(::LoadCursor(NULL, IDC_SIZEWE));
406 ::SetCursor(m_hCursor);
411 return _super::WindowProc(message, wParam, lParam);
423 _super::ModifyStyle(0, SS_NOTIFY);
424 _super::PreSubclassWindow();
429 void m_RewidthHeader(
void)
431 if ( m_pBuddyCtrl != NULL )
436 GetParent()->ScreenToClient(rc);
437 rc.left += m_headerWidth;
438 m_pBuddyCtrl->
SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER);
442 bool m_IsDragSpace(
const POINT& pos)
const
444 if ( m_pBuddyCtrl != NULL )
447 CHeaderCtrl* pHead = m_pBuddyCtrl->GetHeaderCtrl();
448 pHead->GetClientRect(headerRect);
449 if ( pos.x >= m_headerWidth - 5 && pos.x <= m_headerWidth )
451 if ( pos.y < headerRect.Height() )
461 void m_BkDraw(HDC hdc,
const CRect& rect)
463 if ( m_phBkDrawer != NULL )
465 m_phBkDrawer->
Resize(rect.Size());
466 m_phBkDrawer->
Draw(hdc, rect.left, rect.top);
471 r.top = r.bottom - 1;
472 ::InvertRect(hdc, r);
474 r.left = r.right - 1;
475 ::InvertRect(hdc, r);
482 GetClientRect(clientRect);
484 bi.
Set(m_headerWidth, clientRect.Height(), m_backColor);
485 if ( m_pBuddyCtrl != NULL )
489 dsa.SetBkMode(TRANSPARENT);
490 dsa.SelectFont(GetFont());
491 dsa.SetTextColor(m_textColor);
495 CHeaderCtrl* pHead = m_pBuddyCtrl->GetHeaderCtrl();
496 pHead->GetClientRect(headerRect);
497 CRect r = headerRect;
499 r.right = m_headerWidth;
501 if ( ! m_phHeaderDrawer.
IsNull() )
503 m_phHeaderDrawer->
Resize(r.Size());
504 m_phHeaderDrawer->
Draw(dc, r.left, r.top);
508 int cpp = m_pBuddyCtrl->GetCountPerPage();
509 int si = m_pBuddyCtrl->GetTopIndex();
510 loop ( i, cpp + (m_isPartialOk ? 1 : 0) )
517 m_pBuddyCtrl->GetItemRect(si, rc, LVIR_BOUNDS);
519 rc.right = m_headerWidth;
521 rc.left += m_offset.x;
522 rc.top += m_offset.y;
523 HRGN hRgn = ::CreateRectRgnIndirect(&rc);
524 ::SelectClipRgn(dc, hRgn);
527 TParam& prm = m_params[si];
528 if ( prm.phDraw.IsNull() )
530 ::DrawText(dc, prm.text, -1, rc, m_textStyle);
534 prm.phDraw->Resize(rc.Size());
535 prm.phDraw->Draw(dc, rc.left, rc.top);
538 ::SelectClipRgn(dc, NULL);
546 void m_BuddyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT lResult)
557 rc.right = m_headerWidth;
558 InvalidateRect(rc, FALSE);
562 _super::ShowWindow((wParam != FALSE) ? SW_SHOW : SW_HIDE);
567 m_params.
Insert(lResult, TParam());
576 case LVM_DELETEALLITEMS:
594 WM_RHC_HOOKMESSAGE = WM_APP,
616 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
627 case LVM_DELETEALLITEMS:
629 LRESULT r = _super::WindowProc(message, wParam, lParam);
635 ::SendMessage(m_hParent, WM_RHC_HOOKMESSAGE, NULL,
reinterpret_cast<LPARAM
>(&msg));
642 return _super::WindowProc(message, wParam, lParam);
655 COLORREF m_textColor;
658 COLORREF m_backColor;
659 CMyHooker m_myHooker;
664 bool m_isWidthVariable;
667 CPoint m_captureStartPos;
668 int m_captureStartHeaderWidth;
#define loop(VAR, CNT)
loop構文.
int GetItemCount(void) const
[取得] アイテム数取得.
int InsertItem(int nItem, LPCTSTR lpszItem)
[設定] アイテム挿入.
DWORD GetStyle(void) const
[取得] ウィンドウスタイル取得.
BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
[設定] ウィンドウスタイル変更.
BOOL SetWindowPos(const CWnd *pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
[設定] ウィンドウサイズポジション設定.
BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
[設定] ウィンドウ拡張スタイル変更.
BOOL ShowWindow(int nCmdShow)
[設定] ウィンドウ表示状態.
HWND GetSafeHwnd(void) const
[取得] ウィンドウハンドル取得.
bool Set(int cx, int cy, COLORREF color=CLR_INVALID)
[設定] イメージ設定.
bool Draw(HDC hdc, int x=0, int y=0) const
[処理] イメージ描画.
bool IsNull(void) const
[確認] NULLチェック
virtual size_t GetSize(void) const
[取得] サイズ取得
virtual bool Insert(INDEX index, const TYP &t)
[追加] 要素一つ挿入
virtual bool Remove(INDEX index)
[削除] 要素一つ削除.
virtual bool SetSize(size_t size)
[操作] サイズ指定
virtual bool RemoveAll(void)
[削除] 空化
int ToInt(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
bool IsInRange(INDEX index) const
[確認] INDEXの有効確認.
virtual bool Resize(const SIZE &size)=0
[設定] サイズ設定.
virtual IDrawable * Clone(void) const =0
[作成] クローン作成.
virtual void Draw(HDC dc, int x=0, int y=0) const =0
[描画] 描画.