Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/nsmsgs/src/UFrmNsmMain.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 119 - (show annotations) (download) (as text)
Fri Oct 8 15:41:45 2010 UTC (13 years, 7 months ago) by kamoya
File MIME type: text/x-c++src
File size: 1983 byte(s)
avoid ARRAYSIZE macro
1 #include "UFrmNsmMain.h"
2
3 #include <algorithm>
4
5 #ifdef _WINDOWS
6 #include <windowsx.h>
7 #else
8 #include <iostream>
9 #endif
10
11 #include "../../Common/UNsmConsts.h"
12 #include "../../Common/dummy.h"
13
14 #include "nsmsgs.h"
15 #include "UNsmSystem.h"
16
17 #define RS_ERROR_NOUIMODULE TEXT("UI モジュールが見つかりませんでした。\nPlugins フォルダ内に UI モジュールが存在するか確認してください。")
18
19 namespace Regnessem
20 {
21 namespace System
22 {
23 NsmMain::NsmMain()
24 :SystemHandle(CreateMainWindow())
25 {}
26
27 NsmMain::~NsmMain()
28 {}
29
30 HWND NsmMain::CreateMainWindow()
31 {
32 WNDCLASSEX wc = {};
33 wc.cbSize = sizeof(wc);
34 wc.lpszClassName = TEXT("NsmMain");
35 wc.lpfnWndProc = WndProc;
36 wc.hInstance = static_cast<HINSTANCE>(GetModuleHandle(NULL));
37
38 RegisterClassEx(&wc);
39
40 return CreateWindowEx(0,
41 wc.lpszClassName,
42 0,
43 WS_OVERLAPPED,
44 0, 0, 0, 0,
45 NULL,
46 NULL,
47 NULL,
48 NULL);
49 }
50
51 void NsmMain::Initialize()
52 {
53 g_NsmSystem.SearchPlugin(ExtractFilePath(Application::ExeName()) + (TEXT("Plugins") FILESEP TEXT("*") DLLSUFFIX));
54
55 const NsmPluginList &p = g_NsmSystem.Plugins;
56 if(std::find_if(p.begin(), p.end(), NsmPlugin::FindByModuleName(NMM_UI)) == p.end())
57 {
58 #ifdef _WINDOWS
59 MessageBox(NULL, RS_ERROR_NOUIMODULE, Application::Title, MB_ICONEXCLAMATION);
60 Application::Terminate();
61 #else
62 // [TODO]
63 // XWindows System用のMessageBoxAどうしようか。
64 std::cout << "UI Module not found." << std::endl;
65 Application.Terminate();
66 #endif
67 return;
68 }
69
70 g_NsmSystem.Initialize();
71 }
72
73 LRESULT CALLBACK NsmMain::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
74 {
75 switch (msg)
76 {
77 HANDLE_MSG(hWnd, WM_ENDSESSION, Cls_OnEndSession);
78 }
79
80 return DefWindowProc(hWnd, msg, wParam, lParam);
81 }
82
83 void NsmMain::Cls_OnEndSession(HWND /* hwnd */, BOOL fEnding)
84 {
85 if(fEnding)
86 g_NsmSystem.Terminate();
87 }
88 }
89 }
90

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26