From 7fb6958c7a7d48087919d86a4a7820c32173a9fe Mon Sep 17 00:00:00 2001 From: zzc-1024 <1977309465@qq.com> Date: Sat, 25 Feb 2023 00:04:12 +0800 Subject: [PATCH] MinGW build fix. Fixes #14 --- CMakeLists.txt | 8 ++++++++ Sources/NodeEngine/NE_NodeEngineUtilities.hpp | 1 + Sources/NodeEngine/NE_ValueCombination.cpp | 1 + Sources/NodeUIEngine/NUIE_NodeAlignment.cpp | 1 + Sources/WindowsAppSupport/WAS_CustomControl.cpp | 1 + Sources/WindowsAppSupport/WAS_Direct2DContextBase.cpp | 5 +++-- Sources/WindowsAppSupport/WAS_GdiOffscreenContext.hpp | 6 ++++++ Sources/WindowsAppSupport/WAS_InMemoryDialog.cpp | 3 ++- .../WindowsAppSupport/WAS_IncludeWindowsHeaders.hpp | 6 ++++++ .../WindowsAppSupport/WAS_NodeEditorHwndControl.cpp | 2 +- .../WAS_NodeEditorNodeTreeHwndControl.cpp | 2 +- Sources/WindowsEmbeddingDemo/main.cpp | 4 ++++ Sources/WindowsReferenceApp/Application.cpp | 4 ++-- Sources/WindowsReferenceApp/CommandIds.hpp | 2 +- Sources/WindowsReferenceApp/main.cpp | 10 ++++++++-- 15 files changed, 46 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec05d7ca..94b53053 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,14 @@ if (WIN32) ${WindowsAppSupportSourcesFolder} ) target_link_libraries (WindowsReferenceApp NodeEngine NodeUIEngine BuiltInNodes WindowsAppSupport) + target_link_libraries( + WindowsReferenceApp + gdiplus + comctl32 + windowscodecs + d2d1 + dwrite + ) SetCompilerOptions (WindowsReferenceApp) # WindowsEmbeddingDemo diff --git a/Sources/NodeEngine/NE_NodeEngineUtilities.hpp b/Sources/NodeEngine/NE_NodeEngineUtilities.hpp index a4cb7395..c88f67b0 100644 --- a/Sources/NodeEngine/NE_NodeEngineUtilities.hpp +++ b/Sources/NodeEngine/NE_NodeEngineUtilities.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace NE { diff --git a/Sources/NodeEngine/NE_ValueCombination.cpp b/Sources/NodeEngine/NE_ValueCombination.cpp index f660e7fe..e0576ef1 100644 --- a/Sources/NodeEngine/NE_ValueCombination.cpp +++ b/Sources/NodeEngine/NE_ValueCombination.cpp @@ -4,6 +4,7 @@ #include "NE_Debug.hpp" #include +#include namespace NE { diff --git a/Sources/NodeUIEngine/NUIE_NodeAlignment.cpp b/Sources/NodeUIEngine/NUIE_NodeAlignment.cpp index c63e5889..0b8e6755 100644 --- a/Sources/NodeUIEngine/NUIE_NodeAlignment.cpp +++ b/Sources/NodeUIEngine/NUIE_NodeAlignment.cpp @@ -1,6 +1,7 @@ #include "NUIE_NodeAlignment.hpp" #include +#include namespace NUIE { diff --git a/Sources/WindowsAppSupport/WAS_CustomControl.cpp b/Sources/WindowsAppSupport/WAS_CustomControl.cpp index 6f6cc58d..582b7463 100644 --- a/Sources/WindowsAppSupport/WAS_CustomControl.cpp +++ b/Sources/WindowsAppSupport/WAS_CustomControl.cpp @@ -2,6 +2,7 @@ #include "NE_Debug.hpp" #include +#include namespace WAS { diff --git a/Sources/WindowsAppSupport/WAS_Direct2DContextBase.cpp b/Sources/WindowsAppSupport/WAS_Direct2DContextBase.cpp index 1d7ff0fd..cb2858bf 100644 --- a/Sources/WindowsAppSupport/WAS_Direct2DContextBase.cpp +++ b/Sources/WindowsAppSupport/WAS_Direct2DContextBase.cpp @@ -1,5 +1,6 @@ #include "WAS_Direct2DContextBase.hpp" #include "NE_Debug.hpp" +#include namespace WAS { @@ -130,9 +131,9 @@ Direct2DContextBase::Direct2DContextBase () : Direct2DContextBase::Direct2DContextBase (const Direct2DImageLoaderPtr& imageLoader) : NUIE::NativeDrawingContext (), - direct2DHandler (), width (0), height (0), + direct2DHandler (), imageLoader (imageLoader), renderTarget (nullptr) { @@ -165,7 +166,7 @@ void Direct2DContextBase::BeginDraw () void Direct2DContextBase::EndDraw () { HRESULT result = renderTarget->EndDraw (); - if (result == D2DERR_RECREATE_TARGET) { + if ((unsigned int)result == D2DERR_RECREATE_TARGET) { InitRenderTarget (); } } diff --git a/Sources/WindowsAppSupport/WAS_GdiOffscreenContext.hpp b/Sources/WindowsAppSupport/WAS_GdiOffscreenContext.hpp index 151577de..e01b8470 100644 --- a/Sources/WindowsAppSupport/WAS_GdiOffscreenContext.hpp +++ b/Sources/WindowsAppSupport/WAS_GdiOffscreenContext.hpp @@ -12,8 +12,14 @@ namespace WAS { +#ifdef _MSC_VER template HANDLE CreateHandle (const KeyType& key); +#else +HANDLE CreateHandle (const NUIE::PenCacheKey& key); +HANDLE CreateHandle (const NUIE::ColorCacheKey& key); +HANDLE CreateHandle (const NUIE::FontCacheKey& key); +#endif template class HandleCache diff --git a/Sources/WindowsAppSupport/WAS_InMemoryDialog.cpp b/Sources/WindowsAppSupport/WAS_InMemoryDialog.cpp index b280b09a..f48a8209 100644 --- a/Sources/WindowsAppSupport/WAS_InMemoryDialog.cpp +++ b/Sources/WindowsAppSupport/WAS_InMemoryDialog.cpp @@ -289,7 +289,8 @@ INT_PTR InMemoryDialog::Show (HWND parentHwnd, DLGPROC dialogProc, LPARAM initPa return -1; } - NONCLIENTMETRICS metrics = { sizeof (NONCLIENTMETRICS) }; + NONCLIENTMETRICS metrics; + metrics.cbSize = sizeof (NONCLIENTMETRICS); if (DBGERROR (!SystemParametersInfo (SPI_GETNONCLIENTMETRICS, 0, &metrics, 0))) { return -1; } diff --git a/Sources/WindowsAppSupport/WAS_IncludeWindowsHeaders.hpp b/Sources/WindowsAppSupport/WAS_IncludeWindowsHeaders.hpp index 9949cd33..6d28c7e3 100644 --- a/Sources/WindowsAppSupport/WAS_IncludeWindowsHeaders.hpp +++ b/Sources/WindowsAppSupport/WAS_IncludeWindowsHeaders.hpp @@ -5,11 +5,17 @@ #include #include +#ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4244) #pragma warning (disable : 4458) +#endif + #include // for gdiplus #include + +#ifdef _MSC_VER #pragma warning (pop) +#endif #endif diff --git a/Sources/WindowsAppSupport/WAS_NodeEditorHwndControl.cpp b/Sources/WindowsAppSupport/WAS_NodeEditorHwndControl.cpp index eca22bbd..21261ed4 100644 --- a/Sources/WindowsAppSupport/WAS_NodeEditorHwndControl.cpp +++ b/Sources/WindowsAppSupport/WAS_NodeEditorHwndControl.cpp @@ -11,7 +11,7 @@ static LRESULT CALLBACK NodeEditorStaticWindowProc (HWND hwnd, UINT msg, WPARAM LPCREATESTRUCT createStruct = LPCREATESTRUCT (lParam); SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) createStruct->lpCreateParams); } else if (msg == WM_DESTROY) { - SetWindowLongPtr (hwnd, GWLP_USERDATA, NULL); + SetWindowLongPtr (hwnd, GWLP_USERDATA, 0); } NodeEditorHwndControl* control = (NodeEditorHwndControl*) GetWindowLongPtr (hwnd, GWLP_USERDATA); diff --git a/Sources/WindowsAppSupport/WAS_NodeEditorNodeTreeHwndControl.cpp b/Sources/WindowsAppSupport/WAS_NodeEditorNodeTreeHwndControl.cpp index b2bccfec..c01037ba 100644 --- a/Sources/WindowsAppSupport/WAS_NodeEditorNodeTreeHwndControl.cpp +++ b/Sources/WindowsAppSupport/WAS_NodeEditorNodeTreeHwndControl.cpp @@ -14,7 +14,7 @@ static LRESULT CALLBACK NodeEditorNodeListStaticWindowProc (HWND hwnd, UINT msg, LPCREATESTRUCT createStruct = LPCREATESTRUCT (lParam); SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) createStruct->lpCreateParams); } else if (msg == WM_DESTROY) { - SetWindowLongPtr (hwnd, GWLP_USERDATA, NULL); + SetWindowLongPtr (hwnd, GWLP_USERDATA, 0); } NodeEditorNodeTreeHwndControl* control = (NodeEditorNodeTreeHwndControl*) GetWindowLongPtr (hwnd, GWLP_USERDATA); diff --git a/Sources/WindowsEmbeddingDemo/main.cpp b/Sources/WindowsEmbeddingDemo/main.cpp index 9127e668..36e07d33 100644 --- a/Sources/WindowsEmbeddingDemo/main.cpp +++ b/Sources/WindowsEmbeddingDemo/main.cpp @@ -382,7 +382,11 @@ LRESULT CALLBACK ApplicationWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPAR return DefWindowProc (hwnd, msg, wParam, lParam); } +#ifdef _MSC_VER int wWinMain (HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, int /*nCmdShow*/) +#else +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int) +#endif { WNDCLASSEX windowClass; ZeroMemory (&windowClass, sizeof (WNDCLASSEX)); diff --git a/Sources/WindowsReferenceApp/Application.cpp b/Sources/WindowsReferenceApp/Application.cpp index cc1389a9..cc5d1555 100644 --- a/Sources/WindowsReferenceApp/Application.cpp +++ b/Sources/WindowsReferenceApp/Application.cpp @@ -117,7 +117,7 @@ void Application::InitFileMenu (HWND hwnd) { HMENU file = fileMenu.AddPopupMenu (L"File"); fileMenu.AddPopupMenuItem (file, FILE_NEW, L"New"); - fileMenu.AddPopupMenuItem (file, FILE_OPEN, L"Open"); + fileMenu.AddPopupMenuItem (file, OPEN_FILE, L"Open"); fileMenu.AddPopupMenuItem (file, FILE_SAVE, L"Save"); fileMenu.AddPopupMenuSeparator (file); fileMenu.AddPopupMenuItem (file, FILE_QUIT, L"Quit"); @@ -142,7 +142,7 @@ void Application::InitToolbar (HWND hwnd) toolbar.Init (hwnd); AddToolbarItem (TOOLBAR_ENABLED_NEW_ICON, FILE_NEW); - AddToolbarItem (TOOLBAR_ENABLED_OPEN_ICON, FILE_OPEN); + AddToolbarItem (TOOLBAR_ENABLED_OPEN_ICON, OPEN_FILE); AddToolbarItem (TOOLBAR_ENABLED_SAVE_ICON, FILE_SAVE); toolbar.AddSeparator (); diff --git a/Sources/WindowsReferenceApp/CommandIds.hpp b/Sources/WindowsReferenceApp/CommandIds.hpp index da851374..19ea1bda 100644 --- a/Sources/WindowsReferenceApp/CommandIds.hpp +++ b/Sources/WindowsReferenceApp/CommandIds.hpp @@ -2,7 +2,7 @@ #define COMMANDIDS_HPP #define FILE_NEW 1101 -#define FILE_OPEN 1102 +#define OPEN_FILE 1102 #define FILE_SAVE 1103 #define FILE_QUIT 1104 #define EDIT_UNDO 1201 diff --git a/Sources/WindowsReferenceApp/main.cpp b/Sources/WindowsReferenceApp/main.cpp index dca63104..03104f95 100644 --- a/Sources/WindowsReferenceApp/main.cpp +++ b/Sources/WindowsReferenceApp/main.cpp @@ -4,12 +4,14 @@ #include "ResourceIds.hpp" #include "CommandIds.hpp" +#ifdef _MSC_VER #pragma comment (lib, "gdiplus.lib") #pragma comment (lib, "comctl32.lib") #pragma comment (lib, "windowscodecs.lib") #pragma comment (lib, "d2d1.lib") #pragma comment (lib, "dwrite.lib") #pragma comment (linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif LRESULT CALLBACK ApplicationWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -17,7 +19,7 @@ LRESULT CALLBACK ApplicationWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPAR LPCREATESTRUCT createStruct = LPCREATESTRUCT (lParam); SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) createStruct->lpCreateParams); } else if (msg == WM_DESTROY) { - SetWindowLongPtr (hwnd, GWLP_USERDATA, NULL); + SetWindowLongPtr (hwnd, GWLP_USERDATA, 0); PostQuitMessage (0); } @@ -70,7 +72,7 @@ LRESULT CALLBACK ApplicationWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPAR case FILE_NEW: application->New (hwnd); break; - case FILE_OPEN: + case OPEN_FILE: application->Open (hwnd); break; case FILE_SAVE: @@ -111,7 +113,11 @@ LRESULT CALLBACK ApplicationWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPAR return DefWindowProc (hwnd, msg, wParam, lParam); } +#ifdef _MSC_VER int wWinMain (HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, int /*nCmdShow*/) +#else +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int) +#endif { EnableLeakDetection (); InitCommonControls ();