OSDN Git Service

名前登録機能追加
[nlite/nlite.git] / nlite / nlite_mainframe.cpp
1 #include "stdafx.h"
2
3 #include "nlite_include.h"
4
5
6 namespace nlite{
7
8 static const RECT commentViewSize = {5,0,5,0};
9
10 ///
11 ///\92è\90\94
12 ///
13 enum{
14         IDC_COMBO_REBAR = 301,
15         IDC_COMBO_TITLE = 302
16 };
17
18
19
20 ///
21 ///\83E\83B\83\93\83h\83E\8dÅ\92á\83T\83C\83Y
22 ///
23 const static SIZE lowestFrameSize = {300,300};
24
25
26
27 CNliteMainFrame::~CNliteMainFrame(){
28
29         DeleteObject(hTabFont);
30 }
31
32 CNliteMainFrame::CNliteMainFrame()
33         :userData(*this),
34         subLiveNoComboBox(*this),
35         commentWriteWindow(nicoLiveStream),
36         commentView(nicoLiveStream,nicoVideoAuth)
37 {
38         LOGFONT lf = {0};
39
40         lf.lfHeight = 10;
41         lf.lfCharSet = SHIFTJIS_CHARSET;
42         hTabFont = CreateFontIndirect(&lf);
43 }
44
45
46 // \83\81\83b\83Z\81[\83W\83t\83B\83\8b\83^\8f\88\97\9d
47 BOOL CNliteMainFrame::PreTranslateMessage(MSG* pMsg){
48         // \8aî\92ê\83N\83\89\83X\82ÌPreTranslateMessage\82ð\8cÄ\82Ñ\8fo\82·
49         return CFrameWindowImpl<CNliteMainFrame>::PreTranslateMessage(pMsg);
50 }
51
52 // \83A\83C\83h\83\8b\8f\88\97\9d
53 BOOL CNliteMainFrame::OnIdle(){
54         return FALSE;
55 }
56
57 //\83T\83C\83Y\95Ï\8dX\8f\88\97\9d
58 VOID CNliteMainFrame::ChangeSize(const SIZE& client){
59
60         
61         UINT_PTR tabheight = client.cy - (toolBarHeight + statusBarHeight + commentWriteWindow.GetHeight());
62
63         
64         RECT tabWindowRect = {0};
65         RECT commentViewRect = {0};
66         RECT commentWriteWindowRect = {0};
67
68
69         tabWindowRect.left = 0;
70         tabWindowRect.top = toolBarHeight;
71         tabWindowRect.right =  client.cx - tabWindowRect.left;
72         tabWindowRect.bottom = tabWindowRect.top + tabheight;
73         
74         
75         commentWriteWindowRect.left = 0;
76         commentWriteWindowRect.top = tabWindowRect.bottom;
77         commentWriteWindowRect.right = commentWriteWindowRect.left + client.cx;
78         commentWriteWindowRect.bottom = commentWriteWindowRect.top + commentWriteWindow.GetHeight();
79
80
81         
82
83         tabctrl.MoveWindow(tabWindowRect.left,tabWindowRect.top,tabWindowRect.right - tabWindowRect.left ,tabWindowRect.bottom - tabWindowRect.top);
84         
85         
86         tabctrl.GetClientRect(&commentViewRect);
87         tabctrl.AdjustRect(FALSE,&commentViewRect);
88
89         commentView.MoveWindow(commentViewRect.left, commentViewRect.top,commentViewRect.right - commentViewRect.left, commentViewRect.bottom - commentViewRect.top);
90
91         commentWriteWindow.MoveWindow(commentWriteWindowRect.left,commentWriteWindowRect.top,commentWriteWindowRect.right - commentWriteWindowRect.left ,commentWriteWindowRect.bottom - commentWriteWindowRect.top);
92         commentWriteWindow.Invalidate();
93         ::InvalidateRect(m_hWndStatusBar,NULL,TRUE);
94
95 //      tabctrl.SetWindowPos(*this,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
96 //      commentWriteWindow.SetWindowPos(*this,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
97         return;
98 }
99
100 LRESULT CNliteMainFrame::OnCbSelChange(UINT hiWparam,int loWparam,HWND lParam){
101
102         if(lParam == this->lvNoCombo){
103                 INT_PTR cursel = this->lvNoCombo.GetCurSel();
104                 if(cursel == CB_ERR)goto end;
105                 auto it = this->subLiveNoComboBox.liveInfoList.begin();
106                 std::advance(it,cursel);
107                 this->ConnectNicoLive(it->second);
108
109         }
110
111 end:
112
113         return 0;
114 }
115
116 LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
117
118         
119         // \83X\83e\81[\83^\83X\83o\81[\82ð\8dì\90¬
120         m_hWndStatusBar = m_hStatusBar.Create(*this);
121         UIAddStatusBar(m_hWndStatusBar);
122         // \83X\83e\81[\83^\83X\83o\81[\82É\83y\83C\83\93\82ð\90Ý\92è
123         //INT_PTR nPanes[] = {ID_DEFAULT_PANE, IDS_PANE_TIME};
124         //m_hStatusBar.SetPanes(nPanes, sizeof(nPanes)/sizeof(nPanes[0]));
125         //progresBar.Create(m_hWnd,0,NULL,);
126         //m_hStatusBar.SetClipboardViewer
127         tabctrl.Create(m_hWnd,0,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_DLGFRAME );
128         commentView.Create(tabctrl.m_hWnd);
129         
130         commentWriteWindow.Create(m_hWnd,0,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN  );
131         CreateSimpleReBar();
132         HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd,IDC_NLITE, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
133         lvNoCombo.Create(m_hWnd, CRect(0, 0, 100, 100), NULL,WS_CHILD | WS_VISIBLE | WS_VSCROLL  | CBS_DROPDOWN | CBS_AUTOHSCROLL, 0, IDC_COMBO_REBAR);
134         lvNoCombo.LimitText(LENGTH_512);
135
136         subLiveNoComboBox.SubclassWindow(lvNoCombo.GetEditCtrl());
137         lvNoCombo.SetFont(AtlGetDefaultGuiFont());
138         
139         
140
141         //AddSimpleReBarBand(hWndToolBar);
142         AddSimpleReBarBand(lvNoCombo,TEXT("\95ú\91\97URL"));
143         SizeSimpleReBarBands();
144         
145         //tabctrl.SetWindowPos(*this,0,0,0,0,SWP_SHOWWINDOW);
146         
147         tabctrl.SetFont(hTabFont);
148         tabctrl.AddItem(TCIF_TEXT | TCIF_PARAM, _T("\83R\83\81\83\93\83g\88ê\97\97"), 0, (DWORD)commentView.m_hWnd);
149
150         
151                 
152         // \83\81\83b\83Z\81[\83W\83\8b\81[\83v\82É\83\81\83b\83Z\81[\83W\83t\83B\83\8b\83^\82Æ\83A\83C\83h\83\8b\83n\83\93\83h\83\89\82ð\92Ç\89Á
153         CMessageLoop* pLoop = _Module.GetMessageLoop();
154         pLoop->AddMessageFilter(this);
155         pLoop->AddIdleHandler(this);
156
157         RECT wndRect;
158         this->GetWindowRect(&wndRect);
159         
160         LONG cyMaxImized = GetSystemMetrics (SM_CYMAXIMIZED);
161         wndRect.bottom = nliteProperty.mfp.windowSize.cy != 0 ? nliteProperty.mfp.windowSize.cy : (LONG)cyMaxImized / 2;
162         wndRect.right = nliteProperty.mfp.windowSize.cx != 0 ? nliteProperty.mfp.windowSize.cx : commentViewSize.left + commentViewSize.right + 20 + commentView.GetColumnHolSizeSum();
163
164         
165
166         RECT statusbarRect;
167         ::GetClientRect(m_hWndStatusBar,&statusbarRect);
168
169         statusBarHeight = statusbarRect.bottom - statusbarRect.top;
170         
171         
172
173         this->MoveWindow(wndRect.left,wndRect.top,wndRect.right,wndRect.bottom);
174         
175         
176         
177
178         return 0;
179 }
180
181
182
183 VOID CNliteMainFrame::Initialize(LPCTSTR localAppDataPath){
184
185         try{
186                 nliteProperty.ReadProperty();
187
188         
189                 if((nliteProperty.gp.ncvUserSettingReadedFlag == FALSE) && 
190                         ((PathFileExists(ncvAppSettingPath) &&  (!::PathIsDirectory( ncvAppSettingPath ))))){
191                 
192                         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)){
193                                 listenerList.ReadProperty(GetNCVListenerInfoFilePath());
194                         }
195                         nliteProperty.gp.ncvUserSettingReadedFlag = TRUE;
196                 
197
198                         
199                         
200                 }
201
202                 listenerList.ReadProperty(nliteProperty.listenerDataPath);
203
204                 commentView.SetProperty(nliteProperty.cvp,nliteProperty.gp);
205                 if(nliteProperty.gp.browserType == BT_NOSETTING){
206                         nliteProperty.CookieSetting();
207                         while(nliteProperty.gp.browserType == BT_NOSETTING){
208                                 ::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);
209                                 nliteProperty.CookieSetting();
210                         }
211                 }
212                         
213                 nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
214                 nicoLiveStream.SetResFrom(200);
215         }catch(Exception &e){
216
217                 ::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);
218
219         }
220
221         return;
222                         
223 }
224
225 VOID CNliteMainFrame::OnClose(){
226         this->ShowWindow(SW_HIDE);
227         nicoLiveStream.DisConnect();
228         this->DestroyWindow();
229
230         return;
231 }
232
233 VOID CNliteMainFrame::OnDestroy(){
234         
235         commentView.DestroyWindow();
236                         
237         PostQuitMessage(0);
238         return;
239 }
240
241
242 VOID CNliteMainFrame::OnException(){
243
244         nicoLiveStream.DisConnect();
245
246 }
247
248 //\83\81\83j\83\85\81[\82©\82ç\83t\83@\83C\83\8b\82ð\8fI\97¹\82ð\91I\91ð
249 VOID CNliteMainFrame::OnMenuExit(UINT uNotifyCode, int nID, HWND hWndCtl){
250         PostMessage(WM_CLOSE);
251 }
252
253 //\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¦
254 VOID CNliteMainFrame::OnMenuAbount(UINT uNotifyCode,int nID,HWND hWndCtl){
255         appInfo->show();
256 }
257
258 VOID CNliteMainFrame::Finalaize(){
259
260         nliteProperty.cvp = commentView.GetProperty();
261         nliteProperty.WriteProperty();
262         listenerList.WriteProperty(nliteProperty.listenerDataPath);
263 }
264
265 VOID CNliteMainFrame::OnViewPreference(UINT uNotifyCode,int nID,HWND hWndCtl){
266
267         //ViewerPropertyWindow propetyWindow(TEXT("\83r\83\85\81[\83A\90Ý\92è"));
268         
269         //propetyWindow.DoModal();
270
271         return;
272 }
273
274 //\83N\83b\83L\81[\82Ì\90Ý\92è
275 VOID CNliteMainFrame::OnCookie(UINT uNotifyCode,int nID,HWND hWndCtl){
276         nliteProperty.CookieSetting();
277                         
278         while(nliteProperty.gp.browserType == BT_NOSETTING){
279                 ::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);
280                 nliteProperty.CookieSetting();
281         }
282                         
283
284         nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
285
286         
287
288 }
289
290
291
292 VOID CNliteMainFrame::ConnectingThread(LPVOID userData){
293
294         auto &self = *(CNliteMainFrame*)userData;
295         self.lvNoCombo.GetEditCtrl().SetReadOnly(TRUE);
296         self.subLiveNoComboBox.untilConnectingFlag = TRUE;
297         self.EnableWindow(FALSE);
298         Sleep(3000);
299         self.subLiveNoComboBox.AgreeInputLvNo();
300         _endthread();
301         return;
302 }
303
304
305 BOOL CNliteMainFrame::ConnectNicoLive(LPCTSTR liveNo){
306         
307
308         _beginthread(CNliteMainFrame::ConnectingThread,0,this);
309         BOOL rslt = FALSE;
310         try {
311                 nicoLiveStream.DisConnect();
312                 commentView.OnConnect();
313                 
314         
315                 NLIB_RESULT code = nicoLiveStream.Connect(nicoVideoAuth,liveNo,LiveCallBack,&userData);
316
317                 //\83G\83\89\81[\83R\81[\83h\8f\88\97\9d
318                 switch(code){
319         
320                         //\90³\8fí\8fI\97¹
321                 case NLIB_ERR_OK:
322
323                         rslt = TRUE;
324                         goto end;
325
326                         //\91z\92è\82³\82ê\82½\83G\83\89\81[\83R\81[\83h
327                 case NLIB_ERR_COOKIE_FAILED:
328                 case NLIB_LIVENO_FAILED_UNDEFEINE:
329                 case NLIB_GETPLAYERSTATUS_FAILED_CONNECT:
330                 case NLIB_ERR_GETPLAYERSTATUS_INVALID_LV:
331                 case NLIB_ERR_GETPLAYERSTATUS_INVALID_THREAD:
332                 case NLIB_ERR_GETPLAYERSTATUS_CLOSED:
333                 case NLIB_ERR_GETPLAYERSTATUS_UNKNOWN_ERROR:
334                 case NLIB_ERR_GETPLAYERSTATUS_SERVER_ERROR:
335                 case NLIB_ERR_GETPLAYERSTATUS_DELETED:
336                 case NLIB_ERR_GETPLAYERSTATUS_FULL:
337                 case NLIB_ERR_GETPLAYERSTATUS_PERMISSION_DENIED:
338                 case NLIB_ERR_GETPLAYERSTATUS_ACCESS_LOCKED:
339                 case NLIB_ERR_GETPLAYERSTATUS_REQUIRE_COMMUNITY_MEMBER:
340                 case NLIB_ERR_GETPLAYERSTATUS_COMINGSOON:
341                 case NLIB_ERR_GETPLAYERSTATUS_NOTFOUND:
342                 case NLIB_ERR_GETPLAYERSTATUS_NOTLOGIN:
343                 case NLIB_ERR_GETPLAYERSTATUS_UNKNOWN:
344                 case NLIB_ERR_GETPLAYERSTATUS_MAINTENANCE:
345                 case NLIB_ERR_GETPLAYERSTATUS_NOT_PERMITTED:
346                 case NLIB_ERR_GETPLAYERSTATUS_REQUIRE_ACCEPT_PRINT_TIMESHIFT_TICKET:
347                 case NLIB_ERR_GETPLAYERSTATUS_TSARCHIVE:
348                 case NLIB_ERR_GETPLAYERSTATUS_USERTIMESHIFT:
349                 case NLIB_ERR_GETPLAYERSTATUS_UNDEFINED:
350                 case NLIB_ERR_GETPLAYERSTATUS_NOAUTH:
351                 case NLIB_ERR_GETPLAYERSTATUS_CHANT_PARSE:
352
353                         
354                         ::MessageBox(*this,NLIB_GetErrorMessage(code),TEXT("\95ú\91\97\90Ú\91±\83G\83\89\81["),MB_ICONERROR | MB_OK);
355
356                         break;
357
358
359                         //\91z\92è\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81[\83R\81[\83h
360                 default:
361                 
362                         UnexpectedErrorMessageShow( TEXT("\95ú\91\97\90Ú\91±\92\86\82É"),NLIB_GetErrorMessage(code),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
363
364                 
365                         break;
366
367                 }
368                 this->subLiveNoComboBox.AgreeInputLvNo();
369                 rslt = FALSE;
370
371         } catch(nlib::Exception &e){
372
373                 UnexpectedErrorMessageShow( TEXT("\95ú\91\97\90Ú\91±\92\86\82É"),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
374
375         }
376 end:
377
378
379         return rslt;
380
381 }
382
383
384 //\83T\83C\83Y\95Ï\8dX\8cã
385 LRESULT CNliteMainFrame::OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
386
387
388         SIZE clientSize;
389         clientSize.cx = LOWORD(lParam);
390         clientSize.cy = HIWORD(lParam);
391         ChangeSize(clientSize);
392
393         bHandled = FALSE;
394                         
395                         
396
397         return 0;
398 }
399
400
401 ///
402 ///\83T\83C\83Y\95Ï\8dX\92\86\8f\88\97\9d
403 ///
404 VOID CNliteMainFrame::OnSizing(UINT wParam,LPRECT lParam){
405                         
406         if(lParam->right - lParam->left < lowestFrameSize.cx){
407                 lParam->right = lParam->left + lowestFrameSize.cx;
408         }
409
410         if(lParam->bottom - lParam->top < lowestFrameSize.cy){
411
412                 lParam->bottom = lParam->top + lowestFrameSize.cy;
413         }
414                         
415 }
416
417
418 //\83c\81[\83\8b\83o\81[\8d\82\82³\95Ï\8dX
419 LRESULT CNliteMainFrame::OnRbnHeightChange(INT_PTR wParam,LPNMHDR lParam,BOOL &bHandled){
420
421         RECT toolbarRect;
422         ::GetClientRect(m_hWndToolBar,&toolbarRect);
423         toolBarHeight = toolbarRect.bottom - toolbarRect.top;
424
425         RECT client;
426         GetClientRect(&client);
427
428         ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
429
430
431
432         return 0;
433 }
434 LRESULT CNliteMainFrame::OnClickChatNo(UINT uMsg,WPARAM wParam,LPARAM lParam){
435
436         auto &chatData = *(CChatData*)wParam;
437         CString setString;
438         setString.Format(TEXT(">>%d "),chatData.no);
439
440         this->commentWriteWindow.SetText(setString);
441
442         return 0;
443
444 }
445
446 LRESULT CNliteMainFrame::OnClickUserName(UINT uMsg,WPARAM wParam,LPARAM lParam){
447
448
449         return 0;
450 }
451
452
453 NLIB_RESULT CNliteMainFrame::LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2){
454
455         CLiveUserData &userData = (*(CLiveUserData*)option);
456
457         try{
458                 
459
460                 switch(eventType){
461
462                 case NICOLIVE_EVENT_RECEVE_CONNECTRESULT:
463
464                         userData.OnChatReceveStart(userData.self.nicoLiveStream,(NicoLiveThreadComment_P)param1);
465
466                         break;
467
468                 case NICOLIVE_EVENT_RECEVE_CHAT:
469
470                         userData.OnChatReceve((NicoLiveChat_P) param1,param2);
471
472                         break;
473
474                 case NICOLIVE_EVENT_RECEVE_CHATSETTLE:
475
476                         userData.OnChatReceveSettle(param1,param2);
477
478                         break;
479
480                 case NICOLIVE_EVENT_RECEVE_CHATSENDRESULT:
481
482                         userData.OnChatSendResult(reinterpret_cast<NicoLiveSendResultComment_P>(param1));
483
484                         break;
485
486                 case NICOLIVE_EVENT_SEND_HEARTBEAT:
487
488                         userData.OnHeartBeat(reinterpret_cast<NicoLiveHeartBeat_P>(param1));
489
490                         break;
491
492
493                 case NICOLIVE_EVENT_DISCONNECT:
494
495                         userData.OnDisconnect();
496
497                         break;
498
499                 case NICOLIVE_EVENT_ERR_CONNECT:
500
501                         throw NLiveException(TEXT("\90Ú\91±\83G\83\89\81[\82Å\82·"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
502
503                         break;
504
505                 default:
506
507                         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__));
508
509                         break;
510                 }
511
512         } catch(Exception e){
513                 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());
514         
515         } catch(std::exception e){
516                 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ñ"));
517         }
518         
519
520         
521
522         return NLIB_ERR_OK;
523 }
524
525
526 LRESULT CNliteMainFrame::OnSetCursor(LRESULT msg,WPARAM wParam,LPARAM lParam,BOOL &bHandled){
527
528         
529         BOOL rslt = FALSE;
530         
531         if(this->subLiveNoComboBox.untilConnectingFlag == TRUE){
532                 ::SetCursor(::LoadCursorW(NULL,IDC_WAIT));
533                 bHandled = TRUE;
534                 rslt = TRUE;
535         } else {
536
537                 bHandled = FALSE;
538         }
539         
540
541         return TRUE;
542
543 }
544
545
546 //
547 //CSubLiveNoComboBox
548 ////////////////////////////////////
549
550 CNliteMainFrame::CSubLiveNoComboBox::CSubLiveNoComboBox(CNliteMainFrame &in_self):self(in_self),untilConnectingFlag(FALSE){}
551
552 static VOID AgreeEnterKeyThread(LPVOID userData){
553
554         Sleep(1000);
555         auto noCombo = (CNliteMainFrame::CSubLiveNoComboBox*) userData;
556         noCombo->AgreeInputLvNo();
557
558         return;
559 }
560
561 VOID CNliteMainFrame::CSubLiveNoComboBox::OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
562         if(wParam == VK_RETURN){
563                                         
564                 cs.Lock();
565                                         
566                 //INT_PTR no = self.lvNoCombo.GetCurSel();
567                 if(untilConnectingFlag == FALSE){
568                         
569                         std::vector<TCHAR> buffer(this->GetWindowTextLengthW() + 1); 
570                         ::GetWindowTextW(this->m_hWnd,&buffer[0],buffer.size());
571                         
572                         
573                         self.ConnectNicoLive(&buffer[0]);
574                 }
575                                         
576                 cs.Unlock();
577                                         
578                                         
579         }
580         return;
581 }
582
583 LRESULT CNliteMainFrame::CSubLiveNoComboBox::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
584
585
586         return FALSE;
587 }
588
589
590
591 VOID CNliteMainFrame::CSubLiveNoComboBox::AddLiveInfo(CNicoLiveStream &stream,LvnoSearchFunctional &functional){
592         
593         CNLiteString dispComboString;
594         dispComboString += stream.GetId();
595         dispComboString += TEXT("\81@-");
596         dispComboString += stream.GetDefaultCommunity();
597         dispComboString += TEXT("\81@title\81F");
598         dispComboString += stream.GetTitle();
599
600         if(std::find_if(liveInfoList.begin(),liveInfoList.end(),functional) == liveInfoList.end()){
601                 liveInfoList.push_back(LiveInfo(dispComboString,stream.GetId()));
602                 
603                 self.lvNoCombo.InsertItem(self.lvNoCombo.GetCount(),dispComboString,0,0,0,0);
604         
605         } 
606         functional.dispData = dispComboString;
607
608         
609
610
611         return;
612 }
613
614
615 VOID CNliteMainFrame::CSubLiveNoComboBox::AgreeInputLvNo(){
616         cs.Lock();
617         self.lvNoCombo.GetEditCtrl().SetReadOnly(FALSE);
618         self.EnableWindow(TRUE);
619         untilConnectingFlag = FALSE;
620         POINT mousePoint;
621         ::GetCursorPos(&mousePoint);
622         ::SetCursorPos(mousePoint.x,mousePoint.y);
623         cs.Unlock();
624 }
625
626
627 //
628 //CLiveUserData
629 /////////////////////////////////////////////////////////////////////////
630
631 CNliteMainFrame::CLiveUserData::CLiveUserData(CNliteMainFrame &self):self(self)
632 {}
633
634
635
636 VOID CNliteMainFrame::CLiveUserData::OnConnect(){
637
638         self.commentView.OnConnect();
639
640 }
641
642
643 VOID CNliteMainFrame::CLiveUserData::OnChatReceveStart(CNicoLiveStream &stream,NicoLiveThreadComment_P threadComment){
644         
645         LvnoSearchFunctional functional(stream.GetId());
646         self.commentWriteWindow.OnChatReceveStart(stream,threadComment);
647         self.subLiveNoComboBox.AddLiveInfo(stream,functional);
648         self.subLiveNoComboBox.SetWindowText(functional.dispData);
649         self.subLiveNoComboBox.AgreeInputLvNo();
650         
651         return;
652 }
653
654 VOID CNliteMainFrame::CLiveUserData::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
655
656         self.commentView.OnChatReceve(chat,count);
657
658 }
659
660 VOID CNliteMainFrame::CLiveUserData::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
661
662         self.commentView.OnChatReceveSettle(commentCount,commentCountSum);
663         
664         return;
665 }
666
667 VOID CNliteMainFrame::CLiveUserData::OnChatSendResult(NicoLiveSendResultComment_P sendResult){
668         self.commentWriteWindow.OnSendChatResult();
669         return;
670 }
671
672
673 VOID CNliteMainFrame::CLiveUserData::OnHeartBeat(NicoLiveHeartBeat_P heartBeat){
674
675         self.commentWriteWindow.OnHeartBeat(heartBeat);
676
677         return;
678 }
679
680
681
682 VOID CNliteMainFrame::CLiveUserData::OnDisconnect(){
683         self.commentWriteWindow.OnDisConnect();
684         return;
685 }
686
687 }