OSDN Git Service

主コメ選択時にエディットの色が変わる機能を追加
[nlite/nlite.git] / nlite / nlite_commentview.cpp
index b1e0e0f..d4a52f3 100644 (file)
@@ -1,22 +1,89 @@
 #include "stdafx.h"
 #include "nlite_include.h"
-
+using namespace std::tr1;
 
 namespace nlite{
 
+       static const LPCTSTR LIVEURL_PART = TEXT("http://live.nicovideo.jp/watch/");
+       static const LPCTSTR ADDMYLIST_PART = TEXT("http://www.nicovideo.jp/mylist_add/video/");
 
        static const UINT_PTR SELL_SPACE_LENGTH = 1;
        //
        //\83R\83\81\83\93\83g\83r\83\85\81[\93à\82Ì\83R\83\93\83g\83\8d\81[\83\8b\83N\83\89\83X
        ///////////////////////////////////////////////////////////////////
 
-       BOOL CChatReadEdit::SetWindowText(LPCTSTR str){
+       CChatReadEdit::CChatReadEdit(CCommentView &m_master):m_master(m_master){
+
+
+       }
+
+       BOOL CChatReadEdit::SetWindowText(const CChatData &chat){
+
+               BOOL rslt = FALSE;
+               try{
+                       
+                       tstring viewString(regex_replace(tstring(chat.chatBuf),nliteregex::TAGSTRING,nliteregex::text::NUTHINGSTRING));
+                       rslt = __super::SetWindowText(viewString.c_str());
+
+                       CHARFORMAT2 defaultFormat;
+                       this->GetDefaultCharFormat(defaultFormat);
+                       defaultFormat.dwMask |=  CFM_COLOR;
+                       if(chat.premium == 2 || chat.premium == 3){
+
+                               defaultFormat.crTextColor = m_master.viewproperty.ownerStringColor;
+                       }
+                       
+                       else {
+
+                               defaultFormat.crTextColor = m_master.viewproperty.baseStringColor;
+
+                       }
+
+                       BOOL rslt = this->SetDefaultCharFormat(defaultFormat);
+                       
 
-               return __super::SetWindowText(str);
+
+                       linkStringBeside(viewString,nliteregex::LILNKREGEX);
+                       
+                       
+
+               } catch(std::exception &e){
+                       e;
+                       rslt =  FALSE;
+
+               }
+
+               return rslt;
                
        }
 
-       
+       VOID CChatReadEdit::linkStringBeside(const tstring &target,const nliteregex::tregex &re){
+
+               match_results<tstring::const_iterator> regexRslt;
+               tstring::const_iterator beginStr = target.begin();
+               tstring::const_iterator endstr = target.end();
+               CHARFORMAT2 cf;
+               cf.cbSize = sizeof(cf);
+               cf.dwMask = CFM_LINK;
+               cf.dwEffects = CFE_LINK;
+               INT_PTR basePosition = 0;
+               while(regex_search(beginStr,endstr,regexRslt,re)){
+                       basePosition += regexRslt.position(0);
+                       this->SetSel(basePosition,basePosition + regexRslt.length());
+                       this->SetCharFormat(cf,SCF_SELECTION);
+                       basePosition += regexRslt.length();
+                               
+                       beginStr = regexRslt[0].second;
+               }
+
+       }
+
+       VOID CChatReadEdit::Reset(){
+
+               __super::SetWindowText(TEXT(""));
+
+               return;
+       }
 
        HWND CChatReadEdit::GeneralCreate(HWND hParent,DWORD eventMask,UINT id){
 
@@ -39,6 +106,7 @@ namespace nlite{
                int point = -MulDiv(deflogFont.lfHeight,72,picy);
                int twips = point * 20;
                m_defCharFormat.yHeight = twips;
+               m_defCharFormat.dwEffects ^= CFE_AUTOCOLOR;
                _tcscpy(m_defCharFormat.szFaceName,deflogFont.lfFaceName);
                this->SetEventMask(eventMask);
                
@@ -50,7 +118,8 @@ namespace nlite{
        }
 
        CChatChildCtrls::CChatChildCtrls(CCommentView &hMaster):
-       m_master(hMaster)
+       m_master(hMaster),
+       chatDispCtrl(hMaster)
        {
                
                return;
@@ -74,16 +143,16 @@ namespace nlite{
                return;
        }
 
-       VOID CChatChildCtrls::Hide(){
-               HDWP hdwp = ::BeginDeferWindowPos(GetCtrlCount());
-               chatDispCtrl.DeferWindowPos(hdwp,chatDispCtrl.m_hWnd,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_HIDEWINDOW);
-               ::EndDeferWindowPos(hdwp);
+       VOID CChatChildCtrls::Hide(HDWP hdwp){
+
+               chatDispCtrl.DeferWindowPos(hdwp,chatDispCtrl,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_HIDEWINDOW);
+
        }
        
-       VOID CChatChildCtrls::SetCtrl(const RECT  &rc,CCommentList::reference comment,BOOL mulutiLineFlag){
+       VOID CChatChildCtrls::SetCtrl(HDWP hdwp,const RECT  &rc,CCommentList::reference comment,BOOL mulutiLineFlag){
 
                
-               chatDispCtrl.SetWindowText(comment.chatBuf);
+               chatDispCtrl.SetWindowText(comment);
                RECT chatRect = rc;
                
                
@@ -104,9 +173,9 @@ namespace nlite{
                        
                                bkColor = comment.viewData.backColor;
 
-                       }else if(comment.listenerData->originBkFlag == TRUE){
+                       }else if(comment.listenerData->bgcolor != ListenerData::INIT_COLOR){
 
-                               bkColor = comment.listenerData->bkColor;
+                               bkColor = comment.listenerData->bgcolor;
 
 
                        } else {
@@ -120,10 +189,9 @@ namespace nlite{
 
 
                chatDispCtrl.SetBackgroundColor(bkColor);
-//             dumpln(TEXT("height:%d"),rc.bottom - rc.top);
-               HDWP hdwp = ::BeginDeferWindowPos(GetCtrlCount());
+
                chatDispCtrl.DeferWindowPos(hdwp,NULL,chatRect.left,chatRect.top,chatRect.right - chatRect.left ,chatRect.bottom - chatRect.top, SWP_NOZORDER | SWP_SHOWWINDOW);
-               ::EndDeferWindowPos(hdwp);
+
                return;
        }
 
@@ -150,44 +218,63 @@ namespace nlite{
        VOID CChatChildCtrlsList::ShowCntrls(){
 
 
-               dumpln(TEXT("showcntrls:start"));
-               RECT headerRect;
-               RECT tmpRect;
-               RECT listRect;
-               m_hMaster.m_commentListWindow.GetClientRect(&listRect);
-               m_hMaster.m_header.GetItemRect(CCommentView::COMMENT,&headerRect);
-               headerRect.top = 0;
-               headerRect.bottom = 0;
-               
                
-               INT_PTR heightSum =0;
 
-               auto ctrlsBegin = m_list.begin();
-               auto ctrlsEnd = m_list.end();
+               
 
                if(m_hMaster.commentlist.Size() > 0){
-               
+
+
+
+                       RECT headerRect;
+                       RECT tmpRect;
+                       RECT listRect;
+                       m_hMaster.m_commentListWindow.GetClientRect(&listRect);
+                       m_hMaster.m_header.GetItemRect(CCommentView::COMMENT,&headerRect);
+                       headerRect.top = 0;
+                       headerRect.bottom = 0;
+                       
+                       UINT_PTR counter = 0;
+                       INT_PTR heightSum =0;
+
+                       auto ctrlsBegin = m_list.begin();
+                       auto ctrlsEnd = m_list.end();
                        auto chatDataBegin = m_hMaster.commentlist.GetShortCut();
+                       auto chatDataEnd = m_hMaster.commentlist.end();
+                       auto chatDataTmp = chatDataBegin;
+                       for(;chatDataBegin != chatDataEnd && heightSum < listRect.bottom;++chatDataBegin){
+                               m_hMaster.m_commentListWindow.CalcItemHeight(*chatDataBegin);
+                               counter++;
+                               heightSum += chatDataBegin->viewData.height;
+                       } 
 
                        
-                       for(;  chatDataBegin != m_hMaster.commentlist.end() && heightSum < listRect.bottom;++ctrlsBegin,++chatDataBegin){
+               
+                       chatDataBegin = chatDataTmp;
+                       heightSum = 0;
+                       HDWP hdwp = ::BeginDeferWindowPos(CChatChildCtrls::GetCtrlCount() * (counter > m_list.size() ? counter : m_list.size()));
+                       for(;  chatDataBegin != chatDataEnd && counter > 0 ;++ctrlsBegin,++chatDataBegin,--counter){
                        
-                               m_hMaster.m_commentListWindow.CalcItemHeight(*chatDataBegin);
+                               
                                tmpRect = headerRect;
                                tmpRect.top += heightSum;
                                tmpRect.bottom += heightSum + chatDataBegin->viewData.height;
 
                                if(ctrlsBegin == ctrlsEnd)ctrlsBegin = Extend();
 
-                               ctrlsBegin->SetCtrl(tmpRect,*chatDataBegin,m_hMaster.viewproperty.commentFoldingFlag);
+                               ctrlsBegin->SetCtrl(hdwp,tmpRect,*chatDataBegin,m_hMaster.viewproperty.commentFoldingFlag);
 
                                heightSum = tmpRect.bottom;
+
+                               
                        }
                
                        for(;ctrlsBegin != ctrlsEnd;++ctrlsBegin){
 
-                               ctrlsBegin->Hide();
+                               ctrlsBegin->Hide(hdwp);
                        }
+
+                       ::EndDeferWindowPos(hdwp);
                }
                
 
@@ -202,10 +289,11 @@ namespace nlite{
                auto begin =m_list.begin();
                auto end = m_list.end();
 
-
+               HDWP hdwp = ::BeginDeferWindowPos(CChatChildCtrls::GetCtrlCount() * m_list.size());
                for(;begin != end;++begin){
-                       begin->Hide();
+                       begin->Hide(hdwp);
                }
+               ::EndDeferWindowPos(hdwp);
 
        }
 
@@ -229,12 +317,12 @@ namespace nlite{
        //\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
        ///////////////////////////////////////////////////////
 
-       CCommentView::CCommentView(CNicoLiveStream &stream):
+       CCommentView::CCommentView(CNicoLiveStream &stream,CNicoVideoAuth &in_refAuth):
        m_commentListWindow(*this),
-       stream(stream)
-#ifdef USE_RICHEDIT
+       stream(stream),
+       refAuth(in_refAuth)
        ,chatChildCtrlsList(*this)
-#endif
+
        {
 
                LOGFONT lf = {0};
@@ -257,11 +345,21 @@ namespace nlite{
                return;
        }
 
+       VOID CCommentView::UpDateUI(){
 
+               this->chatChildCtrlsList.ShowCntrls();
+               this->m_commentListWindow.Invalidate();
+               return;
+       }
 
 
        VOID CCommentView::OnConnect(){
                m_commentListWindow.SetRedraw(FALSE);
+               m_commentListWindow.ResetViewSellHeight();
+
+               chatChildCtrlsList.AllHide();
+
+
                commentlist.OnConnect();
 
                SCROLLINFO vScrollInfo = {0};
@@ -273,10 +371,7 @@ namespace nlite{
                m_commentListWindow.SetRedraw(TRUE);
                m_commentListWindow.Invalidate();
 
-#ifdef USE_RICHEDIT
-               chatChildCtrlsList.AllHide();
 
-#endif
 
        }
 
@@ -290,9 +385,13 @@ namespace nlite{
                return nMax;
        }
 
-       VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
+       VOID CCommentView::SetProperty(const CommentViewProperty &setProperty,const GeneralProperty &in_generalProperty){
 
+               
                viewproperty = setProperty;
+               generalProperty = in_generalProperty;
+               m_commentListWindow.OnSetProperty();
+               
                return;
        }
 
@@ -337,7 +436,7 @@ namespace nlite{
 
                AddHeader(&headersinfo);
 
-               m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+               m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOrderArray),viewproperty.headerOrderArray);
 
                
                
@@ -387,7 +486,7 @@ namespace nlite{
 
                        if(scrollFlag == TRUE){
 
-                               this->SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+                               this->m_commentListWindow.SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
                        }
 
                        INT_PTR itemCount = m_header.GetItemCount();
@@ -419,7 +518,7 @@ namespace nlite{
        VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
 
 
-               commentlist.OnChatReceve(chat,commnetCountSum,this->m_commentListWindow);
+               commentlist.OnChatReceve(chat,stream.GetDefaultCommunity(),commnetCountSum,this->m_commentListWindow);
 
                return;
        }
@@ -454,8 +553,8 @@ namespace nlite{
 
                if(vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) >= vScrollInfo.nMax - static_cast<INT_PTR>(vScrollInfo.nPage)){
                        m_commentListWindow.Invalidate();
-
-                       this->PostMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
+                       
+                       this->m_commentListWindow.PostMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
                }
 
                return;
@@ -520,6 +619,24 @@ namespace nlite{
        }
 
 
+
+       LRESULT CCommentView::OnClickChatNo(UINT uMsg,WPARAM wParam,LPARAM lParam){
+               
+               
+               ::SendMessage(::GetAncestor(*this,GA_ROOT),uMsg,wParam,lParam);
+               
+               return 0;
+       }
+               
+
+       LRESULT CCommentView::OnClickUserName(UINT uMsg,WPARAM wParam,LPARAM lParam){
+               
+       
+               ::SendMessage(::GetAncestor(*this,GA_ROOT),uMsg,wParam,lParam);
+               
+               return 0;
+       }
+
        LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
 
                return TRUE;
@@ -527,7 +644,7 @@ namespace nlite{
 
 
        VOID CCommentView::OnDestroy(){
-               m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+               m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOrderArray),viewproperty.headerOrderArray);
                INT_PTR headerItemcount = m_header.GetItemCount();
                RECT headerItemRect;
                for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
@@ -546,7 +663,9 @@ namespace nlite{
 
                if(lParam->hwndFrom == m_header.m_hWnd){
                        
-
+                       LPNMHEADER pNMHeader = (LPNMHEADER) lParam; 
+                       this->m_header.SetItem(pNMHeader->iItem,pNMHeader->pitem);
+                       
                        m_commentListWindow.Invalidate();
                        this->m_commentListWindow.SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
                        
@@ -556,7 +675,6 @@ namespace nlite{
                return 0;
        }
 
-
        VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
 
@@ -607,7 +725,7 @@ namespace nlite{
                        EndDeferWindowPos(hDwp);
 
 
-                       this->m_commentListWindow.SetScrollInfo(SB_HORZ,&hScrollInfo);
+                       this->SetScrollInfo(SB_HORZ,&hScrollInfo);
                }
 
                return;
@@ -762,17 +880,46 @@ namespace nlite{
        ////////////////////////////////////////////////////////////////////
 
        CCommentListWindow::CCommentListWindow(CCommentView &in_self):
-       self(in_self)
-       {}
+       self(in_self),
+       viewSellHeight(0)
+       {
+               CFontHandle font = ::AtlGetDefaultGuiFont();
+               LOGFONT logfont;
+               font.GetLogFont(&logfont);
+               logfont.lfUnderline = TRUE;
+               
+               linkFont.CreateFontIndirect(&logfont);
+       }
 
        CCommentListWindow::~CCommentListWindow(){
        }
 
+       
 
-       VOID CCommentListWindow::OnPaint(HDC in_hdc){
+       VOID CCommentListWindow::OnSetProperty(){
 
+               if(IsWindow() == TRUE)this->SetRedraw(FALSE);
 
+               if(collLinePen.IsNull() == FALSE)collLinePen.DeleteObject();
+               if(normalSellLinePen.IsNull() == FALSE)normalSellLinePen.DeleteObject();
+               if(normalBkBrush.IsNull() == FALSE)normalBkBrush.DeleteObject();
+               if(selectSellLinePen.IsNull() ==FALSE)selectSellLinePen.DeleteObject();
+               if(selectBkBrush.IsNull() == FALSE)selectBkBrush.DeleteObject();
 
+               collLinePen.CreatePen(PS_SOLID,1,self.viewproperty.colLineColor);
+               normalSellLinePen.CreatePen(PS_SOLID,1,self.viewproperty.normalSellLineColor);
+               normalBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+               selectSellLinePen.CreatePen(PS_SOLID,1,self.viewproperty.selectSellLineColor);
+               selectBkBrush.CreateSolidBrush(self.viewproperty.selectBackColor);
+
+
+               if(IsWindow() == TRUE)this->SetRedraw(TRUE);
+       }
+
+
+       VOID CCommentListWindow::OnPaint(HDC in_hdc){
+
+               this->self.refAuth.GetUserSession();
                RECT windowRect;
                RECT listRect = {0};
                RECT clientRect;
@@ -808,44 +955,112 @@ namespace nlite{
                                listRect.right = self.GetColumnHolSizeSum();            
 
                                CCommentList::iterator chatData = commentList.GetShortCut();
-                       
 
-
-
-                               CBrush baseBkBrush;
-                               baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
-                               mdc.FillRect(&listRect,baseBkBrush);
-                               baseBkBrush.DeleteObject();
+                       
+                               
+                               
+                               mdc.FillRect(&listRect,this->normalBkBrush);
+                               
                                CCommentList::iterator endData = commentList.end();
                                listRect.bottom = 0;
                                
+                               RECT headerRects[COMMENTVIEW_HEADERITEMSIZE];
+                               RECT colLineRects[COMMENTVIEW_HEADERITEMSIZE];
+                               RECT selectHeaderRects[COMMENTVIEW_HEADERITEMSIZE];
+                               
+                               self.m_header.GetItemRect(CCommentView::NO,&headerRects[CCommentView::NO]);
+                               self.m_header.GetItemRect(CCommentView::USERNAME,&headerRects[CCommentView::USERNAME]);
+                               self.m_header.GetItemRect(CCommentView::COMMENT,&headerRects[CCommentView::COMMENT]);
+                               self.m_header.GetItemRect(CCommentView::TIME,&headerRects[CCommentView::TIME]);
+                               self.m_header.GetItemRect(CCommentView::INFO,&headerRects[CCommentView::INFO]);
 
+                               memcpy(colLineRects,headerRects,sizeof(headerRects));
+
+                               
+                               
+                               
+               
+                               headerRects[CCommentView::NO].left += SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::USERNAME].left += SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::COMMENT].left += SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::TIME].left += SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::INFO].left += SELL_SPACE_LENGTH;
+
+                               headerRects[CCommentView::NO].right -= SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::USERNAME].right -= SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::COMMENT].right -= SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::TIME].right -= SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::INFO].right -= SELL_SPACE_LENGTH;
+
+                               headerRects[CCommentView::NO].top = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::USERNAME].top = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::COMMENT].top = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::TIME].top = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::INFO].top = SELL_SPACE_LENGTH;
+
+                               headerRects[CCommentView::NO].bottom = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::USERNAME].bottom = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::COMMENT].bottom = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::TIME].bottom = SELL_SPACE_LENGTH;
+                               headerRects[CCommentView::INFO].bottom = SELL_SPACE_LENGTH;
+
+                               INT_PTR listRectTop = listRect.top;
                                for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
                                        CalcItemHeight(*chatData);
 
 //                                     dumpln(TEXT("height:%d"),chatData->viewData.height);
                                        listRect.bottom += chatData->viewData.height;
 
+                                       headerRects[CCommentView::NO].top = listRect.top + SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::USERNAME].top = listRect.top + SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::COMMENT].top = listRect.top + SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::TIME].top = listRect.top + SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::INFO].top = listRect.top + SELL_SPACE_LENGTH;
+
+                                       headerRects[CCommentView::NO].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::USERNAME].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::COMMENT].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::TIME].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+                                       headerRects[CCommentView::INFO].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+
                                        if(chatData->viewData.selectFlag == TRUE){
                                                selectFlag = TRUE;
                                                selectData = chatData;
                                                selectRect = listRect;
+                                               memcpy(selectHeaderRects,headerRects,sizeof(headerRects));
                                        } else {
 
-                                               this->DrawItem(mdc,listRect,*chatData);
+                                               
+
+
+                                               this->DrawItem(mdc,listRect,headerRects,*chatData);
                                        }
 
 
                                        listRect.top = listRect.bottom;
                                }
 
