7 const static LPCTSTR NLITE_MAINWINDOW = TEXT("nlite");
9 const static SIZE lowestFrameSize = {300,300};
20 class CNliteMainFrame : public CFrameWindowImpl<CNliteMainFrame>,
21 public CUpdateUI<CNliteMainFrame>,public CMessageFilter, public CIdleHandler
25 class CSubLiveNoComboBox:public CWindowImpl<CEdit>{
30 CNliteMainFrame &self;
31 CComAutoCriticalSection cs;
32 BOOL untilConnectingFlag;
35 CSubLiveNoComboBox(CNliteMainFrame &in_self):self(in_self),untilConnectingFlag(FALSE){}
38 BEGIN_MSG_MAP_EX(CSubLiveNoComboBox)
39 MSG_WM_KEYDOWN(OnKeyDown)
42 void OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
43 if(wParam == VK_RETURN){
47 if(untilConnectingFlag == FALSE){
48 untilConnectingFlag = TRUE;
49 std::vector<TCHAR> buffer(this->GetWindowTextLengthW() + 1);
50 ::GetWindowTextW(this->m_hWnd,&buffer[0],buffer.size());
51 self.ConnectNicoLive(&buffer[0]);
61 VOID AgreeInputLvNo(){
63 untilConnectingFlag = FALSE;
74 CCommentView &commentView;
75 CSubLiveNoComboBox &lvnocombo;
78 CLiveUserData(CCommentView& cv,CSubLiveNoComboBox &combo):commentView(cv),lvnocombo(combo){}
82 commentView.OnConnect();
86 VOID OnChatReceveStart(StreamStatus &streamStatus){
88 commentView.SetStreamStatus(streamStatus);
91 VOID OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
93 commentView.OnChatReceve(chat,count);
97 VOID OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
99 commentView.OnChatReceveSettle(commentCount,commentCountSum);
100 lvnocombo.AgreeInputLvNo();
109 typedef CFrameWindowImpl<CNliteMainFrame> baseWindow;
111 //
\83E
\83B
\83\93\83h
\83E
\83N
\83\89\83X
\96¼
\81A
\8b¤
\92Ê
\83\8a\83\
\81[
\83XID
\81A
\83X
\83^
\83C
\83\8b\81A
\94w
\8ci
\90F
\82ð
\93o
\98^
112 DECLARE_FRAME_WND_CLASS_EX(NLITE_MAINWINDOW, IDC_NLITE,CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_WINDOW)
115 CCommentView commentView;
118 CStatusBarCtrl statusBar;
119 CLiveUserData userData;
120 CSubLiveNoComboBox subLiveNoComboBox;
121 CCommentWriteWindow commentWriteWindow;
125 CComboBoxEx lvNoCombo;
126 INT_PTR statusBarHeight;
127 INT_PTR toolBarHeight;
128 CNicoVideoAuth nicoVideoAuth;
129 Property nliteProperty;
130 CNicoLiveStream nicoLiveStream;
133 //
\83\81\83b
\83Z
\81[
\83W
\83t
\83B
\83\8b\83^
\8f\88\97\9d
134 virtual BOOL PreTranslateMessage(MSG* pMsg){
135 //
\8aî
\92ê
\83N
\83\89\83X
\82ÌPreTranslateMessage
\82ð
\8cÄ
\82Ñ
\8fo
\82·
136 return CFrameWindowImpl<CNliteMainFrame>::PreTranslateMessage(pMsg);
139 //
\83A
\83C
\83h
\83\8b\8f\88\97\9d
140 virtual BOOL OnIdle(){
148 :userData(commentView,subLiveNoComboBox),
149 subLiveNoComboBox(*this)
154 lf.lfCharSet = SHIFTJIS_CHARSET;
155 hTabFont = CreateFontIndirect(&lf);
160 DeleteObject(hTabFont);
164 BEGIN_UPDATE_UI_MAP(CNliteMainFrame)
165 //
\83G
\83\93\83g
\83\8a\82È
\82µ
168 //
\83\81\83b
\83Z
\81[
\83W
\83}
\83b
\83v
169 BEGIN_MSG_MAP_EX(CNliteMainFrame)
170 MSG_WM_CREATE(OnCreate)
171 MSG_WM_DESTROY(OnDestroy)
172 MESSAGE_HANDLER(WM_SIZE,OnSize)
173 MESSAGE_HANDLER_EX(WM_ERASEBKGND,OnErasekgnd);
174 COMMAND_ID_HANDLER_EX(IDM_EXIT, OnMenuExit)
175 COMMAND_ID_HANDLER_EX(IDM_ABOUT,OnMenuAbount)
176 COMMAND_ID_HANDLER_EX(IDM_COOKIE,OnCookie)
177 NOTIFY_HANDLER(ATL_IDW_TOOLBAR,RBN_HEIGHTCHANGE,OnRbnHeightChange)
178 // CFrameWindowImpl
\83N
\83\89\83X
\82Ö
\83`
\83F
\81[
\83\93
179 CHAIN_MSG_MAP(CFrameWindowImpl<CNliteMainFrame>)
184 //
\83`
\83\89\83c
\83L
\82ð
\82È
\82
\82·
185 LRESULT OnErasekgnd(UINT uMsg,WPARAM wParam,LPARAM lParam){
191 //
\83c
\81[
\83\8b\83o
\81[
\8d\82\82³
\95Ï
\8dX
192 LRESULT OnRbnHeightChange(INT_PTR wParam,LPNMHDR lParam,BOOL &bHandled){
195 ::GetClientRect(m_hWndToolBar,&toolbarRect);
196 toolBarHeight = toolbarRect.bottom - toolbarRect.top;
199 GetClientRect(&client);
201 ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
209 //
\83T
\83C
\83Y
\95Ï
\8dX
\8cã
210 LRESULT OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
214 clientSize.cx = LOWORD(lParam);
215 clientSize.cy = HIWORD(lParam);
216 ChangeSize(clientSize);
225 VOID ChangeSize(const SIZE& client);
228 LRESULT OnCreate(LPCREATESTRUCT lpcs);
230 VOID ConnectNicoLive(LPCTSTR liveNo){
232 nicoLiveStream.DisConnect();
233 commentView.OnConnect();
234 nicoLiveStream.Connect(nicoVideoAuth,liveNo,LiveCallBack,&userData);
238 VOID Initialize(LPCTSTR localAppDataPath){
240 nliteProperty.ReadIniFile();
242 commentView.SetProperty(nliteProperty.cvp);
244 if(nliteProperty.gp.browserType == BT_NOSETTING){
245 nliteProperty.CookieSetting();
246 while(nliteProperty.gp.browserType == BT_NOSETTING){
247 ::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);
248 nliteProperty.CookieSetting();
252 nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
258 nliteProperty.cvp = commentView.GetProperty();
259 nliteProperty.WriteIniFile();
263 nicoLiveStream.DisConnect();
264 commentView.DestroyWindow();
272 nicoLiveStream.DisConnect();
276 //
\83\81\83j
\83\85\81[
\82©
\82ç
\83t
\83@
\83C
\83\8b\82ð
\8fI
\97¹
\82ð
\91I
\91ð
277 void OnMenuExit(UINT uNotifyCode, int nID, HWND hWndCtl){
278 PostMessage(WM_CLOSE);
281 //
\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¦
282 void OnMenuAbount(UINT uNotifyCode,int nID,HWND hWndCtl){
288 //
\83N
\83b
\83L
\81[
\82Ì
\90Ý
\92è
289 void OnCookie(UINT uNotifyCode,int nID,HWND hWndCtl){
290 nliteProperty.CookieSetting();
292 while(nliteProperty.gp.browserType == BT_NOSETTING){
293 ::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);
294 nliteProperty.CookieSetting();
298 nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
301 static NLIB_RESULT LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2);