OSDN Git Service

2011/11/26 18:00:26
authorqwerty2501 <riot313@gmail.com>
Sat, 26 Nov 2011 09:00:26 +0000 (18:00 +0900)
committerqwerty2501 <riot313@gmail.com>
Sat, 26 Nov 2011 09:00:26 +0000 (18:00 +0900)
nlite/nlite.cpp
nlite/nlite_appInfo.cpp
nlite/nlite_commentWrite.h
nlite/nlite_exception.h
nlite/nlite_include.h
nlite/nlite_listviewex.h
nlite/nlite_mailframe.h
nlite/nlite_mainframe.cpp
nlite/nlite_nlib.h
nlite/stdafx.h

index b06d577..198c4e9 100644 (file)
@@ -21,15 +21,16 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
        int nRet = -1;
        try{
                if(_Module.Init(NULL, hInstance) != S_OK){
-                       throw AppInitException();
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
                        
                if(InitializeNlite() != TRUE){
-                       throw AppInitException();
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
                
 
                
+               
                CMessageLoop theLoop;
                _Module.AddMessageLoop(&theLoop);
 
@@ -41,19 +42,29 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
 
                _heapmin();
 
+               
+
                nRet = theLoop.Run();
 
                vcassert(_heapchk() == _HEAPOK,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
 
-               _Module.RemoveMessageLoop();
-       } catch(Exception e){
-
-               MessageBox(NULL,e.what(),TEXT("\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83G\83\89\81["),MB_OK);
-       }catch(std::exception e){
-
-               MessageBoxA(NULL,e.what(),"\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83G\83\89\81[",MB_OK);
+               
+       } catch(nlite::Exception &e){
+               tstring errMessage(TEXT("\83G\83\89\81[\83\81\83b\83Z\81[\83W:"));
+               errMessage += e.what();
+               errMessage += TEXT("\r\n\8ds\94Ô\8d\86:");
+               std::wostringstream num;
+               num << e.getLineNo();
+               errMessage += num.str();
+               errMessage += TEXT("\r\n\83t\83@\83C\83\8b\96¼:");
+               errMessage += e.getFileName();
+               
+               MessageBox(NULL,errMessage.c_str(),TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82È\82¢\83G\83\89\81["),MB_ICONERROR | MB_OK);
+       }catch(std::exception &e){
+               
+               MessageBoxA(NULL,e.what(),"\83n\83\93\83h\83\8b\82³\82ê\82Ä\82È\82¢\95s\96¾\82Ì\83G\83\89\81[",MB_ICONERROR | MB_OK);
        } 
-
+       _Module.RemoveMessageLoop();
        FinalizeNlite();
        _Module.Term();
 
@@ -81,10 +92,10 @@ static BOOL InitializeNlite(){
 
 
                }
-
+               
                if(err != ERROR_SUCCESS){
 
-                       throw AppInitException();
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
 
                const CApplicationInfo &appInfo = CApplicationInfo::getInstance();
@@ -99,7 +110,7 @@ static BOOL InitializeNlite(){
 
                if(hInternet == NULL){
 
-                       throw AppInitException();
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
 
                }
 
@@ -111,6 +122,8 @@ static BOOL InitializeNlite(){
 
        }
 
+
+
        rslt = TRUE;
 
 
index 44e1f3e..831f985 100644 (file)
@@ -11,7 +11,7 @@ CApplicationInfo::CApplicationInfo(){
        } *lpTranslate;
        TCHAR szModuleName[_MAX_PATH + 1] = {0};                //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83t\83@\83C\83\8b\96¼
        try{
-               static const  AppInitException err;                             //\97á\8aO\83N\83\89\83X
+
                DWORD dwReserved;
                LPTSTR errMessage = NULL;
                int nRet = GetModuleFileName(NULL,szModuleName,ARRAYSIZE(szModuleName));
@@ -20,7 +20,7 @@ CApplicationInfo::CApplicationInfo(){
                if(nRet <= 0){
 
                        
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
 
 
@@ -30,7 +30,7 @@ CApplicationInfo::CApplicationInfo(){
 
                if(dwSize <= 0){
 
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
 
                pBlock = malloc(dwSize);
@@ -41,12 +41,12 @@ CApplicationInfo::CApplicationInfo(){
                assert(bRet);
 
                if(bRet != TRUE){
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
 
                UINT ulen;
                if(VerQueryValue(pBlock,TEXT("\\VarFileInfo\\Translation"),(LPVOID*)&lpTranslate,&ulen) == FALSE){
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
                }
 
                TCHAR subBlock[_MAX_PATH];
@@ -54,7 +54,7 @@ CApplicationInfo::CApplicationInfo(){
 
                if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pProductVersion,&ulen) == FALSE){
 
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
 
                }
 
@@ -62,7 +62,7 @@ CApplicationInfo::CApplicationInfo(){
 
                if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pOriginalFileName,&ulen) == FALSE){
 
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
 
                }
 
@@ -70,7 +70,7 @@ CApplicationInfo::CApplicationInfo(){
 
                if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pLegalCopyright,&ulen) == FALSE){
 
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
 
                }
 
@@ -78,7 +78,7 @@ CApplicationInfo::CApplicationInfo(){
 
                if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pProductName,&ulen) == FALSE){
 
-                       throw err;
+                       throw AppInitException(__LINE__,TEXT(__FILE__));
 
                }
 
index a9f6426..ddb2255 100644 (file)
@@ -75,6 +75,7 @@ namespace nlite{
 
                VOID ChangeSize(SIZE &size){
 
+                       //\83T\83C\83Y\95Ï\8dX\8f\88\97\9d
                        commentPosBox.MoveWindow(SEPARATEFSIZE.left,SEPARATEFSIZE.top, commentPosBoxSize.cx,commentWriteWindowSize.cy - (SEPARATEFSIZE.top + SEPARATEFSIZE.bottom),TRUE);
                        commentSizeBox.MoveWindow((SEPARATEFSIZE.left * 2) + SEPARATEFSIZE.right + commentPosBoxSize.cx, SEPARATEFSIZE.top, commentSizeBoxSize.cx,commentWriteWindowSize.cy - (SEPARATEFSIZE.top + SEPARATEFSIZE.bottom),TRUE);
                        commentColorBox.MoveWindow((SEPARATEFSIZE.left * 3) + (SEPARATEFSIZE.right * 2) + commentPosBoxSize.cx + commentSizeBoxSize.cx,SEPARATEFSIZE.top,commentColorBoxSize.cx,commentWriteWindowSize.cy - (SEPARATEFSIZE.top + SEPARATEFSIZE.bottom),TRUE);
index 43ddc5e..31586d4 100644 (file)
@@ -5,14 +5,27 @@ namespace nlite{
        ///nlite\97á\8aO\8f\88\97\9d\83N\83\89\83X
        ///
        class Exception:public std::exception{
-                       
+               
+       private:
                std::wstring  wErrMessage;
+               UINT_PTR line;
+               tstring fileName;
 
                //\83R\83\93\83X\83g\83\89\83N\83^
        public:
                Exception(){}
                Exception(const char* const& errMessage):exception(errMessage){}
-               Exception(const wchar_t * const & errMessage):wErrMessage(errMessage){}
+               Exception(const wchar_t * const & errMessage,UINT_PTR in_line,LPCTSTR in_fileName):
+                       wErrMessage(errMessage),
+                       line(in_line)
+               {
+                       WCHAR file[_MAX_FNAME];
+                       WCHAR ext[_MAX_EXT];
+                       _wsplitpath(in_fileName,(wchar_t*)NULL,(wchar_t*)NULL,file,ext);
+                       fileName = file;
+                       fileName += ext;
+
+               }
 
                LPCWSTR what(){
 
@@ -20,6 +33,17 @@ namespace nlite{
 
                }
 
+               UINT_PTR getLineNo(){
+
+                       return line;
+               }
+
+               LPCWSTR getFileName(){
+                       
+                       return fileName.c_str();
+               
+               }
+
        };
 
 
@@ -27,7 +51,7 @@ namespace nlite{
 
        public:
 
-               AppInitException():Exception(TEXT("\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8f\89\8aú\89»\82É\8e¸\94s\82µ\82Ü\82µ\82½")){}
+               AppInitException(UINT_PTR in_line,LPCTSTR in_fileName):Exception(TEXT("\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8f\89\8aú\89»\82É\8e¸\94s\82µ\82Ü\82µ\82½"),in_line,in_fileName){}
 
 
                
@@ -40,7 +64,8 @@ namespace nlite{
                NLIB_RESULT errcode;
 
        public:
-               NLIBException(NLIB_RESULT rslt):errcode(rslt){}
+               NLIBException(LPCTSTR errmessage,NLIB_RESULT rslt,UINT_PTR in_line,LPCTSTR in_fileName):errcode(rslt),Exception(errmessage,in_line,in_fileName)
+               {}
        
 
        };
@@ -49,7 +74,7 @@ namespace nlite{
 
        public:
 
-               NLiveException(LPCTSTR errmessage):Exception(errmessage){}
+               NLiveException(LPCTSTR errmessage,UINT_PTR in_line,LPCTSTR in_fileName):Exception(errmessage,in_line,in_fileName){}
 
        };
        
index b756174..5f61818 100644 (file)
@@ -8,11 +8,12 @@
 #include <vcmpool.h>
 #include "resource.h"
 
+#include "nlite_define.h"
 
 #include "nlite_exception.h"
 #include "nlite_commentWrite.h"
 #include "nlite_nlib.h"
-#include "nlite_define.h"
+
 #include "nlite_common.h"
 #include "nlite_listviewex.h"
 #include "nlite_commentview.h"
index b476ea4..1a208de 100644 (file)
@@ -120,8 +120,8 @@ namespace nlite{
                        HWND rslt = __super::Create(hWndParent,0,LISTVIEW_EX,WS_VISIBLE | WS_CHILD  | WS_BORDER,0,menuOrID);
 
                        if(rslt == NULL){
-                               static AppInitException err;
-                               throw err;
+
+                               throw AppInitException(__LINE__,TEXT(__FILE__));
                        }
                
                        
index 63d6edd..5550f24 100644 (file)
@@ -23,61 +23,41 @@ namespace nlite{
        };
 
 
-       class CNicoLiveStream{
 
-       private:
-               NicoLiveStream_P nicoLiveStream;
 
-       public:
-               CNicoLiveStream()
-                       :nicoLiveStream(NicoLiveStream_new())
 
-               {}
-               ~CNicoLiveStream(){
 
-                       NicoLiveStream_delete(&nicoLiveStream);
-                       
-               }
+       class CNliteMainFrame : public CFrameWindowImpl<CNliteMainFrame>,
+               public CUpdateUI<CNliteMainFrame>,public CMessageFilter, public CIdleHandler
+       {
 
                
+               class CSubLiveNoComboBox:public CWindowImpl<CEdit>{
 
-               VOID Connect(CLiveUserData &userData,CNicoVideoAuth &nicoVideoAuth,LPCTSTR url){
-
-                       NLIB_RESULT rslt;
+                       
 
-                       rslt = NicoLiveStream_connect(nicoLiveStream,nicoVideoAuth.GetAuth(),url,LiveCallBack,&userData);
+               private:
+                       CNliteMainFrame &self;
 
-                       if(rslt != NLIB_ERR_OK){
+               public:
+                       CSubLiveNoComboBox(CNliteMainFrame &in_self):self(in_self){}
 
-                               throw NLIBException(rslt);
-                       }
-               }
-               
 
-               VOID DisConnect(){
+                       BEGIN_MSG_MAP_EX(CSubLiveNoComboBox)
+                               MSG_WM_KEYDOWN(OnKeyDown)
+                       END_MSG_MAP()
 
-                       NicoLiveStream_disConnect(nicoLiveStream);
-               }
-               
-               VOID SendChat(LPCTSTR chatBuf,std::vector<LPCTSTR> mails,std::vector<LPCTSTR> extends){
-                       NLIB_RESULT rslt;
-                       mails.insert( mails.end(),(LPCTSTR)NULL);
-                       extends.insert(extends.end(),(LPCTSTR)NULL);
-                       rslt = NicoLiveStream_sendChat(nicoLiveStream,chatBuf,&mails[0],&extends[0]);
-
-                       if(rslt != NLIB_ERR_OK){
-                               throw NLIBException(rslt);
+                       void OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
+                               if(wParam == VK_RETURN){
+                                       std::vector<TCHAR> buffer(this->GetWindowTextLengthW() + 1); 
+                                       ::GetWindowTextW(this->m_hWnd,&buffer[0],buffer.size());
+                               }
+                               return;
                        }
-               }
-
-               static NLIB_RESULT LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2);
-               
 
-       };
+               };
 
-       class CNliteMainFrame : public CFrameWindowImpl<CNliteMainFrame>,
-               public CUpdateUI<CNliteMainFrame>,public CMessageFilter, public CIdleHandler
-       {
+               
        public:
 
                typedef CFrameWindowImpl<CNliteMainFrame> baseWindow;
@@ -92,11 +72,12 @@ namespace nlite{
                CNicoVideoAuth nicoVideoAuth;
                CStatusBarCtrl statusBar;
                CLiveUserData userData;
+               CSubLiveNoComboBox subLiveNoComboBox;
                CCommentWriteWindow commentWriteWindow;
                CTabCtrl tabctrl;
                Property nliteProperty;
                HFONT hTabFont;
-               CComboBox lvNoCombo;
+               CComboBoxEx lvNoCombo;
                INT_PTR statusBarHeight;
                INT_PTR toolBarHeight;
        private:
@@ -117,7 +98,7 @@ namespace nlite{
 
                CNliteMainFrame()
                        :userData(commentView),
-                       nicoLiveStream()
+                       subLiveNoComboBox(*this)
                {
                        LOGFONT lf = {0};
 
@@ -143,6 +124,7 @@ namespace nlite{
                        MSG_WM_DESTROY(OnDestroy)
                        MESSAGE_HANDLER(WM_SIZING,OnSizing)
                        MESSAGE_HANDLER(WM_SIZE,OnSize)
+//                     MSG_WM_NOTIFY(OnNotify)
                        MESSAGE_HANDLER_EX(WM_ERASEBKGND,OnErasekgnd);
                        COMMAND_ID_HANDLER_EX(IDM_EXIT, OnMenuExit)
                        COMMAND_ID_HANDLER_EX(IDM_ABOUT,OnMenuAbount)
@@ -170,7 +152,7 @@ namespace nlite{
 
                }
 
-               //\83`\83\89\83c\83L\82ð\82È\82­\82·
+               //\83`\83\89\83c\83L\82ð\82È\82­\82·\81B\82 \82ñ\82Ü\8cø\89Ê\82È\82¢\81H
                LRESULT OnErasekgnd(UINT uMsg,WPARAM wParam,LPARAM lParam){
 
                        return TRUE;
@@ -236,6 +218,8 @@ namespace nlite{
 
                        appInfo->show();
                }
+
+               static NLIB_RESULT LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2);
        };
 
 
index 2a25497..4b0e7ea 100644 (file)
@@ -36,8 +36,7 @@ VOID CNliteMainFrame::ChangeSize(const SIZE& client){
 }
 
 LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
-       // \83c\81[\83\8b\83o\81[\82ð\8dì\90¬
-       //
+
 
        // \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½"));
@@ -48,7 +47,10 @@ LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
        
        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 , 0, IDC_COMBO_REBAR);
+
+
+       subLiveNoComboBox.SubclassWindow(lvNoCombo.GetEditCtrl());
        lvNoCombo.SetFont(AtlGetDefaultGuiFont());
        
        
@@ -93,7 +95,7 @@ LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){
        return 0;
 }
 
-NLIB_RESULT CNicoLiveStream::LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2){
+NLIB_RESULT CNliteMainFrame::LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2){
 
        try{
                switch(eventType){
@@ -120,19 +122,19 @@ NLIB_RESULT CNicoLiveStream::LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStrea
 
                case NICOLIVE_EVENT_ERR_CONNECT:
 
-                       throw NLiveException(TEXT("\90Ú\91±\83G\83\89\81[\82Å\82·"));
+                       throw NLiveException(TEXT("\90Ú\91±\83G\83\89\81[\82Å\82·"),__LINE__,TEXT(__FILE__));
 
                        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½"));
+                       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__));
 
                        break;
                }
        } catch(Exception e){
 
-               MessageBox(NULL,e.what(),TEXT("\83j\83R\90\83G\83\89\81["),MB_OK | MB_ICONSTOP | MB_TASKMODAL);
+               ::MessageBox(NULL,e.what(),TEXT("\83j\83R\90\83G\83\89\81["),MB_OK | MB_ICONSTOP | MB_TASKMODAL);
        }
 
        return NLIB_ERR_OK;
index efa28a3..3755987 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace nlite{
 
-
        class CNicoVideoAuth{
 
        private:
@@ -24,7 +23,7 @@ namespace nlite{
                        rslt = NicoVideoAuth_getNicoVideoAuth(nicoVideoAuth,bt);
                        if(rslt != NLIB_ERR_OK){
 
-                               throw NLIBException(rslt);
+                               throw NLIBException(TEXT("\83j\83R\83j\83R\93®\89æ\94F\8fØ\8fî\95ñ\8eæ\93¾\82É\8e¸\94s\82µ\82Ü\82µ\82½"),rslt,__LINE__,TEXT(__FILE__));
                        }
 
                }
@@ -35,4 +34,58 @@ namespace nlite{
                }
 
        };
+
+       class CNicoLiveStream{
+
+       private:
+               NicoLiveStream_P nicoLiveStream;
+
+       public:
+               CNicoLiveStream()
+                       :nicoLiveStream(NicoLiveStream_new())
+
+               {}
+               ~CNicoLiveStream(){
+
+                       NicoLiveStream_delete(&nicoLiveStream);
+                       
+               }
+
+               
+
+               VOID Connect(CNicoVideoAuth &nicoVideoAuth,LPCTSTR url,NicoRecvCallBack callback,LPVOID userData){
+
+                       NLIB_RESULT rslt;
+
+                       rslt = NicoLiveStream_connect(nicoLiveStream,nicoVideoAuth.GetAuth(),url,callback,userData);
+
+                       if(rslt != NLIB_ERR_OK){
+
+                               throw NLIBException(TEXT("\83j\83R\83j\83R\90\95ú\91\97\90Ú\91±\82É\8e¸\94s\82µ\82Ü\82µ\82½"),rslt,__LINE__,TEXT(__FILE__));
+                       }
+               }
+               
+
+               VOID DisConnect(){
+
+                       NicoLiveStream_disConnect(nicoLiveStream);
+               }
+               
+               VOID SendChat(LPCTSTR chatBuf,std::vector<LPCTSTR> mails,std::vector<LPCTSTR> extends){
+                       NLIB_RESULT rslt;
+                       mails.insert( mails.end(),(LPCTSTR)NULL);
+                       extends.insert(extends.end(),(LPCTSTR)NULL);
+                       rslt = NicoLiveStream_sendChat(nicoLiveStream,chatBuf,&mails[0],&extends[0]);
+
+                       if(rslt != NLIB_ERR_OK){
+                               throw NLIBException(TEXT("\83R\83\81\83\93\83g\91\97\90M\92\86\82É\8fá\8aQ\82ª\94­\90\82µ\82Ü\82µ\82½"),rslt,__LINE__,TEXT(__FILE__));
+                       }
+               }
+
+               
+
+       };
+
+
+
 }
\ No newline at end of file
index 600efdf..ba8a886 100644 (file)
@@ -25,6 +25,8 @@
 
 // C++\83\89\83C\83u\83\89\83\8a
 #include <string>
+#include <iostream>
+#include <sstream>
 #include <exception>
 #include <vector>