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);
_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();
}
-
+
if(err != ERROR_SUCCESS){
- throw AppInitException();
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
const CApplicationInfo &appInfo = CApplicationInfo::getInstance();
if(hInternet == NULL){
- throw AppInitException();
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
}
+
+
rslt = TRUE;
} *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));
if(nRet <= 0){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
if(dwSize <= 0){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
pBlock = malloc(dwSize);
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];
if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pProductVersion,&ulen) == FALSE){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pOriginalFileName,&ulen) == FALSE){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pLegalCopyright,&ulen) == FALSE){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pProductName,&ulen) == FALSE){
- throw err;
+ throw AppInitException(__LINE__,TEXT(__FILE__));
}
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);
///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(){
}
+ UINT_PTR getLineNo(){
+
+ return line;
+ }
+
+ LPCWSTR getFileName(){
+
+ return fileName.c_str();
+
+ }
+
};
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){}
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)
+ {}
};
public:
- NLiveException(LPCTSTR errmessage):Exception(errmessage){}
+ NLiveException(LPCTSTR errmessage,UINT_PTR in_line,LPCTSTR in_fileName):Exception(errmessage,in_line,in_fileName){}
};
#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"
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__));
}
};
- 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;
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:
CNliteMainFrame()
:userData(commentView),
- nicoLiveStream()
+ subLiveNoComboBox(*this)
{
LOGFONT lf = {0};
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)
}
- //\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;
appInfo->show();
}
+
+ static NLIB_RESULT LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2);
};
}
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½"));
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());
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){
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;
namespace nlite{
-
class CNicoVideoAuth{
private:
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__));
}
}
}
};
+
+ 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
// C++\83\89\83C\83u\83\89\83\8a
#include <string>
+#include <iostream>
+#include <sstream>
#include <exception>
#include <vector>