1

i am trying to embed a c++ opengl window in a java window. I'm able to send the HWND of the opengl window to the java window through sockets. I'd rather not use JNI for it as i want to have 2 seperate process (the why doesn't matter). I made my search and found out this could be possible by using User32's function SetParent(HWND childWindow, HWND parentWindow). However, i'm unable to use it properly or can't find the steps to use User32. So this might be an issue related to Embed HWND (Window Handle) in a JPanel which is quite what i want to do but i wasn't able to reproduce the solution as i wasn't able to use User32 (cannot be resolved) even if i made the following imports : import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.Pointer;

I was also unable to use WComponentPeer but i haven't done much search on the subject.

Thanks in advance

Community
  • 1
  • 1

1 Answers1

1

You need the User32 interface mapping from JNA's platform.jar.

See these notes for getting started.

technomage
  • 9,861
  • 2
  • 26
  • 40
  • Ok i've managed to find a way of getting the HWND of a canvas in which i could probably embed the c++ opengl window. Now i am having issue trying to convert a string representing the pointer to the c++ opengl window to an actual Windef.HWND in java. Any ideas ? – user1628526 Aug 31 '12 at 17:47
  • Assuming you've got `String s="0x01234"`, you can do `Integer.parseInt(s, 16)`. Though if the method you're using to obtain the pointer value doesn't let you capture the original 32- or 64-bit value, I'm not sure I'd trust it. You can create an `HWND` de novo given a `Pointer` value. – technomage Aug 31 '12 at 18:01