-       
-                               
+                               viewSellHeight = listRect.bottom;
+
+
 
                                if(selectFlag == TRUE){
-                                       this->DrawItem(mdc,selectRect,*selectData);
+                                       this->DrawItem(mdc,selectRect,selectHeaderRects,*selectData);
                                }
 
+                                       //\8d\80\96Ú\82Ì\8fc\90ü\82ð\95`\89æ
+                               mdc.SelectPen(collLinePen);
+                               mdc.MoveTo(colLineRects[CCommentView::NO].right,listRectTop);
+                               mdc.LineTo(colLineRects[CCommentView::NO].right,listRect.bottom);
+                               mdc.MoveTo(colLineRects[CCommentView::USERNAME].right,listRectTop);
+                               mdc.LineTo(colLineRects[CCommentView::USERNAME].right,listRect.bottom);
+                               mdc.MoveTo(colLineRects[CCommentView::COMMENT].right,listRectTop);
+                               mdc.LineTo(colLineRects[CCommentView::COMMENT].right,listRect.bottom);
+                               mdc.MoveTo(colLineRects[CCommentView::TIME].right,listRectTop);
+                               mdc.LineTo(colLineRects[CCommentView::TIME].right,listRect.bottom);
+                               mdc.MoveTo(colLineRects[CCommentView::INFO].right,listRectTop);
+                               mdc.LineTo(colLineRects[CCommentView::INFO].right,listRect.bottom);
+
                        }
                        windowRect.left = listRect.right;
                        mdc.FillRect(&windowRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
@@ -865,10 +1080,10 @@ namespace nlite{
        LRESULT CCommentListWindow::OnSetCtrol(UINT uMsg,WPARAM wparam,LPARAM lparam){
 
 
-#ifdef USE_RICHEDIT
+
                self.chatChildCtrlsList.ShowCntrls();
-#endif
-               dumpln(TEXT("setctrl"));
+
+
 
                return 0;
        }
@@ -932,14 +1147,14 @@ overclientrect:
                return rslt;
        }
 
-       VOID CCommentListWindow::DrawItem(CDC &dc,const RECT &rc,CChatData &chatData){
+       VOID CCommentListWindow::DrawItem(CDC &dc,const RECT &rc,const RECT *headerRect,CChatData &chatData){
 
 
-               RECT noViewRect;                                                                                //\83R\83\81\94Ô\95\\8e¦\97Ì\88æ
-               RECT userNameViewRect;                                                                  //\83\86\81[\83U\96¼\95\\8e¦\97Ì\88æ
-               RECT timeViewRect;                                                                              //\8e\9e\8aÔ\95\\8e¦\97Ì\88æ
-               RECT chatViewRect;                                                                              //\83R\83\81\83\93\83g\95\\8e¦\97Ì\88æ
-               RECT infoViewRect;                                                                              //\83R\83\81\83\93\83g\8fî\95ñ\95\\8e¦\97Ì\88æ
+               RECT noViewRect = headerRect[CCommentView::NO];                                                                         //\83R\83\81\94Ô\95\\8e¦\97Ì\88æ
+               RECT userNameViewRect = headerRect[CCommentView::USERNAME];                                                     //\83\86\81[\83U\96¼\95\\8e¦\97Ì\88æ
+               RECT chatViewRect = headerRect[CCommentView::COMMENT];                                                          //\83R\83\81\83\93\83g\95\\8e¦\97Ì\88æ
+               RECT timeViewRect = headerRect[CCommentView::TIME];                                                                     //\8e\9e\8aÔ\95\\8e¦\97Ì\88æ  
+               RECT infoViewRect  = headerRect[CCommentView::INFO];                                                                    //\83R\83\81\83\93\83g\8fî\95ñ\95\\8e¦\97Ì\88æ
 
 
                //
@@ -975,104 +1190,88 @@ overclientrect:
 
 
                COLORREF bkColor;                                                                                                       //\94w\8ci\90F
-               COLORREF sellLineColor;                                                                                         //\98g\90ü\90F
-               CPen sellLinePen;                                                                                                       //\98g\90ü\95`\89æ\97p\83y\83\93
-               CPen collLinePen;                                                                                                       //\8d\80\96Ú\8fc\90ü\95`\89æ\97p\83y\83\93
-               CBrush bkBrush;                                                                                                         //\94w\8ci\95`\89æ\97p\83u\83\89\83V
-               collLinePen.CreatePen(PS_SOLID,1,self.viewproperty.colLineColor);
-
-
+               CPen originSellLinePen;                                                                                                 //\98g\90ü\95`\89æ\97p\83y\83\93
+               CBrush originBkBrush;                                                                                                           //\94w\8ci\95`\89æ\97p\83u\83\89\83V
+               
                //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
                if (chatData.viewData.selectFlag == TRUE)
                {
                        bkColor = self.viewproperty.selectBackColor;
-                       sellLineColor = self.viewproperty.selectSellLineColor;
+                       
+                       dc.SelectBrush(this->selectBkBrush);
+                       dc.SelectPen(this->selectSellLinePen);
                }
                else  
                {
 
-                       sellLineColor = chatData.viewData.sellLineColor == CChatData::ViewData::INIT_COLOR ? self.viewproperty.normalSellLineColor : chatData.viewData.sellLineColor;
+                       if(chatData.viewData.sellLineColor == CChatData::ViewData::INIT_COLOR){
+                               dc.SelectPen(this->normalSellLinePen);
 
-                       if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR){
-                       
-                               bkColor = chatData.viewData.backColor;
+                       } else {
+
+                               originSellLinePen.CreatePen(PS_SOLID,1,chatData.viewData.sellLineColor);
+                               dc.SelectPen(originSellLinePen);
+                       }
 
-                       }else if(chatData.listenerData->originBkFlag == TRUE){
+                       
 
-                               bkColor = chatData.listenerData->bkColor;
+                       if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR || chatData.listenerData->bgcolor != ListenerData::INIT_COLOR){
+                       
+                               if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR){
+                                       bkColor = chatData.viewData.backColor;
+                                       originBkBrush.CreateSolidBrush(chatData.viewData.backColor);
+                               
+                               }else if(chatData.listenerData->bgcolor != ListenerData::INIT_COLOR){
 
+                                       bkColor = chatData.listenerData->bgcolor;
+                                       originBkBrush.CreateSolidBrush(chatData.listenerData->bgcolor);
+                                       
+                               }
 
+                               dc.SelectBrush(originBkBrush);
                        } else {
 
                                bkColor = self.viewproperty.backColor;
-
+                               dc.SelectBrush(this->normalBkBrush);
+                               dc.SelectBrush(this->normalBkBrush);
 
 
                        }
                }
                
                //\94w\8ci\82Æ\98g\90ü\82ð\95`\89æ
-               sellLinePen.CreatePen(PS_SOLID,1,sellLineColor);
-               bkBrush.CreateSolidBrush(bkColor);
-               dc.SelectPen(sellLinePen);
-               dc.SelectBrush(bkBrush);
+               
+               
                dc.Rectangle(rc.left,rc.top  - 1,rc.right ,rc.bottom + 1);
                dc.SetBkColor(bkColor);
-               dc.SetTextColor(chatData.viewData.stringColor == CChatData::ViewData::INIT_COLOR ? chatData.viewData.stringColor :self.viewproperty.baseStringColor);
+               
 
                //\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);
-
-               noViewRect.left += SELL_SPACE_LENGTH;
-               userNameViewRect.left += SELL_SPACE_LENGTH;
-               timeViewRect.left += SELL_SPACE_LENGTH;
-               chatViewRect.left += SELL_SPACE_LENGTH;
-               infoViewRect.left += SELL_SPACE_LENGTH;
-
-               noViewRect.right -= SELL_SPACE_LENGTH;
-               userNameViewRect.right -= SELL_SPACE_LENGTH;
-               timeViewRect.right -= SELL_SPACE_LENGTH;
-               chatViewRect.right -= SELL_SPACE_LENGTH;
-               infoViewRect.right -= SELL_SPACE_LENGTH;
-
-               noViewRect.top = rc.top + SELL_SPACE_LENGTH;
-               userNameViewRect.top = rc.top + SELL_SPACE_LENGTH;
-               timeViewRect.top = rc.top + SELL_SPACE_LENGTH;
-               chatViewRect.top = rc.top + SELL_SPACE_LENGTH;
-               infoViewRect.top = rc.top + SELL_SPACE_LENGTH;
-
-               noViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-               userNameViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-               timeViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-               chatViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-               infoViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-
-               //\8d\80\96Ú\82Ì\8fc\90ü\82ð\95`\89æ
-               dc.SelectPen(collLinePen);
-               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);
-
 
