#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;
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);
+
+ return;
+ }
+
+
+ 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);
- m_listBox.SetCurSel(curSel);
-
- m_listBox.SetRedraw(TRUE);
- m_listBox.Invalidate();
-
if(scrollFlag == TRUE){
+ this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
+ }
+
- m_listBox.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
+ 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();
}
- 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;
+ //this->SetScrollInfo(SB_VERT,NULL);
+
+ return;
+ }
+
+ static UCHAR getrgb(){
+
+ UCHAR rgb = 160 + rand() % 92;
+ return rgb;
+ }
+
+
+
+
+
+
+
+
+
+
+
+ LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
+ ChangeSize(lParam);
+
+ return 0;
+ }
+
+
+ VOID CCommentView::ChangeSize(const SIZE& client){
+
+ SCROLLINFO hScrollInfo = {0};
+ hScrollInfo.cbSize = sizeof(hScrollInfo);
+ hScrollInfo.fMask = SIF_PAGE;
+ hScrollInfo.nPage = client.cx;
+
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+ hScrollInfo.fMask = SIF_ALL;
+ this->GetScrollInfo(SB_HORZ,&hScrollInfo);
+
+
+ HDWP hDwp = BeginDeferWindowPos(2);
+
+
+ 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);
+
+ 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;
+
+
+ return;
+ }
+
+
+ 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();
+ }
+
+ }
+
+ return 0;
+ }
+
+
+ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+
+
+ 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;
+
+ case SB_LINELEFT:
+ case SB_PAGELEFT:
+
+ dy = -1 * hScrollInfo.nPage;
+
+ break;
+
+ case SB_LINERIGHT:
+ case SB_PAGERIGHT:
+
+ 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;
+
+ }
+
+ dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
+
+
+ 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);
}
- this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE);
+ 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();
+ }
+ }
+
+
+
+ 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);
+
+
+
+
+ return 0;
+ }
+
+ VOID CCommentView::AddHeader(LPHEADERSINFO infos){
+
+
+ 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;
}
- return 0;
-}
+ VOID CCommentView::DecisionHorzSize(){
-VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
-
+ 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);
-
- Lock();
- commentlist.OnChatReceve(chat,count);
- m_listBox.AddString((LPCTSTR)&commentlist.back());
+ EndDeferWindowPos(hWindowPosInfo);
- 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,SB_BOTTOM,0);
+ return;
}
- Unlock();
-}
-VOID CCommentView::SetStreamStatus(StreamStatus &st){
-
- streamStatus.SetStreamStatus(st);
-}
-VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
- m_listBox.SetRedraw(TRUE);
-
+ //
+ //\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
+ ////////////////////////////////////////////////////////////////////
- return;
-}
+ CCommentListWindow::CCommentListWindow(CCommentView &in_self):
+ self(in_self)
+ {}
-static UCHAR getrgb(){
+ CCommentListWindow::~CCommentListWindow(){
+ }
- UCHAR rgb = 160 + rand() % 92;
- return rgb;
-}
-LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl){
-
+ VOID CCommentListWindow::OnPaint(HDC in_hdc){
- if(wndCtl.m_hWnd == m_listBox.m_hWnd){
- 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{
+ RECT windowRect;
+ RECT listRect = {0};
+ RECT clientRect;
- red = getrgb();
- green = getrgb();
- blue = getrgb();
- bkColor = RGB(red,green,blue);
+ self.GetClientRect(&clientRect);
+ clientRect.bottom -= commentViewConstant::HEADER_HAIGHT;
- }while(colorCollector.Find(bkColor));
+ this->GetWindowRect(&windowRect);
+ windowRect.right -= windowRect.left;
+ windowRect.bottom -= windowRect.top;
+ windowRect.left = 0;
+ windowRect.top = 0;
- chatData.listenerData->originBkFlag = TRUE;
- } else {
+ CPaintDC pdc(*this);
- bkColor = viewproperty.backColor;
- chatData.listenerData->originBkFlag = FALSE;
+ {
+ 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);
+
+
+ if(chatData->selectFlag == TRUE){
+ selectFlag = TRUE;
+ selectData = chatData;
+ selectRect = listRect;
+ } else {
+
+ this->DrawItem(mdc,listRect,*chatData);
+ }
+
+
+ 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));
+
+
+
+
+ }
+
+
+
+
+ return;
+ }
+
+ VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
+
+
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_ALL;
+
+
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
+ vScrollInfo.nPage = CalcScrollPage(vScrollInfo.nMax);
+
+ vScrollInfo.fMask = SIF_PAGE;
+ self.SetScrollInfo(SB_VERT,&vScrollInfo);
+
+
+
+ if(scrollFlag == TRUE){
+ self.SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+ }
+
+ this->Invalidate();
+
+ return;
+ }
+
+
+ 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){
+
+ CCommentList::reverse_iterator rbegin = self.commentlist.rbegein();
+ CCommentList::reverse_iterator rend = self.commentlist.rend();
+ for(;rbegin != rend;++rbegin){
+
+ height += CalcItemHeight(*rbegin);
+ rslt++;
+ if(height > clientRect.bottom)goto overclientrect;
+
+ }
}
+ /*
+ vScrollInfo.fMask = SIF_RANGE;
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ */
+ rslt = nMax+ 1;
-
-
- chatData.listenerData->SetBkColor(bkColor);
+overclientrect:
- m_listBox.Invalidate(TRUE);
+ return rslt;
}
- return 0;
-}
+ VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
-VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
- if((lpDrawItemStruct->hwndItem == m_listBox.m_hWnd) && ((UINT)m_listBox.GetCount() > lpDrawItemStruct->itemID)){
-
RECT noViewRect;
RECT userNameViewRect;
RECT timeViewRect;
RECT chatViewRect;
RECT infoViewRect;
-
- CChatData &chatData = *(CChatData*)lpDrawItemStruct->itemData;
+ time_t chatTime = (time_t)difftime(chatData.date,self.streamStatus.start_time);
-
- time_t chatTime = (time_t)difftime(chatData.date,streamStatus.start_time);
- tm ct = *gmtime(&chatTime);
-
-
+ BOOL beforeStartFlag = chatTime < 0 ? TRUE : FALSE;
TCHAR noString[sizeof(chatData.no) * 8];
TCHAR dateString[LENGTH_16];
- _stprintf(noString,TEXT("%u"),chatData.no);
+ if(chatData.no != 0)_stprintf(noString,TEXT("%u"),chatData.no);
+ else _tcscpy(noString,TEXT(""));
+ CNLiteString timeFormat;
- _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
-
-
- //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
- if ((lpDrawItemStruct->itemState) & (ODS_SELECTED))
- {
+ if(beforeStartFlag == TRUE){
- SelectObject(lpDrawItemStruct->hDC,bkBurushSelect);
- SelectObject(lpDrawItemStruct->hDC,outLinePenSelect);
- SetBkColor(lpDrawItemStruct->hDC,RGB(255,240,240)) ;
+ timeFormat = TEXT("-");
+ chatTime = -chatTime;
}
- else
- {
- SelectObject(lpDrawItemStruct->hDC,outLinePenNomal);
+ tm ct = *gmtime(&chatTime);
+ if(ct.tm_hour != 0 ){
- if(chatData.listenerData->originBkFlag == TRUE){
-
- SelectObject(lpDrawItemStruct->hDC,chatData.listenerData->baseBkBrush);
- SetBkColor(lpDrawItemStruct->hDC,chatData.listenerData->bkColor) ;
+ timeFormat += TEXT("%H:%M:%S");
- } else {
+ } else {
- SelectObject(lpDrawItemStruct->hDC,bkBurushNomal);
- SetBkColor(lpDrawItemStruct->hDC,viewproperty.backColor) ;
-
- }
+ timeFormat += TEXT("%M:%S");
}
-
-
- //\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);
+ _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
+ {
- //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
+ outLineColor = ColorList::outLineNomal;
- 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);
+ if(chatData.listenerData->originBkFlag == TRUE){
+
+ bkColor = chatData.listenerData->bkColor;
- 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;
+ } else {
+
+ bkColor = self.viewproperty.backColor;
- 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;
- 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;
+ }
+ }
+ outLinePen.CreatePen(PS_SOLID,1,outLineColor);
+ bkBrush.CreateSolidBrush(bkColor);
+ dc.SelectPen(outLinePen);
-
+ if(chatData.selectFlag == TRUE){
- ::DrawText(lpDrawItemStruct->hDC,noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
+ 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);
- ::DrawText(lpDrawItemStruct->hDC,chatData.listenerData->user_id.c_str(),chatData.listenerData->user_id.length(),&userNameViewRect,DT_WORD_ELLIPSIS);
- ::DrawText(lpDrawItemStruct->hDC,chatData.chatBuf.c_str(),chatData.chatBuf.length(),&chatViewRect,DT_WORDBREAK);
- ::DrawText(lpDrawItemStruct->hDC,dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
-
- }
+ dc.SetTextColor(self.viewproperty.baseStringColor);
- return;
-}
-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);
- ::Rectangle(paintDC,paintStruct.rcPaint.left,paintStruct.rcPaint.top,paintStruct.rcPaint.right,paintStruct.rcPaint.bottom);
- this->EndPaint(&paintStruct);
- ::SelectObject(paintDC,oldBrush);
- ::SelectObject(paintDC,oldPen);
-
- return;
-}
+ //\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);
-VOID CCommentView::OnSizing(UINT wParam,LPRECT lParam){
+ 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;
+
+ 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);
- ChangeSize( _WTYPES_NS::CSize(lParam->right - lParam->left,lParam->bottom - lParam->top));
+ return;
+ }
-
- return;
-}
+ UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
+ 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;
-LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
- ChangeSize(lParam);
-
- return 0;
-}
+ return drowSize.bottom;
+ }
-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);
+ LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
- this->GetScrollInfo(SB_HORZ,&hScrollInfo);
+ return 0;
+ }
- HDWP hDwp = BeginDeferWindowPos(2);
-
+ INT_PTR CCommentListWindow::CalcClickLine(INT_PTR height){
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_POS;
- 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);
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
- 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);
+ 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){
- return;
-}
+ heightSum += CalcItemHeight(*chatData);
+ if(heightSum >= height){
-LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
+ goto end;
+ }
- return TRUE;
-}
+ ++lineNo;
+ }
+ lineNo = -1;
+end:
-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 lineNo;
}
- commentlist.OnDestroy();
- m_header.DestroyWindow();
- m_listBox.DestroyWindow();
- return;
-}
-LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
- if(lParam->hwndFrom == m_header.m_hWnd){
+ VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+
- m_listBox.Invalidate();
+ 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;
}
- return 0;
-}
+ VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
-VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
-
- INT_PTR dy;
- switch(loWParam){
- case SB_THUMBPOSITION:
- case SB_THUMBTRACK:
- dy = hiWParam - hScrollInfo.nPos;
- break;
- case SB_LINELEFT:
- case SB_PAGELEFT:
+ this->SetFocus();
+ if(self.commentlist.empty() == TRUE)return;
- dy = -1 * hScrollInfo.nPage;
+ 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;
- break;
+ srand((unsigned int)time(NULL));
+ do{
- case SB_LINERIGHT:
- case SB_PAGERIGHT:
+ red = getrgb();
+ green = getrgb();
+ blue = getrgb();
+ bkColor = RGB(red,green,blue);
- 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;
+ }while(colorCollector.Find(bkColor));
- break;
+ chatData.listenerData->originBkFlag = TRUE;
+ chatData.listenerData->SetBkColor(bkColor);
+ } else {
- default:
- dy = 0;
- break;
- }
-
- dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
+ chatData.listenerData->originBkFlag = FALSE;
+ }
- 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);
-
-
-
- HDWP hDwp = BeginDeferWindowPos(2);
- 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);
- }
-
- 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());
-
-
- return 0;
-}
+ if(TryEnterCriticalSection(&this->m_sec) == TRUE){
+ this->Invalidate(TRUE);
+ this->Unlock();
+ }
-VOID CCommentView::AddHeader(LPHEADERSINFO infos){
- 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){
+ return;
+ }
- item.pszText = infos->columns[index];
+ LRESULT CCommentListWindow::OnEraseBkGnd(HDC lparam){
- item.cxy = infos->holizensize[index];
- m_header.AddItem(&item);
+ return TRUE;
}
- RECT itemRect;
- hScrollInfo.nMax = 0;
- UINT_PTR itemCount = m_header.GetItemCount();
- for(UINT_PTR u_index = 0;u_index < itemCount;++u_index){
+ LRESULT CCommentListWindow::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
- m_header.GetItemRect(u_index,&itemRect);
- hScrollInfo.nMax += itemRect.right - itemRect.left;
- }
-
- this->SetScrollInfo(SB_HORZ,&hScrollInfo,TRUE);
- DecisionHorzSize();
- return;
-}
+ self.SendMessageW(WM_VSCROLL,MAKELONG(hiWparam < 0 ? SB_PAGEDOWN : SB_PAGEUP ,0),0);
-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;
-}
+ return 0;
+ }
-//
-//\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
-////////////////////////////////////////////////////////////////////
+}
\ No newline at end of file