# No rendering on child windows created by SetParent native api method

**URL:** <https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168>\
**Category:** support\
**Created:** [October 7, 2022, 3:02pm UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168 "2022-10-07T15:02:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrashantSaxena](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@PrashantSaxena](https://discourse.glfw.org/u/PrashantSaxena)\
**Post date:** [October 7, 2022, 3:02pm UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168/1 "2022-10-07T15:02:22Z")

</div>

Hi,  
glfw 3.3.2  
windows 10  
mingw32

I am creating a unified window system and using native api using SetParent function.

`SetParent(glfwGetWin32Window(child), glfwGetWin32Window(parent));`

It’s working perfectly fine and all the child windows seamlessly become one with the main window. All the child windows are created with no decoration. However, the problem is that when rendering, nothing appears. I’m setting the context using **glfwMakeContextCurrent(child)** just before rendering on the child window but nothing appears.  
After searching on google I even tried this:

```auto
glfwMakeContextCurrent( window );   
auto hglrc = glfwGetWGLContext(window);
auto current_dc = wglGetCurrentDC();
wglMakeCurrent(current_dc, hglrc);

```

still no luck!!! If I don’t use the SetParent call then everything renders perfectly but that’s not the purpose. I would appreciate if someone point out the correct way to do it.  
Cheers

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [October 12, 2022, 9:57am UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168/2 "2022-10-12T09:57:12Z")

</div>

Hi PrashantSaxena ,

Welcome to the GLFW forum.

I don’t know enough about child windows and OpenGL since when I’ve needed this behaviour I’ve simply closed the second window and rendered the window content to a region of the main window directly - this is also how the popular [Dear ImGui docking branch works](https://github.com/ocornut/imgui/issues/2109).

I did find a bit of code on Github using GLFW and SetParent, which I can’t find again (sorry). However it appeared to be resting some style attributes similar to the post below:

> [@Attach A GLFWwindow To Windows Window Client Area?](https://discourse.glfw.org/t/attach-a-glfwwindow-to-windows-window-client-area/882/7):
>
> I know this is old but will explain how I did it for those who also had issues. BEFORE you #include your glfw includes, define the native win32 glfw exposure such as: #define GLFW\_EXPOSE\_NATIVE\_WIN32 #include \<GLFW/glfw3.h\> #include \<GLFW/glfw3native.h\> Next, make sure to include the glfw3native.h as shown above. Clean and rebuild and you should then have access to the function “HWND glfwGetWin32Window(GLFWwindow \*window)” which returns a HWND handle from your GLFWwindow Next, create a sta…

Perhaps that might work for you?

Good luck,  
Doug.

---

<div class="post-metadata">

**Author:** ![Majisto](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Majisto](https://discourse.glfw.org/u/Majisto)\
**Post date:** [July 6, 2023, 7:55am UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168/3 "2023-07-06T07:55:44Z")

</div>

Did anyone manage to figure this out? I tried the solution posted above and it didn’t work.

---

<div class="post-metadata">

**Author:** ![PrashantSaxena](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@PrashantSaxena](https://discourse.glfw.org/u/PrashantSaxena)\
**Post date:** [July 9, 2023, 1:34pm UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168/4 "2023-07-09T13:34:30Z")

</div>

Hello [Majisto](https://discourse.glfw.org/u/Majisto)  
Well to be honest if you are seriously interested in parent-child stuff then better you go native and leave glfw. glfw was never designed to do this kind of stuff. Yes, you can make a child window but there is no point in doing so when all your windows are floating on your desktop screen.  
Initially, I tried a lot to make this work in glfw but in the last, I gave up because it was not worth going that road. Later I programmed a multi-window manager individually using native api on all three major OS, Linux, OSX and MSWIN. It was kind of re-inventing the wheel but you can trust my words, it was worth it.

Why I did do so? Nowadays one can easily buy a 4k or 8k monitor and they are becoming part of mainstream rapidly. Even if you enable vertical sync, wait for events and do all kind of optimizations in glfw or the same, refreshing 4k-8k screen at 60 times per second is not at all a good idea. This issue is greatly discussed in a post at [ImGui](https://github.com/ocornut/imgui) where users were complaining about the constant buzzing of gpu and cpu fans even when the system is laying idle.

Prashant

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 10, 2023, 9:51am UTC](https://discourse.glfw.org/t/no-rendering-on-child-windows-created-by-setparent-native-api-method/2168/5 "2023-07-10T09:51:31Z")

</div>

> [@PrashantSaxena](#):
>
> Even if you enable vertical sync, wait for events and do all kind of optimizations in glfw or the same, refreshing 4k-8k screen at 60 times per second is not at all a good idea. This issue is greatly discussed in a post at [ImGui](https://github.com/ocornut/imgui) where users were complaining about the constant buzzing of gpu and cpu fans even when the system is laying idle.

Adding idle handling (for minimized state and also no input or animation) code to a GLFW app is fairly trivial. This [GLFW with Runtime Compiled C++ and Dear ImGui example](https://github.com/juliettef/RCCpp-DearImGui-GLFW-example) has a section in the readme with a link to the code on power saving. I would also add a check for whether your windows are `GLFW_ICONIFIED` and disable rendering and GUI for them if they are.