+               
+               
+               CComBSTR &viewUserName = chatData.listenerData->name.Length() == 0 ? chatData.listenerData->user_id : chatData.listenerData->name;
+               dc.SelectFont(linkFont);
+               dc.SetTextColor(chatData.listenerData->nameColor != ListenerData::INIT_COLOR ? chatData.listenerData->nameColor : self.viewproperty.linkStringColor);
                //\83e\83L\83X\83g\95`\89æ
                dc.DrawTextW(noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
-               dc.DrawTextW(chatData.listenerData->user_id,chatData.listenerData->user_id.Length(),&userNameViewRect,DT_WORD_ELLIPSIS);
-               dc.DrawTextW(chatData.chatBuf,chatData.chatBuf.Length(),&chatViewRect,DT_WORDBREAK | DT_EDITCONTROL);
+
+               
+               dc.DrawTextW(viewUserName,viewUserName.Length(),&userNameViewRect,DT_WORD_ELLIPSIS);
+               dc.SelectFont(::AtlGetDefaultGuiFont());
+               dc.SetTextColor(chatData.viewData.stringColor == CChatData::ViewData::INIT_COLOR ? chatData.viewData.stringColor :self.viewproperty.baseStringColor);
                dc.DrawTextW(dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
 
                return;
        }
 
+       VOID CCommentListWindow::ResetViewSellHeight(){
+
+               viewSellHeight = 0;
+
+               return;
+       }
 
 
        VOID CCommentListWindow::ShowCurSel(){
@@ -1088,9 +1287,12 @@ overclientrect:
                
                if(!(cursel >= vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) / 2 && cursel <= vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) / 2)){
                        self.SetScrollPos(SB_VERT,cursel - (vScrollInfo.nPage / 2));
+                       self.commentlist.SetShortCut(self.GetScrollPos(SB_VERT));
                }
 
                this->Invalidate();
