OSDN Git Service

読み取り機能実装途中
[nlite/nlite.git] / nlite / nlite.cpp
index 425c814..6935dcf 100644 (file)
@@ -3,12 +3,13 @@
 
 #include "stdafx.h"
 #include "nlite_include.h"
+using namespace nlite;
+CAppModule _Module;
+
+
 
 
-CAppModule _Module;
 
-const CApplicationInfo* nlite::appInfo = NULL;
-static TCHAR localAppDataPath[_MAX_PATH];
 
 static WSAData wsaData;                                                        //winsockdata
 static HINTERNET hInternet = NULL;
@@ -16,62 +17,75 @@ static HINTERNET hInternet = NULL;
 static BOOL InitializeNlite();                                 //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8f\89\8aú\89»
 static VOID FinalizeNlite();                                   //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8fI\97¹\8f\88\97\9d
 static CNliteMainFrame wnd;                                            //\83\81\83C\83\93\83t\83\8c\81[\83\80\83E\83B\83\93\83h\83E
+
+//\83\81\83C\83\93\8aÖ\90\94
 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
        LPTSTR lpCmdLine, int nCmdShow)
 {
-   
+       HINSTANCE hRich = LoadLibrary(CRichEditCtrl::GetLibraryName());
        int nRet = -1;
        try{
-               InitCommonControls();
 
-               if(_Module.Init(NULL, hInstance) != S_OK){
-                       throw AppInitException(__LINE__,TEXT(__FILE__));
+               //
+               //\83A\83v\83\8a\83P\83P\81[\83V\83\87\83\93\8f\89\8aú\89»\8f\88\97\9d
+               //
+               HRESULT hRes = ::CoInitialize(NULL);
+               ATLASSERT(SUCCEEDED(hRes));
+               AtlInitCommonControls(ICC_COOL_CLASSES | ICC_WIN95_CLASSES);
+               GUID guid;
+               if(_Module.Init(NULL, hInstance,&guid) != S_OK){
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
                }
-                       
+
+               AtlAxWinInit();
+
                if(InitializeNlite() != TRUE){
-                       throw AppInitException(__LINE__,TEXT(__FILE__));
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
                }
-               
+
+               g_speaker.SynthesisAsync(TEXT("\83e\83X\83g\83R\83\81\83\93\83g"));
 
                
-               
+               //\83\81\83b\83Z\81[\83W\83\8b\81[\83v\93o\98^
                CMessageLoop theLoop;
                _Module.AddMessageLoop(&theLoop);
 
 
+               //\83\81\83C\83\93\83E\83B\83\93\83h\83E\8f\89\8aú\89»
                wnd.Initialize(localAppDataPath);
                wnd.CreateEx(0,0,WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);
+
+               //\83\81\83C\83\93\83E\83B\83\93\83h\83E\95\\8e¦
                wnd.ShowWindow(nCmdShow);
                wnd.UpdateWindow();
-               
+
+               //\97]\95ª\82É\8am\95Û\82µ\82Ä\82¢\82é\83q\81[\83v\82ð\8aJ\95ú
                _heapmin();
 
-               
 
+               //\83\81\83b\83Z\81[\83W\83\8b\81[\83v\8aJ\8en
                nRet = theLoop.Run();
 
+               //\8fI\97¹\8cã\83\81\83\82\83\8a\83`\83F\83b\83N
                vcassert(_heapchk() == _HEAPOK,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
 
                goto nliteend;
-               
+
        } catch(nlite::Exception &e){
-               CNLiteString 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);
-               errprint(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81[:%s"),errMessage.c_str());
+
+               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());
+
+
+               goto nlitefinally;
+       } catch(nlib::Exception &e){
+
+               UnexpectedErrorMessageShow(TEXT("nlib\82Å\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\83G\83\89\81["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName());
 
                goto nlitefinally;
        }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);
-               errprint_mb(CP_THREAD_ACP,"\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\82¢\95s\96¾\82È\83G\83\89\81[:%s",e.what());
+               UnexpectedErrorMessageShow(TEXT("\83n\83\93\83h\83\8b\82³\82ê\82Ä\82¢\82È\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ñ"));
+
+
 
                goto nlitefinally;
        } 
@@ -79,14 +93,14 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
 nlitefinally:
        wnd.OnException();
        wnd.DestroyWindow();
-
+       FreeLibrary(hRich);
 
 nliteend:
 
        _Module.RemoveMessageLoop();
        FinalizeNlite();
        _Module.Term();
-
+       ::CoUninitialize();
 
        return nRet;
 }
@@ -111,60 +125,76 @@ static BOOL InitializeNlite(){
 
 
                }
-               
+
                if(err != ERROR_SUCCESS){
 
-                       throw AppInitException(__LINE__,TEXT(__FILE__));
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
                }
 
+               //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8fî\95ñ\83C\83\93\83X\83^\83\93\83X\90\90¬
                const CApplicationInfo &appInfo = CApplicationInfo::getInstance();
                CNLiteString userAgent;
-               userAgent.reserve(256);
                userAgent = appInfo.getProcuctName();
                userAgent += TEXT("/");
                userAgent += appInfo.getProductVersion();
 
 
-               hInternet = WinHttpOpen(userAgent.c_str(),WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0);
+
+               //HTTP\83I\83u\83W\83F\83N\83g\90\90¬
+               hInternet = WinHttpOpen(userAgent,WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0);
 
                if(hInternet == NULL){
 
-                       throw AppInitException(__LINE__,TEXT(__FILE__));
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
 
                }
 
+               //nlib\82Ì\8f\89\8aú\89»
                InitializeNLIB(hInternet);
 
+               //\83\8d\81[\83J\83\8b\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83t\83H\83\8b\83_\8c\9f\8dõ
                if(SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppDataPath) != S_OK){
 
-                       throw AppInitException(__LINE__,TEXT(__FILE__));
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
                }
 
 
                SystemParametersInfo (SPI_SETLISTBOXSMOOTHSCROLLING,FALSE,FALSE,0);
 
 
+
+               if(SHGetFolderPathW(0,CSIDL_APPDATA,0,SHGFP_TYPE_CURRENT,appFolderPath) != S_OK){
+
+                       throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
+               }
+               ncvAppSettingPath = appFolderPath;
+               ncvAppSettingPath += TEXT("\\posite-c\\NiconamaCommentViewer\\AppSetting.xml");
+               rslt = TRUE;
        }catch (AppInitException e){
 
-               return rslt;
+               rslt = FALSE;
 
        }
+       
 
+       return rslt;
+}
 
 
-       rslt = TRUE;
+VOID FinalizeNlite(){
 
+       //\83\81\83C\83\93\83t\83\8c\81[\83\80\83E\83B\83\93\83h\83E\8cã\8f\88\97\9d
+       wnd.Finalaize();
 
-       return rslt;
-}
+       //nlib\8cã\8f\88\97\9d
+       FinalizeNLIB();
 
+       //HTTP\83I\83u\83W\83F\83N\83g\8aJ\95ú
+       WinHttpCloseHandle(hInternet);
 
- VOID FinalizeNlite(){
+       //winsock\8aJ\95ú
+       WSACleanup();
 
-        wnd.Finalaize();
-        FinalizeNLIB();
-        WinHttpCloseHandle(hInternet);
-        WSACleanup();
+       return;
+}
 
-        return;
- }
\ No newline at end of file