@@ -582,11 +582,10 @@ static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
582
582
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
583
583
{
584
584
// Most backends don't have silent checks like this one, but we need it because WndProc are called early in CreateWindow().
585
- if (ImGui::GetCurrentContext () == nullptr )
586
- return 0 ;
587
-
585
+ // We silently allow both context or just only backend data to be nullptr.
588
586
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData ();
589
- IM_ASSERT (bd != nullptr && " Context or backend not initialized! Did you call ImGui_ImplWin32_Init()?" );
587
+ if (bd == nullptr )
588
+ return 0 ;
590
589
ImGuiIO& io = ImGui::GetIO ();
591
590
592
591
switch (msg)
@@ -609,10 +608,10 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
609
608
}
610
609
POINT mouse_pos = { (LONG)GET_X_LPARAM (lParam), (LONG)GET_Y_LPARAM (lParam) };
611
610
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient (hwnd, &mouse_pos) == FALSE ) // WM_NCMOUSEMOVE are provided in absolute coordinates.
612
- break ;
611
+ return 0 ;
613
612
io.AddMouseSourceEvent (mouse_source);
614
613
io.AddMousePosEvent ((float )mouse_pos.x , (float )mouse_pos.y );
615
- break ;
614
+ return 0 ;
616
615
}
617
616
case WM_MOUSELEAVE:
618
617
case WM_NCMOUSELEAVE:
@@ -625,7 +624,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
625
624
bd->MouseTrackedArea = 0 ;
626
625
io.AddMousePosEvent (-FLT_MAX, -FLT_MAX);
627
626
}
628
- break ;
627
+ return 0 ;
629
628
}
630
629
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
631
630
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
0 commit comments