+
+               this->SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
 end:
 
                return;
@@ -1101,21 +1303,21 @@ end:
        VOID CCommentListWindow::CalcItemHeight(CChatData &chatData){
                
                if(chatData.viewData.height == 0){
-               //      dumpln(TEXT("viewdataupdate"));
                        RECT drowSize;
                        self.m_header.GetItemRect(CCommentView::COMMENT,&drowSize);
                
                        drowSize.bottom = 0;
 
-                       CChatReadEdit cedit;
+                       CChatReadEdit cedit(self);
                
                        cedit.GeneralCreate(*this,ENM_REQUESTRESIZE,CALCEDIT_ID);
-                       cedit.SetWindowText(TEXT(""));
+                       cedit.Reset();
                        cedit.SetWindowPos(NULL,0,0,drowSize.right - drowSize.left,drowSize.bottom - drowSize.top,SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW);
-                       cedit.SetWindowText(chatData.chatBuf);
+                       cedit.SetWindowText(chatData);
                        cedit.GetClientRect(&drowSize);
                        cedit.DestroyWindow();
-                       if(drowSize.bottom - drowSize.top > 70)drowSize.bottom = drowSize.top + 70;
+                       drowSize.bottom += 12;
+                       if(drowSize.bottom - drowSize.top > 120)drowSize.bottom = drowSize.top + 120;
                        chatData.viewData.height = drowSize.bottom - drowSize.top;
                }
 
@@ -1126,6 +1328,13 @@ end:
 
        LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
                
+               //CComPtr<IUnknown> iu;
+               //::AtlAxCreateControlEx(TEXT("MSHTML:<HTML><BODY></BODY></HTML>"),*this,(IStream*)NULL,(IUnknown**)NULL,&iu,GUID_NULL);
+
+               //iu->QueryInterface(DIID_DWebBrowserEvents2,&addToMyListWindow);
+               RECT rc = {0,0,300,200};
+//             addToMyListWindow.Create(m_hWnd, &rc,_T("Shell.Explorer.2"),WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN , 0);
+
                return 0;
        }
 
