OSDN Git Service

2012/01/24 16:53:14
[nlite/nlite.git] / nlite / nlite_commentview.cpp
index 1be0df7..fc6e2f0 100644 (file)
@@ -2,17 +2,26 @@
 #include "nlite_include.h"
 
 
-
-
-//
-//\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
-///////////////////////////////////////////////////////
-
-CCommentView::CCommentView():
-               hScrollInfo()
+namespace nlite{
+
+       //\90F\92è\90\94
+       namespace ColorList{
+               enum type{
+                       selectBack = RGB(255,240,240),
+                       outLineSelect = RGB(255,0,0),
+                       outLineNomal = RGB(0,0,0),
+                       colLine = RGB(224,224,224)
+               };
+       };
+
+       //
+       //\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
+       ///////////////////////////////////////////////////////
+
+       CCommentView::CCommentView():
+       m_commentListWindow(*this)
        {
-               hScrollInfo.fMask = SIF_ALL;
-               hScrollInfo.cbSize = sizeof(hScrollInfo);
+
                LOGFONT lf = {0};
                lf.lfHeight = 10;
                lf.lfCharSet = SHIFTJIS_CHARSET;
@@ -20,673 +29,981 @@ CCommentView::CCommentView():
 
                hHeaderFontNew = CreateFontIndirect(&lf);
 
-               colLinePen.CreatePen(PS_SOLID,1,RGB(224,224,224));
-               outLinePenNomal.CreatePen(PS_SOLID,1,RGB(127,127,127));
-               outLinePenSelect.CreatePen(PS_SOLID,1,RGB(255,0,0));
-               bkBurushSelect.CreateSolidBrush(RGB(255,240,240));
+
                return;
 
-}
+       }
+
+       CCommentView::~CCommentView(){
+
 
-CCommentView::~CCommentView(){
+               DeleteObject(hHeaderFontNew);
 
-       colLinePen.DeleteObject();
-       outLinePenNomal.DeleteObject();
-       outLinePenSelect.DeleteObject();
-       bkBurushSelect.DeleteObject();
-       DeleteObject(hHeaderFontNew);
+               return;
+       }
 
-       return;
-}
 
 
 
-VOID CCommentView::Lock(){
-       ccs.Lock();
-}
+       VOID CCommentView::OnConnect(){
+               m_commentListWindow.SetRedraw(FALSE);
+               commentlist.OnConnect();
 
-VOID CCommentView::Unlock(){
-       ccs.Unlock();
-}
+               SCROLLINFO vScrollInfo = {0};
+               vScrollInfo.cbSize = sizeof(vScrollInfo);
+               vScrollInfo.fMask = SIF_ALL;
 
+               this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
 
-VOID CCommentView::OnConnect(){
-       commentlist.OnConnect();
-       m_listBox.SetRedraw(FALSE);
-       m_listBox.ResetContent();
-}
+               m_commentListWindow.SetRedraw(TRUE);
 
 
-UINT_PTR CCommentView::GetColumnHolSizeSum(){
+       }
 
-       return hScrollInfo.nMax;
-}
 
-VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
+       UINT_PTR CCommentView::GetColumnHolSizeSum(){
 
-       viewproperty = setProperty;
+               INT_PTR nMin = 0;
+               INT_PTR nMax = 0;
+               this->GetScrollRange(SB_HORZ,&nMin,&nMax);
 
-       if(bkBurushNomal.IsNull() == FALSE){
-               bkBurushNomal.DeleteObject();
+               return nMax;
        }
-       bkBurushNomal.CreateSolidBrush(viewproperty.backColor);
-       return;
-}
 
-CommentViewProperty &CCommentView::GetProperty(){
+       VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
 
-       return viewproperty;
+               viewproperty = setProperty;
+               return;
+       }
 
-}
+       CommentViewProperty &CCommentView::GetProperty(){
 
-VOID CCommentView::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lpMersureItemStruct){
+               return viewproperty;
 
-       if(lpMersureItemStruct->CtlID == commentViewConstant::LISTBOX_ID){
+       }
 
-               auto &chat = *(CChatData*)lpMersureItemStruct->itemData;
 
-               CDC cdc = m_listBox.GetDC();
-       
-               RECT drowSize;
-               m_header.GetItemRect(COMMENT,&drowSize);
-               drowSize.left += 2;
-               drowSize.top +=  2;
-               drowSize.right -= 2;
-               drowSize.bottom = 0;
-       
-               SelectObject(cdc,AtlGetDefaultGuiFont());
 
-       
-               cdc.DrawTextW(chat.chatBuf.c_str(),chat.chatBuf.length(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
-       
-               drowSize.top -= 2;
-               drowSize.bottom += 2;
 
-               lpMersureItemStruct->itemHeight = drowSize.bottom - drowSize.top;
 
-       }
-       
+       HWND CCommentView::Create(HWND hWndParent){
 
-       return;
-}
 
 
+               HWND rslt = __super::Create(hWndParent,0,commentViewConstant::NLITE_COMMENTVIEW,WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER,0,commentViewConstant::MENU_OR_ID);
 
-HWND CCommentView::Create(HWND hWndParent){
+               PAINTSTRUCT ps;
+               HDC hdc = m_header.BeginPaint(&ps);
+               SIZE size;
 
-       
+               HFONT hOld = (HFONT)SelectObject(hdc,hHeaderFontNew);
 
-       HWND rslt = __super::Create(hWndParent,0,commentViewConstant::NLITE_COMMENTVIEW,WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_BORDER,0,commentViewConstant::MENU_OR_ID);
+               LPTSTR columns[] = {TEXT("\83R\83\81\94Ô"),TEXT("\83\86\81[\83U\81[\96¼"),TEXT("\83R\83\81\83\93\83g"),TEXT("\8e\9e\8aÔ"),TEXT("\8fî\95ñ")};
+               UINT_PTR holizenSize[] = {0,0,100,0,0};
 
-       PAINTSTRUCT ps;
-       HDC hdc = m_header.BeginPaint(&ps);
-       SIZE size;
+               for(UINT_PTR index = 0;index < ARRAY_LENGTH(columns) ;++index){
 
-       HFONT hOld = (HFONT)SelectObject(hdc,hHeaderFontNew);
+                       GetTextExtentPoint32(hdc , columns[index] , _tcslen(columns[index]) , &size);
+                       UINT_PTR holsize = holizenSize[index] + size.cx + 15;
+                       holizenSize[index] = viewproperty.headerholSize[index] >= 0 ? viewproperty.headerholSize[index] : holsize;
+               }
 
-       LPTSTR columns[] = {TEXT("\83R\83\81\94Ô"),TEXT("\83\86\81[\83U\81[\96¼"),TEXT("\83R\83\81\83\93\83g"),TEXT("\8e\9e\8aÔ"),TEXT("\8fî\95ñ")};
-       UINT_PTR holizenSize[] = {0,0,100,0,0};
+               SelectObject(hdc,hOld);
 
-       for(UINT_PTR index = 0;index < ARRAY_LENGTH(columns) ;++index){
+               m_header.EndPaint(&ps);
 
-               GetTextExtentPoint32(hdc , columns[index] , _tcslen(columns[index]) , &size);
-               UINT_PTR holsize = holizenSize[index] + size.cx + 15;
-               holizenSize[index] = viewproperty.headerholSize[index] >= 0 ? viewproperty.headerholSize[index] : holsize;
+
+               HEADERSINFO headersinfo = {columns,holizenSize,ARRAY_LENGTH(columns)};
+
+               AddHeader(&headersinfo);
+
+               m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+
+
+
+
+               return rslt;
        }
 
-       SelectObject(hdc,hOld);
 
-       m_header.EndPaint(&ps);
-                       
-                       
-       HEADERSINFO headersinfo = {columns,holizenSize,ARRAY_LENGTH(columns)};
 
-       AddHeader(&headersinfo);
 
-       m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
-               
-                       
-       
-                       
-       return rslt;
-}
+       LRESULT CCommentView::OnHeaderEndTrack(LPNMHDR lParam){
+
+
+               if(lParam->hwndFrom == m_header.m_hWnd){
+
+
+                       m_commentListWindow.SetRedraw(FALSE);
+                       SCROLLINFO vScrollInfo = {0};
+                       vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
+
+                       this->GetScrollInfo(SB_VERT,&vScrollInfo);
+                       vScrollInfo.nPage = m_commentListWindow.CalcScrollPage(vScrollInfo.nMax);
+                       vScrollInfo.fMask = SIF_PAGE;
+                       this->SetScrollInfo(SB_VERT,&vScrollInfo);
 
+                       BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage + 1>= vScrollInfo.nMax;
+                       UINT_PTR commentCount = commentlist.Size();
+                       LPNMHEADER  lpNmHdr = (LPNMHEADER )lParam;
 
+                       m_header.SetItem(lpNmHdr->iItem,lpNmHdr->pitem);
 
 
-LRESULT CCommentView::OnheaderItemChanged(LPNMHDR lParam){
 
-       
-       if(lParam->hwndFrom == m_header.m_hWnd){
 
-               INT_PTR curSel = m_listBox.GetCurSel();
 
-               SCROLLINFO scrollInfo = {0};
-               scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-               m_listBox.GetScrollInfo(SB_VERT,&scrollInfo);
-               scrollInfo.nPos++;
-               BOOL scrollFlag = scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax;
-               UINT_PTR commentCount = commentlist.Size();
 
-       
-               m_listBox.SetRedraw(FALSE);
-               m_listBox.ResetContent();
-               for(UINT_PTR index =0;index < commentCount;index++){
-                       m_listBox.AddString((LPCTSTR)&commentlist.GetChatAt(index));
+
+                       if(scrollFlag == TRUE){
+
+                               this->SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+                       }
+
+                       INT_PTR itemCount = m_header.GetItemCount();
+                       RECT itemSizeRect;
+
+                       INT_PTR nMax = 0;
+                       for(INT_PTR itemIndex = 0;itemIndex < itemCount;itemIndex++){
+                               m_header.GetItemRect(itemIndex,&itemSizeRect);
+                               nMax += itemSizeRect.right - itemSizeRect.left;
+
+                       }
+                       INT_PTR nMin = 0;
+                       this->SetScrollRange(SB_HORZ,nMin,nMax,TRUE);
+                       DecisionHorzSize();
+
+
+                       auto begin = commentlist.begin();
+
+                       auto end = commentlist.end();
+
+                       /*
+                       for(;begin != end;++begin){
+
+                       begin->height = m_commentListWindow.CalcItemHeight(*begin);
+                       }
+                       */
+                       m_commentListWindow.SetRedraw(TRUE);
+                       if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+                               m_commentListWindow.Invalidate();
+                               m_commentListWindow.Unlock();
+                       }
+
                }
-       
 
-       
+               return 0;
+       }
+
+       VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
+
+               commentlist.OnChatReceve(chat,commnetCountSum,this->m_commentListWindow);
 
-               m_listBox.SetCurSel(curSel);
+               return;
+       }
 
-       
 
-               m_listBox.SetRedraw(TRUE);
-               m_listBox.Invalidate();
-       
+       VOID CCommentView::SetStreamStatus(StreamStatus_P st){
+
+               streamStatus.SetStreamStatus(st);
+       }
+
+       VOID CCommentView::OnChatReceveSettle(UINT_PTR chatNo,UINT_PTR commentCountSum){
+
+
+               SCROLLINFO vScrollInfo = {0};
+
+               //vScrollCcs.Lock();
+
+               vScrollInfo.fMask = SIF_ALL;
+
+               this->GetScrollInfo(SB_VERT,&vScrollInfo);
+               BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
+
+
+
+               //      vScrollInfo.fMask = SIF_RANGE;
+               vScrollInfo.cbSize = sizeof(vScrollInfo);
+
+               vScrollInfo.nMax = commentCountSum;
+               //      this->SetScrollRange(SB_VERT,vScrollInfo.nMin,vScrollInfo.nMax,FALSE);
+               //      this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+               vScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
+               vScrollInfo.nPage = m_commentListWindow.CalcScrollPage(vScrollInfo.nMax);
+
+
+               this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+
 
-               if(scrollFlag == TRUE){
 
-                       m_listBox.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
+
+               if(scrollFlag == TRUE){
+                       this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
                }
 
-               INT_PTR itemCount = m_header.GetItemCount();
-               RECT itemSizeRect;
-               hScrollInfo.nMax = 0;
-               for(INT_PTR imtemIndex = 0;imtemIndex < itemCount;imtemIndex++){
-                       m_header.GetItemRect(imtemIndex,&itemSizeRect);
-                       hScrollInfo.nMax += itemSizeRect.right - itemSizeRect.left;
 
+               if(vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) >= vScrollInfo.nMax - static_cast<INT_PTR>(vScrollInfo.nPage)&& TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+                       m_commentListWindow.Invalidate();
+                       m_commentListWindow.Unlock();
                }
 
-               this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE);
-               DecisionHorzSize();
-                               
+
+               //this->SetScrollInfo(SB_VERT,NULL);
+
+               return;
        }
 
-       return 0;
-}
+       static UCHAR getrgb(){
+
+               UCHAR rgb = 160 + rand() % 92;
+               return rgb;
+       }
+
+
+
+
 
-VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
-       
 
-       
-       Lock();
-       m_listBox.SetRedraw(FALSE);
-       commentlist.OnChatReceve(chat,count);
-       m_listBox.AddString((LPCTSTR)&commentlist.back());
 
-       SCROLLINFO scrollInfo = {0};
-       scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-       m_listBox.GetScrollInfo(SB_VERT,&scrollInfo);
-       scrollInfo.nPos++;
-       
-       
-       if(scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax == TRUE){
-               m_listBox.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);     
+
+
+
+
+       LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
+               ChangeSize(lParam);
+
+               return 0;
        }
-       Unlock();
-}
 
 
-VOID CCommentView::SetStreamStatus(StreamStatus &st){
-       
-       streamStatus.SetStreamStatus(st);
-}
+       VOID CCommentView::ChangeSize(const SIZE& client){
 
-VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
+               SCROLLINFO hScrollInfo = {0};
+               hScrollInfo.cbSize = sizeof(hScrollInfo);
+               hScrollInfo.fMask = SIF_PAGE;
+               hScrollInfo.nPage = client.cx;
 
-       m_listBox.SetRedraw(TRUE);
-       
+               this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+               hScrollInfo.fMask = SIF_ALL;
+               this->GetScrollInfo(SB_HORZ,&hScrollInfo);
 
-       return;
-}
 
