VOID CCommentView::OnConnect(){
+ m_commentListWindow.SetRedraw(FALSE);
commentlist.OnConnect();
-// m_commentListWindow.SetRedraw(FALSE);
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_ALL;
+ this->SetScrollInfo(SB_VERT,&vScrollInfo);
+ m_commentListWindow.SetRedraw(TRUE);
+
}
-LRESULT CCommentView::OnheaderItemChanged(LPNMHDR lParam){
+LRESULT CCommentView::OnHeaderEndTrack(LPNMHDR lParam){
if(lParam->hwndFrom == m_header.m_hWnd){
- dumpln(TEXT("OnheaderItemChanged\8aJ\8en"));
+
SCROLLINFO vScrollInfo = {0};
vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
this->GetScrollInfo(SB_VERT,&vScrollInfo);
- vScrollInfo.nPos++;
- BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
+ vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
+ vScrollInfo.fMask = SIF_PAGE;
+ this->SetScrollInfo(SB_VERT,&vScrollInfo);
+ BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage + 1>= vScrollInfo.nMax;
UINT_PTR commentCount = commentlist.Size();
-
- dumpln(TEXT("Invalidate\91O"));
+ LPNMHEADER lpNmHdr = (LPNMHEADER )lParam;
+
+ m_header.SetItem(lpNmHdr->iItem,lpNmHdr->pitem);
+
m_commentListWindow.Invalidate();
- dumpln(TEXT("Invalidate\8cã"));
+
if(scrollFlag == TRUE){
INT_PTR nMin = 0;
this->SetScrollRange(SB_HORZ,nMin,nMax,TRUE);
DecisionHorzSize();
- dumpln(TEXT("OnheaderItemChanged\8fI\97¹"));
+
}
return 0;
}
VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
-
-
- commentlist.Lock();
commentlist.OnChatReceve(chat,commnetCountSum);
- commentlist.Unlock();
-
return;
}
vScrollInfo.fMask = SIF_ALL;
this->GetScrollInfo(SB_VERT,&vScrollInfo);
+ BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
- if(vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax == TRUE){
- vScrollInfo.nPos = commentCountSum;
- }
- vScrollInfo.fMask = SIF_RANGE | SIF_POS;
+ vScrollInfo.fMask = SIF_RANGE;
vScrollInfo.nMax = commentCountSum;
- this->SetScrollInfo(SB_VERT,&vScrollInfo);
-
- idumpln(TEXT("chatreceve_start:%d"),GetCurrentThreadId());
- commentlist.Lock();
+ this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+
+
+
vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
- commentlist.Unlock();
+
vScrollInfo.fMask = SIF_PAGE;
- this->SetScrollInfo(SB_VERT,&vScrollInfo);
+ this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+
+ if(scrollFlag == TRUE){
+ this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
+ }
m_commentListWindow.Invalidate();
- idumpln(TEXT("chatreceve_end:%d"),GetCurrentThreadId());
+
return;
}
LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl){
- /*
- if(wndCtl.m_hWnd == m_commentListWindow.m_hWnd){
-
- //INT_PTR cursel = m_commentListWindow.GetCurSel();
- INT_PTR cursel = 0;
- 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);
-
- }while(colorCollector.Find(bkColor));
-
- chatData.listenerData->originBkFlag = TRUE;
-
- } else {
-
- bkColor = viewproperty.backColor;
- chatData.listenerData->originBkFlag = FALSE;
- }
-
-
-
-
- chatData.listenerData->SetBkColor(bkColor);
-
- m_commentListWindow.Invalidate(TRUE);
- }
- */
return 0;
}
-VOID CCommentView::OnSizing(UINT wParam,LPRECT lParam){
-
-
- ChangeSize( _WTYPES_NS::CSize(lParam->right - lParam->left,lParam->bottom - lParam->top));
-
-
- return;
-
-}
INT_PTR dy;
SCROLLINFO vScrollInfo = {0};
vScrollInfo.fMask = SIF_ALL;
- vScrollCcs.Lock();
+
this->GetScrollInfo(SB_VERT,&vScrollInfo);
switch(loWParam){
dy = max(-1 * vScrollInfo.nPos, min(dy, vScrollInfo.nMax - vScrollInfo.nPos));
- idumpln(TEXT("dy:%d"),dy);
if(dy != 0){
this->SetScrollInfo(SB_VERT,&vScrollInfo);
m_commentListWindow.Invalidate();
}
- vScrollCcs.Unlock();
return;
}
//\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
////////////////////////////////////////////////////////////////////
-CCommentListWindow::CCommentListWindow(CCommentView &in_self):self(in_self){
-
- colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
- outLinePenNomal.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
- outLinePenSelect.CreatePen(PS_SOLID,1,ColorList::outLineSelect);
-
+CCommentListWindow::CCommentListWindow(CCommentView &in_self):self(in_self){
}
CCommentListWindow::~CCommentListWindow(){
- colLinePen.DeleteObject();
- outLinePenNomal.DeleteObject();
- outLinePenSelect.DeleteObject();
}
VOID CCommentListWindow::OnPaint(HDC hdc){
- dumpln(TEXT("CCommentListWindow::OnPaint\8aJ\8enthread:%d"),GetCurrentThreadId());
+
RECT windowRect;
RECT clientRect;
CCommentList &commentList = self.commentlist;
- //\83R\83\81\83\93\83g\83\8a\83X\83g\83\8d\83b\83N
- commentList.Lock();
+
SCROLLINFO vScrollInfo = {0};
if(commentList.Size() > (UINT_PTR)vScrollInfo.nPos){
CCommentList::iterator chatData = commentList.begin();
- chatData += vScrollInfo.nPos;
- m_memoryDC.FillRect(&listRect,self.viewproperty.backColor);
+
+ std::advance(chatData,vScrollInfo.nPos);
+ CBrush baseBkBrush;
+ baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+ m_memoryDC.FillRect(&listRect,baseBkBrush);
+ baseBkBrush.DeleteObject();
CCommentList::iterator endData = commentList.end();
listRect.bottom = 0;
for(;chatData != endData;++chatData){
}
-
//\83R\83\81\83\93\83g\83\8a\83X\83g\83\8d\83b\83N\89ð\8f\9c
- commentList.Unlock();
+// commentList.Unlock();
+
PAINTSTRUCT ps;
HDC selfDC = this->BeginPaint(&ps);
::BitBlt(selfDC,0,0,windowRect.right,windowRect.bottom,m_memoryDC,0,0,SRCCOPY);
this->EndPaint(&ps);
- dumpln(TEXT("CCommentListWindow::OnPaint\8fI\97¹:%d"),GetCurrentThreadId());
return;
}
VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_PAGE;
- self.commentlist.Lock();
+ vScrollInfo.fMask = SIF_ALL;
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
vScrollInfo.nPage = CalcScrolPage();
- self.commentlist.Unlock();
+
self.SetScrollInfo(SB_VERT,&vScrollInfo);
+
+ if(scrollFlag == TRUE){
+ self.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
+ }
return;
}
}
vScrollInfo.fMask = SIF_ALL;
-
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
rslt = vScrollInfo.nMax + 1;
-
overclientrect:
- self.commentlist.Unlock();
return rslt;
}
_tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
COLORREF bkColor;
+
+ CPen outLinePen;
+ CPen colLinePen;
+ colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
+
//\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
if (chatData.selectFlag == TRUE)
{
bkColor = ColorList::selectBack;
- dc.SelectPen(outLinePenSelect);
- dc.SetBkColor(ColorList::selectBack);
+ outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineSelect);
}
else
{
- dc.SelectPen(outLinePenNomal);
+ outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
if(chatData.listenerData->originBkFlag == TRUE){
bkColor = chatData.listenerData->bkColor;
-
- dc.SetBkColor(chatData.listenerData->bkColor);
} else {
+
bkColor = self.viewproperty.backColor;
- dc.SetBkColor(self.viewproperty.backColor);
+
}
}
-
+
+ dc.SelectPen(outLinePen);
+ dc.SetBkColor(bkColor);
+ //\83e\83L\83X\83g\82Ì\83J\83\89\81[\82ð\90Ý\92è
dc.SetTextColor(self.viewproperty.baseStringColor);
- //\83e\83L\83X\83g\82Ì\83J\83\89\81[\82ð\90Ý\92è
- dc.FillRect(&rc,bkColor);
+
+ CBrush bkBrush;
+ bkBrush.CreateSolidBrush(bkColor);
+ dc.FillRect(&rc,bkBrush);
+ bkBrush.DeleteObject();
//\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
-
+
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);
- dc.MoveTo(rc.left,rc.top,NULL);
- dc.LineTo(rc.right,rc.top);
- dc.MoveTo(rc.left,rc.bottom,NULL);
- dc.LineTo(rc.right,rc.bottom);
+ UINT_PTR upline = rc.top;
+ UINT_PTR bottomline = rc.bottom -1;
+ dc.MoveTo(rc.left,upline,NULL);
+ dc.LineTo(rc.right,upline);
+ dc.MoveTo(rc.left,bottomline,NULL);
+ dc.LineTo(rc.right,bottomline);
noViewRect.left += 2;
userNameViewRect.left += 2;
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){
+
+ heightSum += CalcItemHeight(*chatData);
+
+ if(heightSum >= height){
+
+ goto end;
+ }
+
+ ++lineNo;
+ }
+ lineNo = -1;
+end:
+
+
+ return lineNo;
+}
+
VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+ auto curselItem = self.commentlist.GetCurSelItem();
+ if(curselItem != self.commentlist.end()){
+ curselItem->selectFlag = FALSE;
+ }
+ self.commentlist.SetCurSel(CalcClickLine(point.y));
+
+ this->Invalidate();
return;
}
VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
+
+
+
+
+ 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;
+
+ } else {
+
+ bkColor = self.viewproperty.backColor;
+ chatData.listenerData->originBkFlag = FALSE;
+ }
+
+
+
+
+ chatData.listenerData->SetBkColor(bkColor);
+
+ this->Invalidate(TRUE);
+
+
+
return;
}