@@ -1135,12 +1344,13 @@ end:
 
                CCommentList::iterator chatData = self.commentlist.GetShortCut();
                CCommentList::iterator end  = self.commentlist.end();
-               dumpln(TEXT("height:%d"),height);
-       
+
+
+               
                for(; chatData != end ;(++chatData)){
                        CalcItemHeight(*chatData);
                        heightSum += chatData->viewData.height;
-                       dumpln(TEXT("height:%d"),heightSum);
+
                        
                        if(heightSum >= height)break;
                }
@@ -1152,20 +1362,85 @@ end:
        }
 
 
+       BOOL CCommentListWindow::IsOnNoOrUserName(UINT_PTR index,const POINT &point){
 
-       VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+               RECT rc = {0};
+               
+               self.m_header.GetItemRect(index,&rc);
+               BOOL rslt = FALSE;
 
+               if((point.x >= rc.left && point.x <= rc.right) && (point.y < static_cast<INT_PTR>(viewSellHeight))){
 
+                       INT_PTR heightsum = 0;
+                       auto clickData = self.commentlist.GetShortCut();
+                       auto endData = self.commentlist.end();
+                       for(;clickData != endData;++clickData){
 
+                               heightsum += clickData->viewData.height;
 
+                               if(heightsum > point.y){
+                                       
+                                       CDC cdc = this->GetDC();
+                                       
+                                       rc.top = heightsum -= clickData->viewData.height;
+                                       RECT calcRect = {0};
+                                       cdc.SelectFont(linkFont);
 
-               if(point.x > (INT_PTR)self.GetColumnHolSizeSum()) goto end;
 
+                                       if(index == CCommentView::USERNAME){
+                                               LPCTSTR viewStr = clickData->listenerData->name.Length() == 0 ? clickData->listenerData->user_id : clickData->listenerData->name;
+                                               cdc.DrawTextW(viewStr ,_tcslen(viewStr),&calcRect,DT_CALCRECT);
+                                       
+                                       } else if(index == CCommentView::NO){
+                                               TCHAR viewStr[sizeof(UINT_PTR) * 8];
+                                               _stprintf(viewStr,TEXT("%d"),clickData->no);
+                                               cdc.DrawTextW(viewStr,_tcslen(viewStr),&calcRect,DT_CALCRECT);
+
+                                       }
+                                       rc.bottom = rc.top +  calcRect.bottom - calcRect.top;
+                                       rc.right = rc.right > rc.left + calcRect.right - calcRect.left ? rc.left + calcRect.right - calcRect.left : rc.right;
+                                       rslt = (point.y >= rc.top && point.y <= rc.bottom && point.x >= rc.left && point.x <= rc.right);
+                                       
+                                       break;
+
+                               }
+                       }
+                       
+               }
+
+               return rslt;
+
+       }
+
+
+       VOID CCommentListWindow::OnDestroy(){
+
+//             this->addToMyListWindow.DestroyWindow();
+
+       }
+
+       VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+
+
+
+               CCommentList::iterator ite;
                this->SetFocus();
