Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using different HWNDs in one ImGui instance #8126

Open
mintygingy opened this issue Nov 4, 2024 · 2 comments
Open

Using different HWNDs in one ImGui instance #8126

mintygingy opened this issue Nov 4, 2024 · 2 comments

Comments

@mintygingy
Copy link

Version/Branch of Dear ImGui:

Version 1.90, Branch: docking

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx11.cpp

Compiler, OS:

Windows 10 + MSVC 143

Full config/build information:

No response

Details:

Question: is it possible to assign different ImGui windows to different HWNDs without using multiple viewports?

My goal is to have two independent ImGui windows. Thing is, i can't use Docking's MultiViewports for a reason - impossibility of rounded\transparent windows. I fixed that by creating a host fully-transparent HWND with required size, which im passing to ImGui_ImplWin32_Init(hwnd), and keeping my ImGui window inside that HWND. That worked just like a charm, but in that case i cant create any other ImGui windows, cause my HWND is limited in size to main ImGui window.

Maybe it's possible to make something like ImGui::Begin("foo", g_hwnd1)?
I also wouldn't mind setting up my transparent-HWND workaround somewhere in imgui_impl, let me know where could i do it

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@cfillion
Copy link
Contributor

cfillion commented Nov 4, 2024

Thing is, i can't use Docking's MultiViewports for a reason - impossibility of rounded\transparent windows
I also wouldn't mind setting up my transparent-HWND workaround somewhere in imgui_impl, let me know where could i do it

Transparent/rounded windows are possible with minimal changes: #5988 (comment)

@ocornut
Copy link
Owner

ocornut commented Nov 4, 2024

I fixed that by creating a host fully-transparent HWND with required size
I also wouldn't mind setting up my transparent-HWND workaround somewhere in imgui_impl, let me know where could i do it

Indeed if you know how to do that then you can most probably do the same thing on Platform Windows created by the viewport system.

See how the backend is assigning hooks:

    ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
    platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
    platform_io.Platform_DestroyWindow = ImGui_ImplWin32_DestroyWindow;
    platform_io.Platform_ShowWindow = ImGui_ImplWin32_ShowWindow;

You can either modify those function (first step).
Then (second step) instead of modifying the backend, do the same thing externally: store those function pointers after calling ImGui_ImplWin32_Init(), replace them with your own functions, and in your own function you can call the original function + add your code before/after the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants