about summary refs log tree commit diff stats
path: root/Source/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Main.cpp')
-rw-r--r--Source/Main.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/Source/Main.cpp b/Source/Main.cpp index 5c7cefa..8a7a5bb 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp
@@ -16,7 +16,6 @@
16HINSTANCE hInst; 16HINSTANCE hInst;
17WCHAR szWindowClass[MAX_LOADSTRING]; 17WCHAR szWindowClass[MAX_LOADSTRING];
18HWND hwndSeed; 18HWND hwndSeed;
19std::shared_ptr<Randomizer> randomizer;
20 19
21// Forward declares 20// Forward declares
22ATOM MyRegisterClass(HINSTANCE hInstance); 21ATOM MyRegisterClass(HINSTANCE hInstance);
@@ -31,10 +30,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
31 if (!InitInstance(hInstance, nCmdShow)) { 30 if (!InitInstance(hInstance, nCmdShow)) {
32 return FALSE; 31 return FALSE;
33 } 32 }
34 randomizer = std::make_shared<Randomizer>();
35 if (randomizer == nullptr) {
36 return FALSE;
37 }
38 33
39 MSG msg; 34 MSG msg;
40 while (!GetMessage(&msg, nullptr, 0, 0) == 0) 35 while (!GetMessage(&msg, nullptr, 0, 0) == 0)
@@ -107,18 +102,12 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
107 102
108LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 103LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
109{ 104{
110 if (WM_COMMAND == WM_DESTROY) { 105 if (message == WM_DESTROY) {
111 PostQuitMessage(0); 106 PostQuitMessage(0);
112 } else { 107 } else if (message == WM_COMMAND) {
113 int wmId = LOWORD(wParam); 108 int wmId = LOWORD(wParam);
114 // Parse the menu selections: 109 // Parse the menu selections:
115 switch (wmId) 110 if (wmId == IDC_RANDOMIZE) {
116 {
117 case IDM_ABOUT:
118 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
119 break;
120 case IDC_RANDOMIZE:
121 {
122 std::wstring text(100, '\0'); 111 std::wstring text(100, '\0');
123 GetWindowText(hwndSeed, &text[0], 100); 112 GetWindowText(hwndSeed, &text[0], 100);
124 int seed = 0; 113 int seed = 0;
@@ -131,15 +120,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
131 } else { 120 } else {
132 seed = _wtoi(text.c_str()); 121 seed = _wtoi(text.c_str());
133 } 122 }
134 randomizer->Randomize(seed); 123 srand(seed);
135 124 Randomizer().Randomize();
136 break;
137 }
138 case IDM_EXIT:
139 DestroyWindow(hWnd);
140 break;
141 default:
142 return DefWindowProc(hWnd, message, wParam, lParam);
143 } 125 }
144 } 126 }
145 return DefWindowProc(hWnd, message, wParam, lParam); 127 return DefWindowProc(hWnd, message, wParam, lParam);