const UINT headerID;
const UINT listBoxID;
HFONT hHeaderFontNew;
- UINT_PTR horizonSize;
+ SCROLLINFO hScrollInfo;
+
public:
headerID(NLITE_HEADER_ID),
listBoxID(NLITE_LIST_ID),
t((TBase*)this),
- horizonSize(0)
+ hScrollInfo()
{
-
- LOGFONT lf = {0};
- lf.lfHeight = 10;
- lf.lfCharSet = SHIFTJIS_CHARSET;
+ hScrollInfo.fMask = SIF_ALL;
+ hScrollInfo.cbSize = sizeof(hScrollInfo);
+ LOGFONT lf = {0};
+ lf.lfHeight = 10;
+ lf.lfCharSet = SHIFTJIS_CHARSET;
- hHeaderFontNew = CreateFontIndirect(&lf);
+ hHeaderFontNew = CreateFontIndirect(&lf);
}
}
- DECLARE_WND_CLASS(LISTVIEW_EX)
-
+
+ DECLARE_WND_CLASS_EX(LISTVIEW_EX,0,COLOR_BACKGROUND)
//\83\81\83b\83Z\81[\83W\83}\83b\83v
BEGIN_MSG_MAP(tn)
MSG_WM_CREATE(OnCreate)
MSG_WM_MEASUREITEM(OnMersureItem)
MSG_WM_SIZING(OnSizing)
MSG_WM_SIZE(OnSize)
+ MSG_WM_PAINT(OnPaint)
+ MSG_WM_HSCROLL(OnHScroll)
MSG_WM_ERASEBKGND(OnEraseBkgnd)
COMMAND_CODE_HANDLER_EX(LBN_DBLCLK,OnListBoxDoubleClick)
NOTIFY_CODE_HANDLER_EX(HDN_ITEMCHANGED ,OnheaderItemChanged)
NOTIFY_CODE_HANDLER_EX(HDN_ENDDRAG ,OnHeaderEndDrag)
END_MSG_MAP()
-
+
+ ///
+ ///\94w\8ci\95`\89æ\8f\88\97\9d
+ ///
+ VOID OnPaint(HDC wParam){
+ PAINTSTRUCT paintStruct;
+ HDC paintDC = this->BeginPaint(&paintStruct);
+ HPEN hPen = (HPEN)GetStockPen(NULL_PEN);
+ HPEN oldPen = (HPEN)::SelectObject(paintDC,hPen);
+ HBRUSH brush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
+ HBRUSH oldBrush = (HBRUSH)::SelectObject(paintDC,brush);
+
+ ::Rectangle(paintDC,paintStruct.rcPaint.left,paintStruct.rcPaint.top,paintStruct.rcPaint.right,paintStruct.rcPaint.bottom);
+ this->EndPaint(&paintStruct);
+ ::SelectObject(paintDC,oldBrush);
+ ::SelectObject(paintDC,oldPen);
+
+ return;
+ }
//\83T\83C\83Y\95Ï\8dX\92\86
VOID OnSizing(UINT wParam,LPRECT lParam){
//\83T\83C\83Y\95Ï\8dX\8f\88\97\9d
VOID ChangeSize(const SIZE& client){
-
- header.MoveWindow(0 , 0,client.cx , headerHaight );
- listBox.MoveWindow(0,headerHaight,client.cx,client.cy - headerHaight);
-
-
+ listBox.MoveWindow(0,headerHaight,hScrollInfo.nMax,client.cy - headerHaight);
+ hScrollInfo.nPage = client.cx;
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+ RECT bkRect = {0};
+ bkRect.right = client.cx - hScrollInfo.nMax;
+ bkRect.bottom = client.cy;
+ this->InvalidateRect(&bkRect);
return;
}
if(lParam->hwndFrom == header.m_hWnd){
t->OnHeaderItemChanged();
+
+ INT_PTR itemCount = header.GetItemCount();
+ RECT itemSizeRect;
+ hScrollInfo.nMax = 0;
+ for(INT_PTR imtemIndex = 0;imtemIndex < itemCount;imtemIndex++){
+ header.GetItemRect(imtemIndex,&itemSizeRect);
+ hScrollInfo.nMax += itemSizeRect.right - itemSizeRect.left;
+
+ }
+
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE);
+ DecisionHorzSize();
+
}
return 0;
LRESULT OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl){
-
-
if(wndCtl.m_hWnd == listBox.m_hWnd){
t->OnListBoxDoubleClick();
return 0;
}
+ ///
+ ///\89¡\83X\83N\83\8d\81[\83\8b\8e\9e\82Ì\8f\88\97\9d
+ ///
+ VOID OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+
+
+ INT_PTR dy;
+ switch(loWParam){
+
+ case SB_THUMBTRACK:
+ dy = hiWParam - hScrollInfo.nPos;
+ break;
+
+ default:
+ dy = 0;
+ break;
+
+ }
+ hScrollInfo.nPos += dy;
+ RECT headerPosRect;
+ RECT listBoxPosRect;
+ header.GetWindowRect(&headerPosRect);
+ listBox.GetWindowRect(&listBoxPosRect);
+ INT_PTR moveRange = -(hScrollInfo.nPos);
+ headerPosRect.bottom -= headerPosRect.top;
+ headerPosRect.top = 0;
+ headerPosRect.right += moveRange - headerPosRect.left;
+ headerPosRect.left = moveRange;
+
+ listBoxPosRect.bottom -= (listBoxPosRect.top - headerHaight);
+ listBoxPosRect.top = headerHaight;
+ listBoxPosRect.right += moveRange - listBoxPosRect.left;
+ listBoxPosRect.left = moveRange;
+
+ header.MoveWindow(&headerPosRect);
+ listBox.MoveWindow(&listBoxPosRect);
+
+
+
+
+ HDWP hDwp = BeginDeferWindowPos(2);
+
+ header.DeferWindowPos(hDwp,header.m_hWnd,headerPosRect.left,headerPosRect.top,headerPosRect.right,headerPosRect.bottom,SWP_NOSIZE | SWP_NOZORDER);
+ listBox.DeferWindowPos(hDwp,listBox.m_hWnd,listBoxPosRect.left,listBoxPosRect.top,listBoxPosRect.right,listBoxPosRect.bottom,SWP_NOSIZE | SWP_NOZORDER);
+
+ EndDeferWindowPos(hDwp);
+
+
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+
+
+ return;
+ }
+
LRESULT OnCreate(LPCREATESTRUCT lpcs){
header.Create(m_hWnd,0,WC_HEADER,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | HDS_BUTTONS | HDS_HOTTRACK |HDS_DRAGDROP | HDS_FULLDRAG ,0,headerID);
listBox.Create(m_hWnd,0,WC_LISTBOX,WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY | LBS_NOREDRAW ,0,listBoxID);
}
- UINT_PTR AddHeader(LPHEADERSINFO infos){
+ VOID AddHeader(LPHEADERSINFO infos){
header.SetFont(hHeaderFontNew);
item.mask = HDI_FORMAT | HDI_TEXT | HDI_WIDTH;
item.fmt = HDF_CENTER | HDF_STRING;
+
for(UINT_PTR index = 0;index < infos->count ;++index){
item.pszText = infos->columns[index];
item.cxy = infos->holizensize[index];
- horizonSize += infos->holizensize[index];
+ hScrollInfo.nMax += infos->holizensize[index];
header.InsertItem(index,&item);
}
-
- SCROLLINFO scrollInfo = {0};
- scrollInfo.fMask = SIF_RANGE | SIF_POS;
- scrollInfo.nMax = horizonSize;
-
-
- this->SetScrollInfo(SB_HORZ,&scrollInfo,TRUE);
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE);
+ DecisionHorzSize();
+ return;
+ }
+
+ VOID DecisionHorzSize(){
- return horizonSize;
+
+ HDWP hWindowPosInfo = BeginDeferWindowPos(2);
+ RECT bkWindowRect;
+ this->GetClientRect(&bkWindowRect);
+ header.DeferWindowPos(hWindowPosInfo,header.m_hWnd,0,0,hScrollInfo.nMax,headerHaight,SWP_NOZORDER | SWP_NOMOVE);
+ listBox.DeferWindowPos(hWindowPosInfo,header.m_hWnd,0,0,hScrollInfo.nMax,bkWindowRect.bottom - headerHaight,SWP_NOZORDER | SWP_NOMOVE);
+
+ EndDeferWindowPos(hWindowPosInfo);
+ bkWindowRect.left = hScrollInfo.nMax;
+
+ this->InvalidateRect(&bkWindowRect);
+
+ return;
}
VOID OnMersureItem(UINT wParam, LPMEASUREITEMSTRUCT lParam){