How to get HWND of an OpenGL window


As the OpenGL context hosted in a native window, which makes the opengl component heavy-weight, I think there must be a way to obtain the HWND of that window. (I’m currently working on WinXP.) However, I was lost in looking for this in the document.

I can find this OpenGL window by spy++ and its handle. But I’m not sure if it is exposed in JUCE.
Can anybody give me a hint?

Thank you in advance!

I think that’d need some hacks to the openglcomponent to make it returns its window handle. Not too difficult to do, I’ll check something in when I get chance.

Thank you , Jules!

In general, if you could add a member function to return the native window handle/ID for all the components containing heavy window, that would be very convenient when we want to integrate JUCE with some other toolkits.

Hi, Jules,

Or even more generally, provide a component/class which create a new empty native window by default, and of course return also the handle/ID of that heavy weight window. This is something like an empty 2D canvas, people can draw what they like by OS-specific api or by some other graphic toolkits. In fact, the openglcomponent just provides an empty 3D canvas. We still need a 2D one.

Do you think this is a reasonable demand? Does that need a lot of work?

(Now I’m working with some 3D engine which can render the scene to some external window if the window handle/id is available, that’s why I need empty heavy-weight windows. )

That’s a pretty sensible demand, kind of similar to the ActiveXComponent class. I’m up to my ears in mac Cocoa stuff at the moment, so don’t have time, but it’s not a huge amount of work.

Thank you for the reply! OK, no hurry. I’ve found a workaround by doing some native coding on win32.

The activexcomponent reads a classid if I want to have a native window. Is there a way to just create a native window without giving a controlID?

I think the control window only gets created on-demand when you open a control, so that’s probably not possible.