OSDN Git Service

エラー処理途中まで
[nlite/nlite.git] / nlite / nlite_mainframe.cpp
index 0d728a3..7577e4b 100644 (file)
 #include "stdafx.h"
+
 #include "nlite_include.h"
 
-using namespace nlite;
 
+namespace nlite{
 
 static const RECT commentViewSize = {5,0,5,0};
 
+///
+///\92è\90\94
+///
+enum{
+       IDC_COMBO_REBAR = 301,
+       IDC_COMBO_TITLE = 302
+};
+
+
+
+///
+///\83E\83B\83\93\83h\83E\8dÅ\92á\83T\83C\83Y
+///
+const static SIZE lowestFrameSize = {300,300};
+
+
+
+CNliteMainFrame::~CNliteMainFrame(){
+
+       DeleteObject(hTabFont);
+}
+
+CNliteMainFrame::CNliteMainFrame()
+       :userData(*this),
+       subLiveNoComboBox(*this),
+       commentWriteWindow(nicoLiveStream),
+       commentView(nicoLiveStream,nicoVideoAuth)
+{
+       LOGFONT lf = {0};
+
+       lf.lfHeight = 10;
+       lf.lfCharSet = SHIFTJIS_CHARSET;
+       hTabFont = CreateFontIndirect(&lf);
+}
 
 
+// \83\81\83b\83Z\81[\83W\83t\83B\83\8b\83^\8f\88\97\9d
+BOOL CNliteMainFrame::PreTranslateMessage(MSG* pMsg){
+       // \8aî\92ê\83N\83\89\83X\82ÌPreTranslateMessage\82ð\8cÄ\82Ñ\8fo\82·
+       return CFrameWindowImpl<CNliteMainFrame>::PreTranslateMessage(pMsg);
+}
+
+// \83A\83C\83h\83\8b\8f\88\97\9d
+BOOL CNliteMainFrame::OnIdle(){
+       return FALSE;
+}
 
 //\83T\83C\83Y\95Ï\8dX\8f\88\97\9d
 VOID CNliteMainFrame::ChangeSize(const SIZE& client){
 
        
+       UINT_PTR tabheight = client.cy - (toolBarHeight + statusBarHeight + commentWriteWindow.GetHeight());
 
        
-       
-       tabctrl.MoveWindow(0,toolBarHeight,client.cx,client.cy - (toolBarHeight + statusBarHeight + commentWriteWindowSize.cy));
-       
+       RECT tabWindowRect = {0};
+       RECT commentViewRect = {0};
+       RECT commentWriteWindowRect = {0};
 
-       RECT tabClientRect;
-       tabctrl.GetClientRect(&tabClientRect);
-       tabctrl.AdjustRect(FALSE,&tabClientRect);
 
+       tabWindowRect.left = 0;
+       tabWindowRect.top = toolBarHeight;
+       tabWindowRect.right =  client.cx - tabWindowRect.left;
+       tabWindowRect.bottom = tabWindowRect.top + tabheight;
        
        
+       commentWriteWindowRect.left = 0;
+       commentWriteWindowRect.top = tabWindowRect.bottom;
+       commentWriteWindowRect.right = commentWriteWindowRect.left + client.cx;
+       commentWriteWindowRect.bottom = commentWriteWindowRect.top + commentWriteWindow.GetHeight();
 
-       commentView.MoveWindow(tabClientRect.left, tabClientRect.top,tabClientRect.right - tabClientRect.left, tabClientRect.bottom - tabClientRect.top);
 
-       commentWriteWindow.MoveWindow(0,client.cy - (commentWriteWindowSize.cy + statusBarHeight),client.cx,client.cy);
        
 
+       tabctrl.MoveWindow(tabWindowRect.left,tabWindowRect.top,tabWindowRect.right - tabWindowRect.left ,tabWindowRect.bottom - tabWindowRect.top);
+       
+       
+       tabctrl.GetClientRect(&commentViewRect);
+       tabctrl.AdjustRect(FALSE,&commentViewRect);
 
+       commentView.MoveWindow(commentViewRect.left, commentViewRect.top,commentViewRect.right - commentViewRect.left, commentViewRect.bottom - commentViewRect.top);
+
+       commentWriteWindow.MoveWindow(commentWriteWindowRect.left,commentWriteWindowRect.top,commentWriteWindowRect.right - commentWriteWindowRect.left ,commentWriteWindowRect.bottom - commentWriteWindowRect.top);
+       commentWriteWindow.Invalidate();
+       ::InvalidateRect(m_hWndStatusBar,NULL,TRUE);
+
+//     tabctrl.SetWindowPos(*this,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+//     commentWriteWindow.SetWindowPos(*this,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
        return;
 }
 
-LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
+LRESULT CNliteMainFrame::OnCbSelChange(UINT hiWparam,int loWparam,HWND lParam){
 
+       if(lParam == this->lvNoCombo){
+               INT_PTR cursel = this->lvNoCombo.GetCurSel();
+               if(cursel == CB_ERR)goto end;
+               auto it = this->subLiveNoComboBox.liveInfoList.begin();
+               std::advance(it,cursel);
+               this->ConnectNicoLive(it->second);
+
+       }
+
+end:
+
+       return 0;
+}
 
+LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
+
+       
        // \83X\83e\81[\83^\83X\83o\81[\82ð\8dì\90¬
-       vcverify(CreateSimpleStatusBar(),TEXT("\83X\83e\81[\83^\83X\83o\81[\8dì\90¬\82É\8e¸\94s\82µ\82Ü\82µ\82½"));
-       tabctrl.Create(m_hWnd,0,NULL,WS_CHILD | WS_CLIPCHILDREN  | WS_DLGFRAME);
+       m_hWndStatusBar = m_hStatusBar.Create(*this);
+       UIAddStatusBar(m_hWndStatusBar);
+       // \83X\83e\81[\83^\83X\83o\81[\82É\83y\83C\83\93\82ð\90Ý\92è
+       //INT_PTR nPanes[] = {ID_DEFAULT_PANE, IDS_PANE_TIME};
+       //m_hStatusBar.SetPanes(nPanes, sizeof(nPanes)/sizeof(nPanes[0]));
+       //progresBar.Create(m_hWnd,0,NULL,);
+       //m_hStatusBar.SetClipboardViewer
+       tabctrl.Create(m_hWnd,0,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_DLGFRAME );
        commentView.Create(tabctrl.m_hWnd);
        
-       commentWriteWindow.Create(m_hWnd,0,NULL,WS_CHILD | WS_VISIBLE);
-       
+       commentWriteWindow.Create(m_hWnd,0,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN  );
        CreateSimpleReBar();
        HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd,IDC_NLITE, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
-       lvNoCombo.Create(m_hWnd, CRect(0, 0, 100, 100), NULL,WS_CHILD | WS_VISIBLE | WS_VSCROLL  | CBS_DROPDOWN , 0, IDC_COMBO_REBAR);
-
+       lvNoCombo.Create(m_hWnd, CRect(0, 0, 100, 100), NULL,WS_CHILD | WS_VISIBLE | WS_VSCROLL  | CBS_DROPDOWN | CBS_AUTOHSCROLL, 0, IDC_COMBO_REBAR);
+       lvNoCombo.LimitText(LENGTH_512);
 
        subLiveNoComboBox.SubclassWindow(lvNoCombo.GetEditCtrl());
        lvNoCombo.SetFont(AtlGetDefaultGuiFont());
        
        
 
-       AddSimpleReBarBand(hWndToolBar);
+       //AddSimpleReBarBand(hWndToolBar);
        AddSimpleReBarBand(lvNoCombo,TEXT("\95ú\91\97URL"));
        SizeSimpleReBarBands();
        
+       //tabctrl.SetWindowPos(*this,0,0,0,0,SWP_SHOWWINDOW);
        
-
-       tabctrl.SetFont(hTabFont);      
-       tabctrl.SetWindowPos(HWND_BOTTOM,0,0,0,0,SWP_SHOWWINDOW);
+       tabctrl.SetFont(hTabFont);
        tabctrl.AddItem(TCIF_TEXT | TCIF_PARAM, _T("\83R\83\81\83\93\83g\88ê\97\97"), 0, (DWORD)commentView.m_hWnd);
 
        
@@ -85,63 +167,556 @@ LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
        ::GetClientRect(m_hWndStatusBar,&statusbarRect);
 
        statusBarHeight = statusbarRect.bottom - statusbarRect.top;
-
+       
        
 
        this->MoveWindow(wndRect.left,wndRect.top,wndRect.right,wndRect.bottom);
        
+       listenerSettingWindow.Create(*this);
+       
+
+       return 0;
+}
+
+
+
+VOID CNliteMainFrame::Initialize(LPCTSTR localAppDataPath){
+
+       try{
+               nliteProperty.ReadProperty();
+
+       
+               if((nliteProperty.gp.ncvUserSettingReadedFlag == FALSE) && 
+                       ((PathFileExists(ncvAppSettingPath) &&  (!::PathIsDirectory( ncvAppSettingPath ))))){
+               
+                       if((::MessageBox(NULL,TEXT("NCV\82Ì\83\8a\83X\83i\81[\8fî\95ñ\82Æ\93¯\8aú\82µ\82Ü\82·\82©\81H"),TEXT("\83\8a\83X\83i\81[\8fî\95ñ\93Ç\82Ý\8d\9e\82Ý"),MB_OK | MB_OKCANCEL) == IDOK)){
+                               listenerList.ReadProperty(GetNCVListenerInfoFilePath());
+                       }
+                       nliteProperty.gp.ncvUserSettingReadedFlag = TRUE;
+               
+
+                       
+                       
+               }
+
+               listenerList.ReadProperty(nliteProperty.listenerDataPath);
+
+               commentView.SetProperty(nliteProperty.cvp,nliteProperty.gp);
+               if(nliteProperty.gp.browserType == BT_NOSETTING){
+                       nliteProperty.CookieSetting();
+                       while(nliteProperty.gp.browserType == BT_NOSETTING){
+                               ::MessageBox(NULL,TEXT("\83u\83\89\83E\83U\83^\83C\83v\82ð\8ew\92è\82µ\82Ä\82­\82¾\82³\82¢\81B\82±\82ê\88È\8aO\82Ì\83u\83\89\83E\83U\82Í\8c»\8dÝ\8eg\97p\82·\82é\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ"),TEXT("\83u\83\89\83E\83U\83^\83C\83v\8ew\92è\83G\83\89\81["),MB_OK);
+                               nliteProperty.CookieSetting();
+                       }
+               }
+                       
+               nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
+               nicoLiveStream.SetResFrom(200);
+       }catch(Exception &e){
+
+               ::MessageBox(NULL,e.what(),TEXT("\90Ý\92è\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81["),MB_OK | MB_ICONERROR);
+
+       }
+       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
+       return;
+                       
+}
+
+VOID CNliteMainFrame::OnClose(){
+       this->ShowWindow(SW_HIDE);
+       nicoLiveStream.DisConnect();
+       this->DestroyWindow();
+       
+       return;
+}
+
+VOID CNliteMainFrame::OnDestroy(){
+       
+       commentView.DestroyWindow();
+                       
+       PostQuitMessage(0);
+       return;
+}
+
+
+VOID CNliteMainFrame::OnException(){
+
+       nicoLiveStream.DisConnect();
+
+}
+
+//\83\81\83j\83\85\81[\82©\82ç\83t\83@\83C\83\8b\82ð\8fI\97¹\82ð\91I\91ð
+VOID CNliteMainFrame::OnMenuExit(UINT uNotifyCode, int nID, HWND hWndCtl){
+       PostMessage(WM_CLOSE);
+}
+
+//\83\81\83j\83\85\81[\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83o\81[\83W\83\87\83\93\8fî\95ñ\95\\8e¦
+VOID CNliteMainFrame::OnMenuAbount(UINT uNotifyCode,int nID,HWND hWndCtl){
+       appInfo->show();
+}
+
+VOID CNliteMainFrame::Finalaize(){
+
+       nliteProperty.cvp = commentView.GetProperty();
+       nliteProperty.WriteProperty();
+       listenerList.WriteProperty(nliteProperty.listenerDataPath);
+}
+
+VOID CNliteMainFrame::OnViewPreference(UINT uNotifyCode,int nID,HWND hWndCtl){
+
+       //ViewerPropertyWindow propetyWindow(TEXT("\83r\83\85\81[\83A\90Ý\92è"));
+       
+       //propetyWindow.DoModal();
+
+       return;
+}
+
+LRESULT CNliteMainFrame::OnUnlockLvNoBuffer(UINT uMsg,WPARAM wParam,LPARAM lParam){
+       this->lvNoBufCS.Unlock();
+       return 0;
+}
+
+//\83N\83b\83L\81[\82Ì\90Ý\92è
+VOID CNliteMainFrame::OnCookie(UINT uNotifyCode,int nID,HWND hWndCtl){
+       nliteProperty.CookieSetting();
+                       
+       while(nliteProperty.gp.browserType == BT_NOSETTING){
+               ::MessageBox(NULL,TEXT("\83u\83\89\83E\83U\83^\83C\83v\82ð\8ew\92è\82µ\82Ä\82­\82¾\82³\82¢\81B\82±\82ê\88È\8aO\82Ì\83u\83\89\83E\83U\82Í\8c»\8dÝ\8eg\97p\82·\82é\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ"),TEXT("\83u\83\89\83E\83U\83^\83C\83v\8ew\92è\83G\83\89\81["),MB_OK);
+               nliteProperty.CookieSetting();
+       }
+                       
+
+       nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
+
        
+
+}
+
+
+
+VOID CNliteMainFrame::ConnectingThread(LPVOID userData){
+
+       auto &self = *(CNliteMainFrame*)userData;
+       CString lvNoString = self.lvNoBuffer;
+       self.SendMessage(UM_UNLOCK_LVNOBUFFER,(WPARAM)0,(LPARAM)0);
+       try {
+               self.nicoLiveStream.DisConnect();
+               self.commentView.OnConnect();
+               
+       
+               NLIB_RESULT code = self.nicoLiveStream.Connect(self.nicoVideoAuth,lvNoString,LiveCallBack,&self.userData);
+
+               //\83G\83\89\81[\83R\81[\83h\8f\88\97\9d
+               switch(code){
        
+                       //\90³\8fí\8fI\97¹
+               case NLIB_ERR_OK:
+
+                       
+                       goto end;
+
+                       //\91z\92è\82³\82ê\82½\83G\83\89\81[\83R\81[\83h
+               case NLIB_ERR_COOKIE_FAILED:
+               case NLIB_LIVENO_FAILED_UNDEFEINE:
+               case NLIB_FAILED_CONNECT:
+               case NLIB_ERR_GETPLAYERSTATUS_INVALID_LV:
+               case NLIB_ERR_GETPLAYERSTATUS_INVALID_THREAD:
+               case NLIB_ERR_GETPLAYERSTATUS_CLOSED:
+               case NLIB_ERR_GETPLAYERSTATUS_UNKNOWN_ERROR:
+               case NLIB_ERR_GETPLAYERSTATUS_SERVER_ERROR:
+               case NLIB_ERR_GETPLAYERSTATUS_DELETED:
+               case NLIB_ERR_GETPLAYERSTATUS_FULL:
+               case NLIB_ERR_GETPLAYERSTATUS_PERMISSION_DENIED:
+               case NLIB_ERR_GETPLAYERSTATUS_ACCESS_LOCKED:
+               case NLIB_ERR_GETPLAYERSTATUS_REQUIRE_COMMUNITY_MEMBER:
+               case NLIB_ERR_GETPLAYERSTATUS_COMINGSOON:
+               case NLIB_ERR_GETPLAYERSTATUS_NOTFOUND:
+               case NLIB_ERR_GETPLAYERSTATUS_NOTLOGIN:
+               case NLIB_ERR_GETPLAYERSTATUS_UNKNOWN:
+               case NLIB_ERR_GETPLAYERSTATUS_MAINTENANCE:
+               case NLIB_ERR_GETPLAYERSTATUS_NOT_PERMITTED:
+               case NLIB_ERR_GETPLAYERSTATUS_REQUIRE_ACCEPT_PRINT_TIMESHIFT_TICKET:
+               case NLIB_ERR_GETPLAYERSTATUS_TSARCHIVE:
+               case NLIB_ERR_GETPLAYERSTATUS_USERTIMESHIFT:
+               case NLIB_ERR_GETPLAYERSTATUS_UNDEFINED:
+               case NLIB_ERR_GETPLAYERSTATUS_NOAUTH:
+               case NLIB_ERR_GETPLAYERSTATUS_CHANT_PARSE:
+               case NLIB_ERR_GETPLAYERSTATUS_BLOCK_NOW_COUNT_OVERFLOW:
+
+
+                       
+                       ::MessageBox(self,NLIB_GetErrorMessage(code),TEXT("\95ú\91\97\90Ú\91±\83G\83\89\81["),MB_ICONERROR | MB_OK);
+
+                       break;
+
+
+                       //\91z\92è\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81[\83R\81[\83h
+               default:
+               
+                       UnexpectedErrorMessageShow( TEXT("\95ú\91\97\90Ú\91±\92\86\82É"),NLIB_GetErrorMessage(code),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
+
+               
+                       break;
+
+               }
+               self.subLiveNoComboBox.AgreeInputLvNo();
+               
+
+       } catch(nlib::Exception &e){
+
+               UnexpectedErrorMessageShow( TEXT("\95ú\91\97\90Ú\91±\92\86\82É"),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
+
+       }
+end:
+       
+       self.subLiveNoComboBox.AgreeInputLvNo();
+       _endthread();
+       return;
+}
+
+
+BOOL CNliteMainFrame::ConnectNicoLive(LPCTSTR liveNo){
+       
+       lvNoCombo.GetEditCtrl().SetReadOnly(TRUE);
+       subLiveNoComboBox.untilConnectingFlag = TRUE;
+       EnableWindow(FALSE);
+       lvNoBufCS.Lock();
+       this->lvNoBuffer = liveNo;
+       _beginthread(CNliteMainFrame::ConnectingThread,0,this);
+
+       
+
+
+       return TRUE;
+
+}
+
+
+//\83T\83C\83Y\95Ï\8dX\8cã
+LRESULT CNliteMainFrame::OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
+
+
+       SIZE clientSize;
+       clientSize.cx = LOWORD(lParam);
+       clientSize.cy = HIWORD(lParam);
+       ChangeSize(clientSize);
+
+       bHandled = FALSE;
+                       
+                       
 
        return 0;
 }
 
+
+///
+///\83T\83C\83Y\95Ï\8dX\92\86\8f\88\97\9d
+///
+VOID CNliteMainFrame::OnSizing(UINT wParam,LPRECT lParam){
+                       
+       if(lParam->right - lParam->left < lowestFrameSize.cx){
+               lParam->right = lParam->left + lowestFrameSize.cx;
+       }
+
+       if(lParam->bottom - lParam->top < lowestFrameSize.cy){
+
+               lParam->bottom = lParam->top + lowestFrameSize.cy;
+       }
+                       
+}
+
+
+//\83c\81[\83\8b\83o\81[\8d\82\82³\95Ï\8dX
+LRESULT CNliteMainFrame::OnRbnHeightChange(INT_PTR wParam,LPNMHDR lParam,BOOL &bHandled){
+
+       RECT toolbarRect;
+       ::GetClientRect(m_hWndToolBar,&toolbarRect);
+       toolBarHeight = toolbarRect.bottom - toolbarRect.top;
+
+       RECT client;
+       GetClientRect(&client);
+
+       ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
+
+
+
+       return 0;
+}
+
+LRESULT CNliteMainFrame::OnUpDateUI(UINT uMsg,WPARAM wParam,LPARAM lParam){
+
+
+       commentView.UpDateUI();
+
+       return 0;
+}
+
+LRESULT CNliteMainFrame::OnClickChatNo(UINT uMsg,WPARAM wParam,LPARAM lParam){
+
+       auto &chatData = *(CChatData*)wParam;
+       CString setString;
+       if(chatData.listenerData->name.Length() == 0){
+               setString.Format(TEXT(">>%d "),chatData.no);
+       }else{
+               setString.Format(TEXT(">>%s "),chatData.listenerData->name);
+       }
+
+       this->commentWriteWindow.SetText(setString);
+
+       return 0;
+
+}
+
+LRESULT CNliteMainFrame::OnClickUserName(UINT uMsg,WPARAM wParam,LPARAM lParam){
+
+       auto &chatData = *(CChatData*)wParam;
+       listenerSettingWindow.ShowSettingWindow(*chatData.listenerData);
+
+
+       return 0;
+}
+
+
 NLIB_RESULT CNliteMainFrame::LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2){
 
        CLiveUserData &userData = (*(CLiveUserData*)option);
 
        try{
+               
+
                switch(eventType){
 
                case NICOLIVE_EVENT_RECEVE_CONNECTRESULT:
 
-                       userData.OnConnect();
+                       userData.OnChatReceveStart(userData.self.nicoLiveStream,(NicoLiveThreadComment_P)param1);
 
                        break;
 
                case NICOLIVE_EVENT_RECEVE_CHAT:
 
+                       userData.OnChatReceve((NicoLiveChat_P) param1,param2);
 
                        break;
 
                case NICOLIVE_EVENT_RECEVE_CHATSETTLE:
 
+                       userData.OnChatReceveSettle(param1,param2);
+
                        break;
 
                case NICOLIVE_EVENT_RECEVE_CHATSENDRESULT:
 
+                       userData.OnChatSendResult(reinterpret_cast<NicoLiveSendResultComment_P>(param1));
+
                        break;
 
                case NICOLIVE_EVENT_SEND_HEARTBEAT:
 
+                       userData.OnHeartBeat(reinterpret_cast<NicoLiveHeartBeat_P>(param1));
+
+                       break;
+
+
+               case NICOLIVE_EVENT_DISCONNECT:
+
+                       userData.OnDisconnect();
+
                        break;
 
                case NICOLIVE_EVENT_ERR_CONNECT:
 
-                       throw NLiveException(TEXT("\90Ú\91±\83G\83\89\81[\82Å\82·"),__LINE__,TEXT(__FILE__));
+                       throw NLiveException(TEXT("\90Ú\91±\83G\83\89\81[\82Å\82·"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
 
                        break;
 
                default:
 
-                       throw NLiveException(TEXT("\97\\8aú\82µ\82È\82¢\83\81\83b\83Z\81[\83W\82ª\91\97\90M\82³\82ê\82Ü\82µ\82½"),__LINE__,TEXT(__FILE__));
+                       throw NLiveException(TEXT("\97\\8aú\82µ\82È\82¢\83\81\83b\83Z\81[\83W\82ª\91\97\90M\82³\82ê\82Ü\82µ\82½"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
 
                        break;
                }
-       } catch(Exception e){
 
-               ::MessageBox(NULL,e.what(),TEXT("\83j\83R\90\83G\83\89\81["),MB_OK | MB_ICONSTOP | MB_TASKMODAL);
+       } catch(Exception e){
+               UnexpectedErrorMessageShow(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
+       
+       } catch(std::exception e){
+               UnexpectedErrorMessageShow(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\95s\96¾\82Ì\83G\83\89\81["),CComBSTR(e.what()),-1,TEXT("\94­\90\83t\83@\83C\83\8b\82ª\93Á\92è\8fo\97\88\82Ü\82¹\82ñ"),TEXT("\94­\90\8aÖ\90\94\82ª\93Á\92è\82Å\82«\82Ü\82¹\82ñ"));
        }
+       
+
+       
 
        return NLIB_ERR_OK;
+}
+
+
+LRESULT CNliteMainFrame::OnSetCursor(LRESULT msg,WPARAM wParam,LPARAM lParam,BOOL &bHandled){
+
+       
+       BOOL rslt = FALSE;
+       
+       if(this->subLiveNoComboBox.untilConnectingFlag == TRUE || this->commentWriteWindow.IsWrighthing() == TRUE){
+               
+               if(this->subLiveNoComboBox.untilConnectingFlag == TRUE){
+                       ::SetCursor(::LoadCursorW(NULL,IDC_WAIT));
+               } else if(this->commentWriteWindow.IsWrighthing() == TRUE){
+                       ::SetCursor(::LoadCursorW(NULL,IDC_APPSTARTING));
+               }
+               bHandled = TRUE;
+               rslt = TRUE;
+       
+
+
+
+       } else {
+               bHandled = FALSE;
+       }
+       
+
+       return TRUE;
+
+}
+
+
+//
+//CSubLiveNoComboBox
+////////////////////////////////////
+
+CNliteMainFrame::CSubLiveNoComboBox::CSubLiveNoComboBox(CNliteMainFrame &in_self):self(in_self),untilConnectingFlag(FALSE){}
+
+static VOID AgreeEnterKeyThread(LPVOID userData){
+
+       Sleep(1000);
+       auto noCombo = (CNliteMainFrame::CSubLiveNoComboBox*) userData;
+       noCombo->AgreeInputLvNo();
+
+       return;
+}
+
+VOID CNliteMainFrame::CSubLiveNoComboBox::OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
+       if(wParam == VK_RETURN){
+                                       
+               cs.Lock();
+                                       
+               //INT_PTR no = self.lvNoCombo.GetCurSel();
+               if(untilConnectingFlag == FALSE){
+                       
+                       std::vector<TCHAR> buffer(this->GetWindowTextLengthW() + 1); 
+                       ::GetWindowTextW(this->m_hWnd,&buffer[0],buffer.size());
+                       
+                       
+                       self.ConnectNicoLive(&buffer[0]);
+               }
+                                       
+               cs.Unlock();
+                                       
+                                       
+       }
+       return;
+}
+
+LRESULT CNliteMainFrame::CSubLiveNoComboBox::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
+
+
+       return FALSE;
+}
+
+
+
+VOID CNliteMainFrame::CSubLiveNoComboBox::AddLiveInfo(CNicoLiveStream &stream,LvnoSearchFunctional &functional){
+       
+       CNLiteString dispComboString;
+       dispComboString += stream.GetId();
+       dispComboString += TEXT("\81@-");
+       dispComboString += stream.GetDefaultCommunity();
+       dispComboString += TEXT("\81@title\81F");
+       dispComboString += stream.GetTitle();
+
+       if(std::find_if(liveInfoList.begin(),liveInfoList.end(),functional) == liveInfoList.end()){
+               liveInfoList.push_back(LiveInfo(dispComboString,stream.GetId()));
+               
+               self.lvNoCombo.InsertItem(self.lvNoCombo.GetCount(),dispComboString,0,0,0,0);
+       
+       } 
+       functional.dispData = dispComboString;
+
+       
+
+
+       return;
+}
+
+
+VOID CNliteMainFrame::CSubLiveNoComboBox::AgreeInputLvNo(){
+       cs.Lock();
+       self.lvNoCombo.GetEditCtrl().SetReadOnly(FALSE);
+       self.EnableWindow(TRUE);
+       untilConnectingFlag = FALSE;
+       POINT mousePoint;
+       ::GetCursorPos(&mousePoint);
+       ::SetCursorPos(mousePoint.x,mousePoint.y);
+       cs.Unlock();
+}
+
+
+//
+//CLiveUserData
+/////////////////////////////////////////////////////////////////////////
+
+CNliteMainFrame::CLiveUserData::CLiveUserData(CNliteMainFrame &self):self(self)
+{}
+
+
+
+VOID CNliteMainFrame::CLiveUserData::OnConnect(){
+
+       self.commentView.OnConnect();
+
+}
+
+
+VOID CNliteMainFrame::CLiveUserData::OnChatReceveStart(CNicoLiveStream &stream,NicoLiveThreadComment_P threadComment){
+       
+       LvnoSearchFunctional functional(stream.GetId());
+       self.commentWriteWindow.OnChatReceveStart(stream,threadComment);
+       self.subLiveNoComboBox.AddLiveInfo(stream,functional);
+       self.subLiveNoComboBox.SetWindowText(functional.dispData);
+       self.subLiveNoComboBox.AgreeInputLvNo();
+       
+       return;
+}
+
+VOID CNliteMainFrame::CLiveUserData::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
+
+       self.commentView.OnChatReceve(chat,count);
+
+}
+
+VOID CNliteMainFrame::CLiveUserData::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
+
+       self.commentView.OnChatReceveSettle(commentCount,commentCountSum);
+       
+       return;
+}
+
+VOID CNliteMainFrame::CLiveUserData::OnChatSendResult(NicoLiveSendResultComment_P sendResult){
+       self.commentWriteWindow.OnSendChatResult();
+       return;
+}
+
+
+VOID CNliteMainFrame::CLiveUserData::OnHeartBeat(NicoLiveHeartBeat_P heartBeat){
+
+       self.commentWriteWindow.OnHeartBeat(heartBeat);
+
+       return;
+}
+
+
+
+VOID CNliteMainFrame::CLiveUserData::OnDisconnect(){
+       self.commentWriteWindow.OnDisConnect();
+       return;
+}
+
 }
\ No newline at end of file