+               if(point.x > (INT_PTR)self.GetColumnHolSizeSum()) goto end;
+
+               
                if(self.commentlist.empty() == TRUE)goto end;
                
-               self.commentlist.SetCurSel(CalcClickLine(point.y));
+               ite = CalcClickLine(point.y);
+               self.commentlist.SetCurSel(ite);
                
+               if(this->IsOnNoOrUserName(CCommentView::NO,point) == TRUE){
+
+                       ::SendMessage(self,UM_CLICK_CHATNO,(WPARAM)&(*ite),(LPARAM)self.m_hWnd);
+
+               } else if(this->IsOnNoOrUserName(CCommentView::USERNAME,point) == TRUE){
+
+                       ::SendMessage(self,UM_CLICK_USERNAME,(WPARAM)&(*ite),(LPARAM)self.m_hWnd);
+               }
 
 
                
@@ -1182,42 +1457,45 @@ end:
 
 
 
-               if(point.x > (INT_PTR)self.GetColumnHolSizeSum()) return;
-               auto end  = self.commentlist.end();
-               auto lineIte = CalcClickLine(point.y);
-               if( lineIte == end)return;
+               if(!(point.x > (INT_PTR)self.GetColumnHolSizeSum() || self.commentlist.empty() == TRUE)){
                
+                       auto end  = self.commentlist.end();
+                       auto lineIte = CalcClickLine(point.y);
+                       if( lineIte == end)goto  endlabel;
                
-               COLORREF bkColor;
-               if(lineIte->listenerData->originBkFlag == FALSE){
-                       CListenerColorCollector colorCollector;
-                       listenerList.BkColorCollect(colorCollector);
-                       UCHAR red;
-                       UCHAR green;
-                       UCHAR blue;
+               
+                       COLORREF bkColor;
+                       if(lineIte->listenerData->bgcolor == ListenerData::INIT_COLOR){
+                               CListenerColorCollector colorCollector;
+                               listenerList.BkColorCollect(colorCollector);
+                               UCHAR red;
+                               UCHAR green;
+                               UCHAR blue;
 
-                       srand((unsigned int)time(NULL));
-                       do{
+                               srand((unsigned int)time(NULL));
+                               do{
 
-                               red = getrgb();
-                               green = getrgb();
-                               blue = getrgb();
-                               bkColor = PALETTERGB(red,green,blue);
+                                       red = getrgb();
+                                       green = getrgb();
+                                       blue = getrgb();
+                                       bkColor = PALETTERGB(red,green,blue);
 
-                       }while(colorCollector.Find(bkColor));
+                               }while(colorCollector.Find(bkColor));
 
-                       lineIte->listenerData->originBkFlag = TRUE;
-                       lineIte->listenerData->SetBkColor(bkColor);
-               } else {
+                               
+                               lineIte->listenerData->SetBkColor(bkColor);
+                       } else {
 
 
-                       lineIte->listenerData->originBkFlag = FALSE;
+                               lineIte->listenerData->bgcolor = ListenerData::INIT_COLOR;
+                       }
                }
 
 
 
 
 
+endlabel:
 
 
                this->Invalidate(TRUE);
@@ -1255,7 +1533,7 @@ end:
                
 
                auto cursel = self.commentlist.GetCurSel();
-               if(dy < 0 || dy >= static_cast<INT_PTR>(self.commentlist.Size()))goto end;
+               if((dy < 0 && cursel == self.commentlist.begin())  || dy >= static_cast<INT_PTR>(self.commentlist.Size()))goto end;
 
                
                std::advance(cursel,dy);
@@ -1268,6 +1546,32 @@ end:
                return;
        }
 
+       LRESULT CCommentListWindow::OnSetCursor(HWND wparam,UINT loLparam,UINT hiLparam){
+
+               
+               POINT mousePoint = {0};
+       
+               GetCursorPos(&mousePoint);
+               ::ScreenToClient(*this,&mousePoint);
+               
+               if(( IsOnNoOrUserName(CCommentView::NO,mousePoint) || IsOnNoOrUserName(CCommentView::USERNAME,mousePoint))){
+                       
+                       
+                       ::SetCursor(::LoadCursorW(NULL,IDC_HAND));
+
+               } else {
+
+                       DefWindowProc ();
+
+               }
+               
+
+               
+       
+
+               return FALSE;
+       }
+
        LRESULT CCommentListWindow::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
 
 
@@ -1277,6 +1581,8 @@ end:
                return 0;
        }
 
+       
+
 
        LRESULT CCommentListWindow::OnChatControlNortify(LPNMHDR lParam){
 
@@ -1285,23 +1591,68 @@ end:
                switch(lParam->code){
 
                case EN_LINK:
-
-
-                       break;
-
-                       /*
-               case EN_REQUESTRESIZE:
                        {
-                               REQRESIZE *pReqResize = (REQRESIZE *) lParam;
-                               self.chatChildCtrlsList.rcBuf = pReqResize->rc;
-                               dumpln(TEXT("calcheight:%d"),pReqResize->rc.bottom - pReqResize->rc.top);
+                               ENLINK *lpenlk = (ENLINK *)lParam;
+                               if (lpenlk->msg == WM_LBUTTONDOWN) {
+                                       CRichEditCtrl chatReadEdit = lpenlk->nmhdr.hwndFrom;
+                                       chatReadEdit.SetSel(lpenlk->chrg);
+                                       CString selTextBuf;
+                                       chatReadEdit.GetSelText(selTextBuf);
+                                       if(regex_match((LPCTSTR)selTextBuf,nliteregex::URL) == TRUE){
+
+                                               
+                                               
+
+                                       } else if(regex_match((LPCTSTR)selTextBuf,nliteregex::VIDEOID) == TRUE){
+                                               
+                                               selTextBuf.Insert(0,ADDMYLIST_PART);
+                               
+                                       } else if( regex_match((LPCTSTR)selTextBuf,nliteregex::LIVEID) == TRUE){
+                                               
+                                               selTextBuf.Insert(0,LIVEURL_PART);
+                                               
+                                       }
+                                       
+                                       OpenURL(*this,self.generalProperty,selTextBuf,SW_SHOWNORMAL);
+                               }
                        }
                        break;
-                       */
 
                case EN_MSGFILTER:
+                       {
+                               auto pmf = (MSGFILTER *)lParam;
+                               if (pmf->msg == WM_LBUTTONDOWN || pmf->msg== WM_LBUTTONDBLCLK || pmf->msg == WM_MOUSEWHEEL){
+
+                                       RECT  windowrect;
+                                       ::GetWindowRect(pmf->nmhdr.hwndFrom,&windowrect);
+                                       _WTYPES_NS::CPoint point(windowrect.left +  LOWORD(pmf->lParam),windowrect.top + HIWORD(pmf->lParam));
+                                       ::ScreenToClient(*this,&point);
+
+                                       switch(pmf->msg){
+
+                                       case WM_LBUTTONDOWN:
+                                               OnLButtonDown(pmf->wParam,point);
+                                               break;
+
+                                       case WM_LBUTTONDBLCLK:
+                                               OnLButtonDblClk(pmf->wParam,point);
+                                               break;
 
+                                       case WM_MOUSEWHEEL:
+                                               OnMouseWheel(LOWORD(pmf->wParam),HIWORD(pmf->wParam),point);
+                                               break;
 
+                                       default:
+
+                                               break;
+                                       }
+                                       
+                               } 
+
+                                       
+
+                               
+            }
                        break;
 
 
@@ -1319,7 +1670,6 @@ end:
 
                auto pReqResize = reinterpret_cast <REQRESIZE *>(lParam);
                ::SetWindowPos(pReqResize->nmhdr.hwndFrom,NULL,0,0,pReqResize->rc.right - pReqResize->rc.left,pReqResize->rc.bottom - pReqResize->rc.top,SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW);
-               //calcRc = pReqResize->rc;
                return 0;
        }