OSDN Git Service

2012/01/11 22:31:33
authorqwerty2501 <riot313@gmail.com>
Wed, 11 Jan 2012 13:31:33 +0000 (22:31 +0900)
committerqwerty2501 <riot313@gmail.com>
Wed, 11 Jan 2012 13:31:33 +0000 (22:31 +0900)
nlite.suo
nlite/nlite_chatData.h
nlite/nlite_commentview.cpp
nlite/nlite_commentview.h

index 9d4372e..f5943f7 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index 7eb0805..556ef8e 100644 (file)
@@ -116,7 +116,7 @@ namespace nlite{
        };
 
 
-       class CCommentList{
+       class CCommentList: public CComAutoCriticalSection{
 
        private:
                std::deque<CChatData> chatList;
index 116e5ab..f108dcd 100644 (file)
@@ -53,8 +53,8 @@ VOID CCommentView::Unlock(){
 
 VOID CCommentView::OnConnect(){
        commentlist.OnConnect();
-       m_commentListWindow.SetRedraw(FALSE);
-       m_commentListWindow.ResetContent();
+//     m_commentListWindow.SetRedraw(FALSE);
+       
 }
 
 
@@ -86,7 +86,7 @@ VOID CCommentView::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lpMersureItemSt
 
                auto &chat = *(CChatData*)lpMersureItemStruct->itemData;
 
-               CDC cdc = m_commentListWindow.GetDC();
+               CDC cdc = this->GetDC();
        
                RECT drowSize;
                m_header.GetItemRect(COMMENT,&drowSize);
@@ -160,36 +160,37 @@ LRESULT CCommentView::OnheaderItemChanged(LPNMHDR lParam){
        
        if(lParam->hwndFrom == m_header.m_hWnd){
 
-               INT_PTR curSel = m_commentListWindow.GetCurSel();
+               //INT_PTR curSel = commentlist.GetCurSel();
 
                SCROLLINFO scrollInfo = {0};
                scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-               m_commentListWindow.GetScrollInfo(SB_VERT,&scrollInfo);
+               this->GetScrollInfo(SB_VERT,&scrollInfo);
                scrollInfo.nPos++;
                BOOL scrollFlag = scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax;
                UINT_PTR commentCount = commentlist.Size();
 
        
-               m_commentListWindow.SetRedraw(FALSE);
-               m_commentListWindow.ResetContent();
+//             m_commentListWindow.SetRedraw(FALSE);
+               //m_commentListWindow.ResetContent();
+               /*
                for(UINT_PTR index =0;index < commentCount;index++){
                        m_commentListWindow.AddString((LPCTSTR)&commentlist.GetChatAt(index));
                }
-       
+               */
 
        
 
-               m_commentListWindow.SetCurSel(curSel);
+               //m_commentListWindow.SetCurSel(curSel);
 
        
 
-               m_commentListWindow.SetRedraw(TRUE);
-               m_commentListWindow.Invalidate();
+//             m_commentListWindow.SetRedraw(TRUE);
+//             m_commentListWindow.Invalidate();
        
 
                if(scrollFlag == TRUE){
 
-                       m_commentListWindow.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
+//                     m_commentListWindow.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
                }
 
                INT_PTR itemCount = m_header.GetItemCount();
@@ -214,18 +215,18 @@ VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
 
        
        Lock();
-       m_commentListWindow.SetRedraw(FALSE);
+//     m_commentListWindow.SetRedraw(FALSE);
        commentlist.OnChatReceve(chat,count);
-       m_commentListWindow.AddString((LPCTSTR)&commentlist.back());
+       //m_commentListWindow.AddString((LPCTSTR)&commentlist.back());
 
        SCROLLINFO scrollInfo = {0};
        scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-       m_commentListWindow.GetScrollInfo(SB_VERT,&scrollInfo);
+//     m_commentListWindow.GetScrollInfo(SB_VERT,&scrollInfo);
        scrollInfo.nPos++;
        
        
        if(scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax == TRUE){
-               m_commentListWindow.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);   
+//             m_commentListWindow.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);   
        }
        Unlock();
 }
@@ -238,7 +239,7 @@ VOID CCommentView::SetStreamStatus(StreamStatus &st){
 
 VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
 
-       m_commentListWindow.SetRedraw(TRUE);
+//     m_commentListWindow.SetRedraw(TRUE);
        
 
        return;
@@ -253,10 +254,11 @@ static UCHAR getrgb(){
 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 = m_commentListWindow.GetCurSel();
+               INT_PTR cursel = 0;
                if(cursel == LB_ERR)return 0;
        
                auto chatData = commentlist.GetChatAt(cursel);
@@ -293,13 +295,13 @@ LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wn
 
                m_commentListWindow.Invalidate(TRUE);
        }
-
+       */
        return 0;
 }
 
 VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
 
-       if((lpDrawItemStruct->hwndItem  == m_commentListWindow.m_hWnd) && ((UINT)m_commentListWindow.GetCount() > lpDrawItemStruct->itemID)){
+       //if((lpDrawItemStruct->hwndItem  == m_commentListWindow.m_hWnd)/* &&/* ((UINT)m_commentListWindow.GetCount() > lpDrawItemStruct->itemID)*/){
                                        
                RECT noViewRect;
                RECT userNameViewRect;
@@ -421,23 +423,13 @@ VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
 
                ::DrawText(lpDrawItemStruct->hDC,dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
                                        
-       }
+       //}
 
        return;
 }
 
 
 
-VOID CCommentView::OnPaint(HDC wParam){
-       PAINTSTRUCT paintStruct;
-       HDC paintDC = this->BeginPaint(&paintStruct);
-       ::FillRect(paintDC,&paintStruct.rcPaint,(HBRUSH)GetStockObject(LTGRAY_BRUSH));
-       this->EndPaint(&paintStruct);
-
-                       
-       return;
-}
-
 
 VOID CCommentView::OnSizing(UINT wParam,LPRECT lParam){
 
@@ -474,7 +466,7 @@ VOID CCommentView::ChangeSize(const SIZE& client){
        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,hScrollInfo.nMax,client.cy - commentViewConstant::HEADER_HAIGHT,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);
        
@@ -509,7 +501,7 @@ VOID CCommentView::OnDestroy(){
        }
        commentlist.OnDestroy();
        m_header.DestroyWindow();
-       m_commentListWindow.DestroyWindow();
+//     m_commentListWindow.DestroyWindow();
        return;
 
 }
@@ -518,7 +510,7 @@ LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
 
        if(lParam->hwndFrom == m_header.m_hWnd){
 
-               m_commentListWindow.Invalidate();
+//             m_commentListWindow.Invalidate();
 
        }
 
@@ -562,11 +554,13 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
        if(dy != 0){
                hScrollInfo.nPos += dy;
-               RECT headerPosRect;
-               RECT listBoxPosRect;
-               m_header.GetWindowRect(&headerPosRect);
-               m_commentListWindow.GetWindowRect(&listBoxPosRect);
+               //RECT headerPosRect;
+               //RECT listBoxPosRect;
+               //m_header.GetWindowRect(&headerPosRect);
+               //m_commentListWindow.GetWindowRect(&listBoxPosRect);
                INT_PTR moveRange = -(hScrollInfo.nPos);
+
+               /*
                headerPosRect.bottom -= headerPosRect.top;
                headerPosRect.top = 0;
                headerPosRect.right += moveRange - headerPosRect.left;
@@ -580,7 +574,7 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
                m_header.MoveWindow(&headerPosRect);
                m_commentListWindow.MoveWindow(&listBoxPosRect);
                                        
-                               
+               */
                                        
 
                HDWP hDwp = BeginDeferWindowPos(2);
@@ -599,8 +593,10 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
 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,WC_LISTBOX,WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN   | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY | LBS_NOREDRAW , 0,commentViewConstant::LISTBOX_ID);
+       m_commentListWindow.Create(m_hWnd,0,WC_LISTBOX,WS_CHILD | WS_VISIBLE  | WS_CLIPCHILDREN  , 0,commentViewConstant::LISTBOX_ID);
        m_commentListWindow.SetFont(AtlGetDefaultGuiFont());
+       
+       
        /*
        m_subListBox.SubclassWindow(m_commentListWindow);
        m_subListBox.CreateMemoryDC();
@@ -646,8 +642,8 @@ 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_commentListWindow.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
+       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);
 
        EndDeferWindowPos(hWindowPosInfo);
        bkWindowRect.left = hScrollInfo.nMax;
@@ -662,4 +658,57 @@ VOID CCommentView::DecisionHorzSize(){
 //\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){}
\ No newline at end of file
+CCommentListWindow::CCommentListWindow(CCommentView &in_self):self(in_self){}
+
+
+
+VOID CCommentListWindow::OnPaint(HDC hdc){
+
+
+       SIZE bitmapSize;
+       m_bitmap.GetSize(bitmapSize);
+       RECT bitmapRect = {0};
+       RECT windowRect;
+       bitmapRect.right = bitmapSize.cx;
+       bitmapRect.bottom = bitmapSize.cy;
+       this->GetWindowRect(&windowRect);
+       m_memoryDC.FillRect(&bitmapRect,self.viewproperty.backColor);
+
+       PAINTSTRUCT ps;
+       HDC selfDC = this->BeginPaint(&ps);
+       ::BitBlt(selfDC,0,0,windowRect.right - windowRect.left,windowRect.bottom - windowRect.top,m_memoryDC,0,0,SRCCOPY);
+       this->EndPaint(&ps);
+       
+       return;
+}
+
+
+
+LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
+       LRESULT lRet = this->DefWindowProc();
+
+       HDC hdc = this->GetDC();
+       m_memoryDC.CreateCompatibleDC(hdc);
+       
+       m_bitmap.CreateCompatibleBitmap(hdc,::GetSystemMetrics(SM_CXFULLSCREEN),::GetSystemMetrics(SM_CYFULLSCREEN));
+       m_memoryDC.SelectBitmap(m_bitmap);
+       this->ReleaseDC(hdc);
+       
+       return lRet;
+}
+
+VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+
+       return;
+}
+
+
+VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
+
+       return;
+}
+
+LRESULT CCommentListWindow::OnEraseBkGnd(HDC lparam){
+
+       return TRUE;
+}
\ No newline at end of file
index 52f9bc0..b1437c0 100644 (file)
@@ -22,10 +22,11 @@ namespace nlite{
        //\83R\83\81\83\93\83g\95\\8e¦\97p\83E\83B\83\93\83h\83E
        class CCommentListWindow:public CWindowImpl<CCommentListWindow>{
 
-               
+               //\83\81\83\93\83o
        private:
                CCommentView &self;
-
+               CBitmap m_bitmap;
+               CDC m_memoryDC;
 
        
 
@@ -40,7 +41,11 @@ namespace nlite{
                //\83\81\83b\83Z\81[\83W\83}\83b\83v
                //
                BEGIN_MSG_MAP(CCommentListWindow)
-                       
+                       MSG_WM_LBUTTONDBLCLK(OnLButtonDbClk)
+                       MSG_WM_LBUTTONDOWN(OnLButtonDown)
+                       MSG_WM_CREATE(OnCreate)
+                       MSG_WM_ERASEBKGND(OnEraseBkGnd)
+                       MSG_WM_PAINT(OnPaint)
                END_MSG_MAP()
 
 
@@ -50,9 +55,45 @@ namespace nlite{
                ///
                ///\83R\83\93\83X\83g\83\89\83N\83^
                ///
-               CCommentListWindow(CCommentView &self);
+               CCommentListWindow(CCommentView &self_in);
+
+
+               ///
+               ///\95`\89æ\8f\88\97\9d
+               ///
+               VOID DoPaint(CDCHandle dc);
+
+               //\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
+       private:
+
+
+               //\83\81\83b\83Z\81[\83W\83n\83\93\83h\83\89
+       private:
+               
+               ///
+               ///\83E\83B\83\93\83h\83E\8dì\90¬\8e\9e\82Ì\8f\88\97\9d
+               ///
+               LRESULT OnCreate(LPCREATESTRUCT lpCreateStruct);
+
+               ///
+               ///\83}\83E\83X\83N\83\8a\83b\83N\8e\9e\82Ì\8f\88\97\9d
+               ///
+               VOID OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point);
 
+               ///
+               ///\95`\89æ\8f\88\97\9d
+               ///
+               VOID OnPaint(HDC hdc);
+
+               ///
+               ///\83}\83E\83X\83_\83u\83\8b\83N\83\8a\83b\83N\8e\9e\82Ì\8f\88\97\9d
+               ///
+               VOID OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point);
 
+               ///
+               ///\94w\8ci\93h\82è\82Â\82Ô\82µ
+               ///
+               LRESULT OnEraseBkGnd(HDC lparam);
        };
        
        class CCommentView:public CWindowImpl<CCommentView>{
@@ -70,29 +111,7 @@ namespace nlite{
                }HEADERSINFO,*LPHEADERSINFO;
 
                
-               //\83R\83\81\83\93\83g\95\\8e¦\83E\83B\83\93\83h\83E\82Ì\83x\81[\83X\82Æ\82È\82é\83E\83B\83\93\83h\83E
-               class CCommentListBaseWindow:public CWindowImpl<CCommentListBaseWindow>{
-
-
-
-               public:
-                       //
-                       //\83E\83B\83\93\83h\83E\83N\83\89\83X\90é\8c¾
-                       //
-                       DECLARE_WND_CLASS_EX(commentViewConstant::NLITE_COMMENTLISTBASE,0,COLOR_BACKGROUND)
-
-                       BEGIN_MSG_MAP(CCommentListBaseWindow)
-                       
-                               MSG_WM_ERASEBKGND(OnEraseBkgnd)
-                       
-                       END_MSG_MAP()
-
-                       LRESULT OnEraseBkgnd(HDC wParam){
-
-                               return TRUE;
-                       }
-
-               };
+               
 
                
 
@@ -157,7 +176,6 @@ namespace nlite{
                        MSG_WM_MEASUREITEM(OnMeasureItem)
                        MSG_WM_SIZING(OnSizing)
                        MSG_WM_SIZE(OnSize)
-                       MSG_WM_PAINT(OnPaint)
                        MSG_WM_HSCROLL(OnHScroll)
                        MSG_WM_ERASEBKGND(OnEraseBkgnd)
                        COMMAND_CODE_HANDLER_EX(LBN_DBLCLK,OnListBoxDoubleClick)
@@ -239,11 +257,6 @@ namespace nlite{
 
                //\83E\83B\83\93\83h\83E\83\81\83b\83Z\81[\83W\83n\83\93\83h\83\89
        private:
-               
-               ///
-               ///\94w\8ci\95`\89æ\8f\88\97\9d
-               ///
-               VOID OnPaint(HDC wParam);
 
                ///
                ///\83T\83C\83Y\95Ï\8dX\92\86\8f\88\97\9d