-static UCHAR getrgb(){
+               HDWP hDwp = BeginDeferWindowPos(2);
 
-       UCHAR rgb = 160 + rand() % 92;
-       return rgb;
-}
 
-LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl){
-       
+               INT_PTR movePos =  -1 * hScrollInfo.nPos;
 
+               m_header.DeferWindowPos(hDwp,m_header.m_hWnd,movePos,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
+               m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,::GetSystemMetrics(SM_CXFULLSCREEN),client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);         
 
-       if(wndCtl.m_hWnd == m_listBox.m_hWnd){
+               EndDeferWindowPos(hDwp);
 
-               INT_PTR cursel = m_listBox.GetCurSel();
-               if(cursel == LB_ERR)return 0;
-       
-               auto chatData = commentlist.GetChatAt(cursel);
-               COLORREF bkColor;
-               if(chatData.listenerData->originBkFlag == FALSE){
-                       CListenerColorCollector colorCollector;
-                       listenerList.BkColorCollect(colorCollector);
-                       UCHAR red;
-                       UCHAR green;
-                       UCHAR blue;
-               
-                       srand((unsigned int)time(NULL));
-                       do{
 
-                               red = getrgb();
-                               green = getrgb();
-                               blue = getrgb();
-                               bkColor = RGB(red,green,blue);
+               RECT bkRect;
+               RECT headerRectSize;
+               m_header.GetWindowRect(&headerRectSize);
+               bkRect.left = headerRectSize.right - headerRectSize.left - hScrollInfo.nPos;
+               bkRect.top = 0;
+               bkRect.right = client.cx ;
+               bkRect.bottom = client.cy;
 
-                       }while(colorCollector.Find(bkColor));
 
-                       chatData.listenerData->originBkFlag = TRUE;
+               return;
+       }
 
-               } else {
 
-                       bkColor = viewproperty.backColor;
-                       chatData.listenerData->originBkFlag = FALSE;
+       LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
+
+               return TRUE;
+       }
+
+
+       VOID CCommentView::OnDestroy(){
+               m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+               INT_PTR headerItemcount = m_header.GetItemCount();
+               RECT headerItemRect;
+               for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
+
+                       m_header.GetItemRect(itemindex,&headerItemRect);
+                       viewproperty.headerholSize[itemindex] = headerItemRect.right - headerItemRect.left;
                }
+               commentlist.OnDestroy();
+               m_header.DestroyWindow();
+               m_commentListWindow.DestroyWindow();
+               return;
+
+       }
+
+       LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
+
+               if(lParam->hwndFrom == m_header.m_hWnd){
+                       if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
 
-       
-       
+                               m_commentListWindow.Invalidate();
+                               m_commentListWindow.Unlock();
+                       }
 
-               chatData.listenerData->SetBkColor(bkColor);
+               }
 
-               m_listBox.Invalidate(TRUE);
+               return 0;
        }
 
-       return 0;
-}
 
-VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
+       VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
-       if((lpDrawItemStruct->hwndItem  == m_listBox.m_hWnd) && ((UINT)m_listBox.GetCount() > lpDrawItemStruct->itemID)){
-                                       
-               RECT noViewRect;
-               RECT userNameViewRect;
-               RECT timeViewRect;
-               RECT chatViewRect;
-               RECT infoViewRect;
 
-       
+               INT_PTR dy;
+               SCROLLINFO hScrollInfo = {0};
+               hScrollInfo.cbSize = sizeof(hScrollInfo);
+               hScrollInfo.fMask = SIF_ALL;
+               this->GetScrollInfo(SB_HORZ,&hScrollInfo);
+               switch(loWParam){
+
+               case SB_THUMBPOSITION:
+               case SB_THUMBTRACK:
+                       dy = hiWParam - hScrollInfo.nPos;
+                       break;
 
-               CChatData &chatData = *(CChatData*)lpDrawItemStruct->itemData;
+               case SB_LINELEFT:
+               case SB_PAGELEFT:
 
-       
+                       dy = -1 * hScrollInfo.nPage;
 
-               time_t chatTime = (time_t)difftime(chatData.date,streamStatus.start_time);
-               tm ct = *gmtime(&chatTime);
-               
-               
-               TCHAR noString[sizeof(chatData.no) * 8]; 
-               TCHAR dateString[LENGTH_16];
-               _stprintf(noString,TEXT("%u"),chatData.no);
+                       break;
 
-               _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
+               case SB_LINERIGHT:
+               case SB_PAGERIGHT:
 
-       
-       
-               //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
-               if ((lpDrawItemStruct->itemState) & (ODS_SELECTED))
-               {
+                       dy = hScrollInfo.nPage + hScrollInfo.nPos > (UINT_PTR)hScrollInfo.nMax ? 0 :(UINT_PTR) (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) < hScrollInfo.nPage ? (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) : hScrollInfo.nPage;
+
+                       break;
+
+               default:
+                       dy = 0;
+                       break;
 
-                       SelectObject(lpDrawItemStruct->hDC,bkBurushSelect);
-                       SelectObject(lpDrawItemStruct->hDC,outLinePenSelect);   
-                       SetBkColor(lpDrawItemStruct->hDC,RGB(255,240,240)) ;
                }
-               else  
-               {
-                       SelectObject(lpDrawItemStruct->hDC,outLinePenNomal);
 
-                       if(chatData.listenerData->originBkFlag == TRUE){
-                       
-                               SelectObject(lpDrawItemStruct->hDC,chatData.listenerData->baseBkBrush);
-                               SetBkColor(lpDrawItemStruct->hDC,chatData.listenerData->bkColor) ;
+               dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
 
-                       } else {
 
-                               SelectObject(lpDrawItemStruct->hDC,bkBurushNomal);
-                               SetBkColor(lpDrawItemStruct->hDC,viewproperty.backColor) ;
-                       
+               if(dy != 0){
+                       hScrollInfo.nPos += dy;
+                       INT_PTR moveRange = -(hScrollInfo.nPos);
+
+                       HDWP hDwp = BeginDeferWindowPos(2);
+
+                       m_header.DeferWindowPos(hDwp,m_header.m_hWnd,moveRange,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
+                       m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,moveRange,commentViewConstant::HEADER_HAIGHT,0,0,SWP_NOSIZE | SWP_NOZORDER);         
+
+                       EndDeferWindowPos(hDwp);
+
+
+                       this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+               }
+
+               return;
+       }
+
+
+       VOID CCommentView::OnVScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+
+               INT_PTR dy;
+               SCROLLINFO vScrollInfo = {0};
+               vScrollInfo.fMask = SIF_ALL;
+
+
+               this->GetScrollInfo(SB_VERT,&vScrollInfo);
+
+               switch(loWParam){
+
+
+               case SB_THUMBPOSITION:
+               case SB_THUMBTRACK:
+
+                       dy = hiWParam - vScrollInfo.nPos;
+
+                       break;
+
+               case SB_LINEUP:
+
+                       dy = -1;
+                       break;
+
+               case SB_LINEDOWN:
+
+                       dy = 1;
+
+                       break;
+
+               case SB_PAGEUP:
+
+                       dy = -1 * vScrollInfo.nPage;
+
+                       break;
+
+               case SB_PAGEDOWN:
+
+                       dy = vScrollInfo.nPage;
+
+                       break;
+
+
+               case SB_TOP:
+
+                       dy = -vScrollInfo.nPos;
+
+                       break;
+
+               case SB_BOTTOM:
+
+                       dy = vScrollInfo.nMax;
+
+                       break;
+
+               default:
+
+                       dy = 0;
+
+                       break;
+
+               }
+
+
+
+
+               if(dy != 0){
+
+                       vScrollInfo.nPos += dy;
+                       //              viewStartHeight = vScrollInfo.nPos;
+                       this->SetScrollPos(SB_VERT,vScrollInfo.nPos);
+                       //this->SetScrollInfo(SB_VERT,&vScrollInfo);
+                       this->UpdateWindow();
+                       if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+                               m_commentListWindow.Invalidate();
+                               m_commentListWindow.Unlock();
                        }
                }
-               
-       
-               //\83e\83L\83X\83g\82Ì\83J\83\89\81[\82ð\90Ý\92è
-               SetTextColor(lpDrawItemStruct->hDC,viewproperty.baseStringColor);
 
-       
-       
-               Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom);
 
 
+               return;
+       }
 
+       LRESULT CCommentView::OnCreate(LPCREATESTRUCT lpcs){
+               m_header.Create(m_hWnd,0,WC_HEADER,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN   | HDS_BUTTONS | HDS_HOTTRACK |HDS_DRAGDROP | HDS_FULLDRAG  ,0,commentViewConstant::HEADER_ID);
+               m_commentListWindow.Create(m_hWnd,0,commentViewConstant::NLITE_COMMENTLISTWINDOW,WS_CHILD | WS_VISIBLE  | WS_CLIPCHILDREN  , 0,commentViewConstant::LISTWINDOW);
 
 
 
 
-               //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
+               return 0;
+       }
 
