From df9c524bc38b9165c88e1dbe0aac66ba9440fba5 Mon Sep 17 00:00:00 2001 From: Jeremy Bernstein Date: Sat, 19 Feb 2022 13:32:50 +0100 Subject: [PATCH] Windows: fix cmake-based build problems & optimization of release build --- CMakeLists.txt | 3 ++- reaper_automidireset.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e59fd0c..cd17f0d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,9 @@ if (APPLE) endif () if (WIN32) - add_definitions(-DUNICODE) + add_definitions(-DUNICODE -D_UNICODE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(LIBS user32.lib) endif () diff --git a/reaper_automidireset.cpp b/reaper_automidireset.cpp index b7ae5bb..f367397 100644 --- a/reaper_automidireset.cpp +++ b/reaper_automidireset.cpp @@ -31,7 +31,7 @@ #include "reaper_plugin_functions.h" #include -#define VERSION_STRING "1.2-beta.2" +#define VERSION_STRING "1.2-beta.3" static int commandId = 0; @@ -343,13 +343,16 @@ DWORD WINAPI window_thread(LPVOID params) wndClass.hInstance = (HINSTANCE) GetModuleHandle(NULL); if (params == kMidiDeviceType) { - wndClass.lpfnWndProc = (WNDPROC) midi_hardware_status_callback; + wndClass.lpfnWndProc = (WNDPROC)midi_hardware_status_callback; wndClass.lpszClassName = WND_CLASS_MIDI_NAME; - assert(RegisterClassEx(&wndClass) && "error registering dummy window"); - hDummyWindow = CreateWindow(WND_CLASS_MIDI_NAME, L"midi window", WS_ICONIC, - 0, 0, CW_USEDEFAULT, 0, NULL, NULL, wndClass.hInstance, NULL); - assert((hDummyWindow != NULL) && "failed to create window"); - ShowWindow(hDummyWindow, SW_HIDE); + ATOM registered = RegisterClassEx(&wndClass); + if (registered) { + hDummyWindow = CreateWindow(WND_CLASS_MIDI_NAME, L"midi window", WS_ICONIC, + 0, 0, CW_USEDEFAULT, 0, NULL, NULL, wndClass.hInstance, NULL); + if (hDummyWindow) { + ShowWindow(hDummyWindow, SW_HIDE); + } + } } PostMessage(hDummyWindow, WM_MIDI_INIT, 0, 0); // call initLists();