|
@@ -1158,11 +1158,20 @@ static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
|
|
|
return ImVec2((float)pos.x, (float)pos.y);
|
|
|
}
|
|
|
|
|
|
+static void ImGui_ImplWin32_UpdateWin32StyleFromWindow(ImGuiViewport* viewport)
|
|
|
+{
|
|
|
+ ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
|
|
+ vd->DwStyle = ::GetWindowLongW(vd->Hwnd, GWL_STYLE);
|
|
|
+ vd->DwExStyle = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE);
|
|
|
+}
|
|
|
+
|
|
|
static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
|
|
{
|
|
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
|
|
IM_ASSERT(vd->Hwnd != 0);
|
|
|
RECT rect = { (LONG)pos.x, (LONG)pos.y, (LONG)pos.x, (LONG)pos.y };
|
|
|
+ if (viewport->Flags & ImGuiViewportFlags_OwnedByApp)
|
|
|
+ ImGui_ImplWin32_UpdateWin32StyleFromWindow(viewport); // Not our window, poll style before using
|
|
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
|
|
|
::SetWindowPos(vd->Hwnd, nullptr, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
|
}
|
|
@@ -1181,6 +1190,8 @@ static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
|
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
|
|
IM_ASSERT(vd->Hwnd != 0);
|
|
|
RECT rect = { 0, 0, (LONG)size.x, (LONG)size.y };
|
|
|
+ if (viewport->Flags & ImGuiViewportFlags_OwnedByApp)
|
|
|
+ ImGui_ImplWin32_UpdateWin32StyleFromWindow(viewport); // Not our window, poll style before using
|
|
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
|
|
|
::SetWindowPos(vd->Hwnd, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
}
|
|
@@ -1227,14 +1238,14 @@ static void ImGui_ImplWin32_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
|
|
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
|
|
|
if (alpha < 1.0f)
|
|
|
{
|
|
|
- DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
|
|
|
- ::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
|
|
+ DWORD ex_style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
|
|
|
+ ::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, ex_style);
|
|
|
::SetLayeredWindowAttributes(vd->Hwnd, 0, (BYTE)(255 * alpha), LWA_ALPHA);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED;
|
|
|
- ::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
|
|
+ DWORD ex_style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED;
|
|
|
+ ::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, ex_style);
|
|
|
}
|
|
|
}
|
|
|
|