From dd89c9ea59af9f8b832fc3fc024166e000d40225 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 21 Jan 2018 20:58:50 +0100 Subject: [PATCH] Examples: Made the Win32 proc handlers not assert if there is no active context yet, to be more flexible with creation order. (#1565) --- examples/directx10_example/imgui_impl_dx10.cpp | 3 +++ examples/directx11_example/imgui_impl_dx11.cpp | 3 +++ examples/directx9_example/imgui_impl_dx9.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/examples/directx10_example/imgui_impl_dx10.cpp b/examples/directx10_example/imgui_impl_dx10.cpp index 66b411e4..2ba65494 100644 --- a/examples/directx10_example/imgui_impl_dx10.cpp +++ b/examples/directx10_example/imgui_impl_dx10.cpp @@ -243,6 +243,9 @@ static bool IsAnyMouseButtonDown() // PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + if (ImGui::GetCurrentContext() == NULL) + return 0; + ImGuiIO& io = ImGui::GetIO(); switch (msg) { diff --git a/examples/directx11_example/imgui_impl_dx11.cpp b/examples/directx11_example/imgui_impl_dx11.cpp index 61860f5c..1df2e30f 100644 --- a/examples/directx11_example/imgui_impl_dx11.cpp +++ b/examples/directx11_example/imgui_impl_dx11.cpp @@ -250,6 +250,9 @@ static bool IsAnyMouseButtonDown() // PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + if (ImGui::GetCurrentContext() == NULL) + return 0; + ImGuiIO& io = ImGui::GetIO(); switch (msg) { diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp index af30fbf4..bd42ecad 100644 --- a/examples/directx9_example/imgui_impl_dx9.cpp +++ b/examples/directx9_example/imgui_impl_dx9.cpp @@ -189,6 +189,9 @@ static bool IsAnyMouseButtonDown() // PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + if (ImGui::GetCurrentContext() == NULL) + return 0; + ImGuiIO& io = ImGui::GetIO(); switch (msg) {