-               m_header.GetItemRect(NO,&noViewRect);
-               m_header.GetItemRect(USERNAME,&userNameViewRect);
-               m_header.GetItemRect(COMMENT,&chatViewRect);
-               m_header.GetItemRect(TIME,&timeViewRect);
-               m_header.GetItemRect(INFO,&infoViewRect);
-
-               SelectObject(lpDrawItemStruct->hDC,colLinePen);
-       
-               MoveToEx(lpDrawItemStruct->hDC,noViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
-               LineTo(lpDrawItemStruct->hDC,noViewRect.right,lpDrawItemStruct->rcItem.bottom);
-               MoveToEx(lpDrawItemStruct->hDC,userNameViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
-               LineTo(lpDrawItemStruct->hDC,userNameViewRect.right,lpDrawItemStruct->rcItem.bottom);
-               MoveToEx(lpDrawItemStruct->hDC,chatViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
-               LineTo(lpDrawItemStruct->hDC,chatViewRect.right,lpDrawItemStruct->rcItem.bottom);
-               MoveToEx(lpDrawItemStruct->hDC,timeViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
-               LineTo(lpDrawItemStruct->hDC,timeViewRect.right,lpDrawItemStruct->rcItem.bottom);
-               MoveToEx(lpDrawItemStruct->hDC,infoViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
-               LineTo(lpDrawItemStruct->hDC,infoViewRect.right,lpDrawItemStruct->rcItem.bottom);
+       VOID CCommentView::AddHeader(LPHEADERSINFO infos){
 
-               noViewRect.left += 2;
-               userNameViewRect.left += 2;
-               timeViewRect.left += 2;
-               chatViewRect.left += 2;
-               infoViewRect.left += 2;
 
-               noViewRect.right += 2;
-               userNameViewRect.right += 2;
-               timeViewRect.right += 2;
-               chatViewRect.right += 2;
-               infoViewRect.right += 2;
+               m_header.SetFont(hHeaderFontNew);
+
+               HDITEM item;
+               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];
+                       m_header.AddItem(&item);
+               }
+
+               RECT itemRect;
+               INT_PTR nMax = 0;
+               UINT_PTR itemCount = m_header.GetItemCount();
+               for(UINT_PTR u_index = 0;u_index < itemCount;++u_index){
+
+                       m_header.GetItemRect(u_index,&itemRect);
+                       nMax += itemRect.right - itemRect.left;
+
+               }
+
+               this->SetScrollRange(SB_HORZ,0,nMax,TRUE);
+
+               DecisionHorzSize();
+               return;
+       }
+
+       VOID CCommentView::DecisionHorzSize(){
 
-               noViewRect.top = lpDrawItemStruct->rcItem.top + 2;
-               userNameViewRect.top = lpDrawItemStruct->rcItem.top + 2;
-               timeViewRect.top = lpDrawItemStruct->rcItem.top + 2;
-               chatViewRect.top = lpDrawItemStruct->rcItem.top + 2;
-               infoViewRect.top = lpDrawItemStruct->rcItem.top + 2;
+               HDWP hWindowPosInfo = BeginDeferWindowPos(2);
+               RECT bkWindowRect;
+               this->GetClientRect(&bkWindowRect);
+               m_header.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
+               m_commentListWindow.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
 
-               noViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
-               userNameViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
-               timeViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
-               chatViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
-               infoViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
+               EndDeferWindowPos(hWindowPosInfo);
 
+               return;
+       }
 
 
-       
 
-               ::DrawText(lpDrawItemStruct->hDC,noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
 
-               ::DrawText(lpDrawItemStruct->hDC,chatData.listenerData->user_id.c_str(),chatData.listenerData->user_id.length(),&userNameViewRect,DT_WORD_ELLIPSIS);
+       //
+       //\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\93à\95\94\83\8a\83X\83g\83N\83\89\83X
+       ////////////////////////////////////////////////////////////////////
 
-               ::DrawText(lpDrawItemStruct->hDC,chatData.chatBuf.c_str(),chatData.chatBuf.length(),&chatViewRect,DT_WORDBREAK);
+       CCommentListWindow::CCommentListWindow(CCommentView &in_self):
+       self(in_self)
+       {}
 
-               ::DrawText(lpDrawItemStruct->hDC,dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
-                                       
+       CCommentListWindow::~CCommentListWindow(){
        }
 
-       return;
-}
 
+       VOID CCommentListWindow::OnPaint(HDC in_hdc){
+
+
+
+               RECT windowRect;
+               RECT listRect = {0};
+               RECT clientRect;
+
+               self.GetClientRect(&clientRect);
+               clientRect.bottom -= commentViewConstant::HEADER_HAIGHT;
+
+               this->GetWindowRect(&windowRect);
+               windowRect.right -= windowRect.left;
+               windowRect.bottom -= windowRect.top;
+               windowRect.left = 0;
+               windowRect.top = 0;
+
+
+               CPaintDC pdc(*this);
+
+               {
+                       CMemoryDC mdc(pdc,windowRect);
+                       mdc.SelectFont(AtlGetDefaultGuiFont());
+
+
+                       CCommentList &commentList = self.commentlist;
+
+                       BOOL selectFlag = FALSE;
+                       CCommentList::iterator selectData;
+                       RECT selectRect = {0};
+                       UINT_PTR viewStartHeight = self.GetScrollPos(SB_VERT);
+
+
+                       if(commentList.Size() > (UINT_PTR)viewStartHeight){
+
+                               listRect = windowRect;
+                               listRect.right = self.GetColumnHolSizeSum();            
+
+                               CCommentList::iterator chatData = commentList.begin();
+                               std::advance(chatData,viewStartHeight);
+
+
+
+                               CBrush baseBkBrush;
+                               baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+                               mdc.FillRect(&listRect,baseBkBrush);
+                               baseBkBrush.DeleteObject();
+                               CCommentList::iterator endData = commentList.end();
+                               listRect.bottom = 0;
+
+                               CPen outLinePen;
+                               outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
+                               mdc.SelectPen(outLinePen);
+                               mdc.MoveTo(listRect.right,listRect.top);
+                               mdc.LineTo(listRect.right,listRect.bottom);
+
+
+                               for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
+                                       listRect.bottom +=      CalcItemHeight(*chatData);
 
 
-VOID CCommentView::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);
+                                       if(chatData->selectFlag == TRUE){
+                                               selectFlag = TRUE;
+                                               selectData = chatData;
+                                               selectRect = listRect;
+                                       } else {
 
-       ::Rectangle(paintDC,paintStruct.rcPaint.left,paintStruct.rcPaint.top,paintStruct.rcPaint.right,paintStruct.rcPaint.bottom);
-       this->EndPaint(&paintStruct);
-       ::SelectObject(paintDC,oldBrush);
-       ::SelectObject(paintDC,oldPen);
-                       
-       return;
-}
+                                               this->DrawItem(mdc,listRect,*chatData);
+                                       }
 
 
-VOID CCommentView::OnSizing(UINT wParam,LPRECT lParam){
+                                       listRect.top = listRect.bottom;
+                               }
 
+                               mdc.SelectPen(outLinePen);
+                               mdc.MoveTo(listRect.left,listRect.bottom);
+                               mdc.LineTo(listRect.right,listRect.bottom);
+
+                               if(selectFlag == TRUE){
+                                       this->DrawItem(mdc,selectRect,*selectData);
+                               }
+
+                       }
+                       windowRect.left = listRect.right;
+                       mdc.FillRect(&windowRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
 
-       ChangeSize( _WTYPES_NS::CSize(lParam->right - lParam->left,lParam->bottom - lParam->top));
 
-                       
-       return;
 
-}
+
+               }
 
 
 
-LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
-       ChangeSize(lParam);
-                       
-       return 0;
-}
 
+               return;
+       }
 
-VOID CCommentView::ChangeSize(const SIZE& client){
-       
-       SCROLLINFO scrollInfoTmp = {0};
-       scrollInfoTmp.cbSize = sizeof(scrollInfoTmp);
-       scrollInfoTmp.fMask = SIF_PAGE;
-       scrollInfoTmp.nPage = client.cx;
-       this->SetScrollInfo(SB_HORZ,&scrollInfoTmp);
+       VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
 
-       this->GetScrollInfo(SB_HORZ,&hScrollInfo);
 
-       HDWP hDwp = BeginDeferWindowPos(2);
-       
+               SCROLLINFO vScrollInfo = {0};
+               vScrollInfo.fMask = SIF_ALL;
 
-       INT_PTR movePos =  -1 * hScrollInfo.nPos;
-       
-       m_header.DeferWindowPos(hDwp,m_header.m_hWnd,movePos,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
-       m_listBox.DeferWindowPos(hDwp,m_listBox.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,hScrollInfo.nMax,client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);                
 
-       EndDeferWindowPos(hDwp);
-       
-       
-       RECT bkRect;
-       RECT headerRectSize;
-       m_header.GetWindowRect(&headerRectSize);
-       bkRect.left = headerRectSize.right - headerRectSize.left - hScrollInfo.nPos;
-       bkRect.top = 0;
-       bkRect.right = client.cx ;
-       bkRect.bottom = client.cy;
-       this->InvalidateRect(&bkRect);
+               self.GetScrollInfo(SB_VERT,&vScrollInfo);
+               BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
+               vScrollInfo.nPage = CalcScrollPage(vScrollInfo.nMax);
 
-       return;
-}
+               vScrollInfo.fMask = SIF_PAGE;
+               self.SetScrollInfo(SB_VERT,&vScrollInfo);
 
 
-LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
 
-       return TRUE;
-}
+               if(scrollFlag == TRUE){
+                       self.SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+               }
 
+               this->Invalidate();
 
-VOID CCommentView::OnDestroy(){
-       m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
-       INT_PTR headerItemcount = m_header.GetItemCount();
-       RECT headerItemRect;
-       for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
-                               
-               m_header.GetItemRect(itemindex,&headerItemRect);
-               viewproperty.headerholSize[itemindex] = headerItemRect.right - headerItemRect.left;
+               return;
        }
-       commentlist.OnDestroy();
-       m_header.DestroyWindow();
-       m_listBox.DestroyWindow();
-       return;
 
-}
 
-LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
+       UINT_PTR CCommentListWindow::CalcScrollPage(UINT_PTR nMax){
+
+               RECT clientRect;
+               INT_PTR rslt = 0;
+               LONG height = 0;
+               this->GetClientRect(&clientRect);
+
+               SCROLLINFO vScrollInfo = {0};
+               if(self.commentlist.empty() != TRUE){
 
-       if(lParam->hwndFrom == m_header.m_hWnd){
+                       CCommentList::reverse_iterator rbegin = self.commentlist.rbegein();
+                       CCommentList::reverse_iterator rend = self.commentlist.rend();
+                       for(;rbegin != rend;++rbegin){
 
-               m_listBox.Invalidate();
+                               height += CalcItemHeight(*rbegin);
+                               rslt++;
+                               if(height > clientRect.bottom)goto overclientrect;
 
+                       }
+               }
+               /*
+               vScrollInfo.fMask = SIF_RANGE;
+               self.GetScrollInfo(SB_VERT,&vScrollInfo);
+               */
+               rslt = nMax+ 1;
+
+
+overclientrect:
+
+               return rslt;
        }
 
-       return 0;
-}
+       VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
+
+
+               RECT noViewRect;
+               RECT userNameViewRect;
+               RECT timeViewRect;
+               RECT chatViewRect;
+               RECT infoViewRect;
+
+
+               time_t chatTime = (time_t)difftime(chatData.date,self.streamStatus.start_time);
+
+
+               BOOL beforeStartFlag = chatTime < 0 ? TRUE : FALSE;
+               TCHAR noString[sizeof(chatData.no) * 8]; 
+               TCHAR dateString[LENGTH_16];
+               if(chatData.no != 0)_stprintf(noString,TEXT("%u"),chatData.no);
+               else _tcscpy(noString,TEXT(""));
+               CNLiteString timeFormat;
+
+
+               if(beforeStartFlag == TRUE){
+
+                       timeFormat = TEXT("-");
+                       chatTime = -chatTime;
+               }
+               tm ct = *gmtime(&chatTime);
+               if(ct.tm_hour != 0 ){
+
+                       timeFormat += TEXT("%H:%M:%S");
+
+               } else {
+
+                       timeFormat += TEXT("%M:%S");
+               }
+
+               _tcsftime(dateString,ARRAY_LENGTH(dateString),timeFormat,&ct);
+
+               COLORREF bkColor;
+               COLORREF outLineColor;
+
+               CPen outLinePen;
+               CPen colLinePen;
+               CBrush bkBrush;
+               colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
+
+
+               //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
+               if (chatData.selectFlag == TRUE)
+               {
+                       bkColor = ColorList::selectBack;
+                       outLineColor = ColorList::outLineSelect;
+
+
+               }
+               else  
+               {
+
+                       outLineColor = ColorList::outLineNomal;
+
+                       if(chatData.listenerData->originBkFlag == TRUE){
+
+                               bkColor = chatData.listenerData->bkColor;
+
+
+                       } else {
+
+                               bkColor = self.viewproperty.backColor;
+
+
+
+                       }
+               }
+
+               outLinePen.CreatePen(PS_SOLID,1,outLineColor);
+               bkBrush.CreateSolidBrush(bkColor);
+               dc.SelectPen(outLinePen);
+
+               if(chatData.selectFlag == TRUE){
+
+                       dc.MoveTo(rc.left,rc.bottom);
+                       dc.LineTo(rc.right,rc.bottom);
+               }
+               dc.FillRect(&rc,bkBrush);
+               dc.SetBkColor(bkColor);
+               dc.MoveTo(rc.left,rc.top);
+               dc.LineTo(rc.right,rc.top);
 
 
-VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
-                       
-       INT_PTR dy;
-       switch(loWParam){
+               dc.SetTextColor(self.viewproperty.baseStringColor);
 
-       case SB_THUMBPOSITION:
-       case SB_THUMBTRACK:
-               dy = hiWParam - hScrollInfo.nPos;
-               break;
 
-       case SB_LINELEFT:
-       case SB_PAGELEFT:
 
-               dy = -1 * hScrollInfo.nPage;
 
-               break;
 
-       case SB_LINERIGHT:
-       case SB_PAGERIGHT:
+               //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
 
-               dy = hScrollInfo.nPage + hScrollInfo.nPos > (UINT_PTR)hScrollInfo.nMax ? 0 :(UINT_PTR) (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) < hScrollInfo.nPage ? (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) : hScrollInfo.nPage;
+               self.m_header.GetItemRect(CCommentView::NO,&noViewRect);
+               self.m_header.GetItemRect(CCommentView::USERNAME,&userNameViewRect);
+               self.m_header.GetItemRect(CCommentView::COMMENT,&chatViewRect);
+               self.m_header.GetItemRect(CCommentView::TIME,&timeViewRect);
+               self.m_header.GetItemRect(CCommentView::INFO,&infoViewRect);
 
-               break;
+               noViewRect.left += 2;
+               userNameViewRect.left += 2;
+               timeViewRect.left += 2;
+               chatViewRect.left += 2;
+               infoViewRect.left += 2;
 
-       default:
-               dy = 0;
-               break;
+               noViewRect.right -= 2;
+               userNameViewRect.right -= 2;
+               timeViewRect.right -= 2;
+               chatViewRect.right -= 2;
+               infoViewRect.right -= 2;
+
+               noViewRect.top = rc.top + 2;
+               userNameViewRect.top = rc.top + 2;
+               timeViewRect.top = rc.top + 2;
+               chatViewRect.top = rc.top + 2;
+               infoViewRect.top = rc.top + 2;
+
+               noViewRect.bottom = rc.bottom - 2;
+               userNameViewRect.bottom = rc.bottom - 2;
+               timeViewRect.bottom = rc.bottom - 2;
+               chatViewRect.bottom = rc.bottom - 2;
+               infoViewRect.bottom = rc.bottom - 2;
+
+               dc.SelectPen(colLinePen);
+
+               dc.MoveTo(noViewRect.right,rc.top);
+               dc.LineTo(noViewRect.right,rc.bottom);
+               dc.MoveTo(userNameViewRect.right,rc.top);
+               dc.LineTo(userNameViewRect.right,rc.bottom);
+               dc.MoveTo(chatViewRect.right,rc.top);
+               dc.LineTo(chatViewRect.right,rc.bottom);
+               dc.MoveTo(timeViewRect.right,rc.top);
+               dc.LineTo(timeViewRect.right,rc.bottom);
+
+               dc.DrawTextW(noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
+               dc.DrawTextW(chatData.listenerData->user_id,chatData.listenerData->user_id.GetLength(),&userNameViewRect,DT_WORD_ELLIPSIS);
+               dc.DrawTextW(chatData.chatBuf,chatData.chatBuf.GetLength(),&chatViewRect,DT_WORDBREAK);
+               dc.DrawTextW(dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
 
+               return;
        }
-       
-       dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
 
 
-       if(dy != 0){
-               hScrollInfo.nPos += dy;
-               RECT headerPosRect;
-               RECT listBoxPosRect;
-               m_header.GetWindowRect(&headerPosRect);
-               m_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 - commentViewConstant::HEADER_HAIGHT);
-               listBoxPosRect.top = commentViewConstant::HEADER_HAIGHT;
-               listBoxPosRect.right += moveRange - listBoxPosRect.left;
-               listBoxPosRect.left = moveRange;
-                       
-               m_header.MoveWindow(&headerPosRect);
-               m_listBox.MoveWindow(&listBoxPosRect);
-                                       
-                               
-                                       
+       UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
 
-               HDWP hDwp = BeginDeferWindowPos(2);
+               RECT drowSize;
+               self.m_header.GetItemRect(CCommentView::COMMENT,&drowSize);
+               drowSize.left += 2;
+               drowSize.top +=  2;
+               drowSize.right -= 2;
+               drowSize.bottom = 0;
+
+               CPaintDC pdc(*this);
+               pdc.SelectFont(AtlGetDefaultGuiFont());
+               ::DrawTextW(pdc,chatData.chatBuf,chatData.chatBuf.GetLength(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
+               drowSize.top -= 2;
+               drowSize.bottom += 2;
+
+               return drowSize.bottom;
+       }
 
-               m_header.DeferWindowPos(hDwp,m_header.m_hWnd,moveRange,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
-               m_listBox.DeferWindowPos(hDwp,m_listBox.m_hWnd,moveRange,commentViewConstant::HEADER_HAIGHT,0,0,SWP_NOSIZE | SWP_NOZORDER);             
 
-               EndDeferWindowPos(hDwp);
-                                       
-                                       
-               this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+       LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
+
+               return 0;
        }
-                       
-       return;
-}
 
-LRESULT CCommentView::OnCreate(LPCREATESTRUCT lpcs){
-       m_header.Create(m_hWnd,0,WC_HEADER,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN   | HDS_BUTTONS | HDS_HOTTRACK |HDS_DRAGDROP | HDS_FULLDRAG  ,0,commentViewConstant::HEADER_ID);
-       m_listBox.Create(m_hWnd,0,WC_LISTBOX,WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN   | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY | LBS_NOREDRAW , 0,commentViewConstant::LISTBOX_ID);
-       m_listBox.SetFont(AtlGetDefaultGuiFont());
-       /*
-       m_subListBox.SubclassWindow(m_listBox);
-       m_subListBox.CreateMemoryDC();
-       */              
-       return 0;
-}
+       INT_PTR CCommentListWindow::CalcClickLine(INT_PTR height){
+               SCROLLINFO vScrollInfo = {0};
+               vScrollInfo.fMask = SIF_POS;
+
+               self.GetScrollInfo(SB_VERT,&vScrollInfo);
+
+               INT_PTR heightSum = 0;
+               INT_PTR lineNo = vScrollInfo.nPos;
+               CCommentList::iterator chatData = self.commentlist.begin();
+               CCommentList::iterator end = self.commentlist.end();    
+               std::advance(chatData,vScrollInfo.nPos);
+               for(; chatData != end;++chatData){
 
-VOID CCommentView::AddHeader(LPHEADERSINFO infos){
+                       heightSum += CalcItemHeight(*chatData);
 
+                       if(heightSum >= height){
 
-       m_header.SetFont(hHeaderFontNew);
+                               goto end;
+                       }
 
-       HDITEM item;
-       item.mask = HDI_FORMAT | HDI_TEXT | HDI_WIDTH;
-       item.fmt = HDF_CENTER | HDF_STRING;
-                       
-                       
-       for(UINT_PTR index = 0;index < infos->count ;++index){
+                       ++lineNo;
+               }
+               lineNo = -1;
+end:
 
-               item.pszText = infos->columns[index];
 
-               item.cxy =  infos->holizensize[index];
-               m_header.AddItem(&item);
+               return lineNo;
        }
 
-       RECT itemRect;
-       hScrollInfo.nMax = 0;
-       UINT_PTR itemCount = m_header.GetItemCount();
-       for(UINT_PTR u_index = 0;u_index < itemCount;++u_index){
 
-               m_header.GetItemRect(u_index,&itemRect);
-               hScrollInfo.nMax += itemRect.right - itemRect.left;
 
+       VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+
+
+
+               this->SetFocus();
+               if(self.commentlist.empty() == TRUE)return;
+               auto curselItem = self.commentlist.GetCurSelItem();
+               if(curselItem != self.commentlist.end()){
+                       curselItem->selectFlag = FALSE;
+               }
+               self.commentlist.SetCurSel(CalcClickLine(point.y));
+               if(TryEnterCriticalSection(&this->m_sec) == TRUE){
+                       this->Invalidate();
+                       this->Unlock();
+               }
+               return;
        }
-                       
-       this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE); 
-       DecisionHorzSize();
-       return;
-}
 
-VOID CCommentView::DecisionHorzSize(){
-       
-       HDWP hWindowPosInfo = BeginDeferWindowPos(2);
-       RECT bkWindowRect;
-       this->GetClientRect(&bkWindowRect);
-       m_header.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
-       m_listBox.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
 
-       EndDeferWindowPos(hWindowPosInfo);
-       bkWindowRect.left = hScrollInfo.nMax;
-                       
-       this->InvalidateRect(&bkWindowRect);
-                       
-       return;
-}
+       VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
+
+
+
+
+               this->SetFocus();
+               if(self.commentlist.empty() == TRUE)return;
+
+               auto chatData = self.commentlist.GetChatAt(CalcClickLine(point.y));
+               COLORREF bkColor;
+               if(chatData.listenerData->originBkFlag == FALSE){
+                       CListenerColorCollector colorCollector;
+                       listenerList.BkColorCollect(colorCollector);
+                       UCHAR red;
+                       UCHAR green;
+                       UCHAR blue;
+
+                       srand((unsigned int)time(NULL));
+                       do{
+
+                               red = getrgb();
+                               green = getrgb();
+                               blue = getrgb();
+                               bkColor = RGB(red,green,blue);
+
+                       }while(colorCollector.Find(bkColor));
+
+                       chatData.listenerData->originBkFlag = TRUE;
+                       chatData.listenerData->SetBkColor(bkColor);
+               } else {
+
+
+                       chatData.listenerData->originBkFlag = FALSE;
+               }
+
+
 
 
-//
-//\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\93à\95\94\83\8a\83X\83g\83N\83\89\83X
-////////////////////////////////////////////////////////////////////
 
 
-VOID CCommentView::CSubCommentListBox::OnPaint(HDC hdc){
+               if(TryEnterCriticalSection(&this->m_sec) == TRUE){
+                       this->Invalidate(TRUE);
+                       this->Unlock();
+               }
+
+
+
+
+               return;
+       }
+
+       LRESULT CCommentListWindow::OnEraseBkGnd(HDC lparam){
+
+               return TRUE;
+       }
+
+       LRESULT CCommentListWindow::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
 
-       PAINTSTRUCT ps;
-       this->BeginPaint(&ps);
 
+               self.SendMessageW(WM_VSCROLL,MAKELONG(hiWparam < 0 ? SB_PAGEDOWN : SB_PAGEUP ,0),0);
 
-       this->EndPaint(&ps);
 
-       return;
-}
+               return 0;
+       }
 
 
 
-VOID CCommentView::CSubCommentListBox::CreateMemoryDC(){
-       HDC hdc = this->GetDC();
-       m_MemoryDC.CreateCompatibleDC(hdc);
-       m_Bitmap.CreateCompatibleBitmap(m_MemoryDC,300,200);
-       
-       ReleaseDC(hdc);
-       return;
-}
-                       
\ No newline at end of file
+}
\ No newline at end of file