嵌入HWND(窗口句柄)在一个JPanel [英] Embed HWND (Window Handle) in a JPanel

查看:737
本文介绍了嵌入HWND(窗口句柄)在一个JPanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个JPanel嵌入HWND(窗口句柄)。

I am trying to embed a HWND (Window Handle) in a JPanel.

其实,我可以嵌入我的HWND成一个JFrame,但嵌入式窗口送花儿给人留在其他部件之上,我不能移动它。如果尝试删除我的JFrame的所有子组件,该HWND呆在那里。该HWND似乎是搽在JFrame的顶部,而不是作为一个孩子。

Actually, I can embed my HWND into a JFrame, but the embedded window alway stay on top of the other component and I can't move it. If a try to remove all the child component of my JFrame, the HWND stay there. The HWND seems to be paint on top of the JFrame and not as one of is child.

要嵌入HWND到JPanel中我使用USER32通过JNA:

To embed the HWND into the JPanel I use User32 through jna:

User32.SetParent(iage.getRenderHwnd(), (int) getGUIHwnd(j));

和我使用它来得到我的JFrame的HWND:

And I use this to get the HWND of my JFrame:

j.getPeer() != null ? ((WComponentPeer) j.getPeer()).getHWnd(): 0;

有没有一种方法嵌入到HWND一个JPanel或将其添加到其他组件,因此就像我在我的UI婉我可以定位吗?

Is there a way to embed a HWND into a JPanel or to add it into an other component so I can position it like I wan in my UI?

感谢

推荐答案

JPanels的轻量化部件(他们有没有真正的本土同行)。即它们使用已在(J)的框架的手柄。看看java.awt.Canvas中。

JPanels are lightweighted components (they have no real native peer). i.e. they use already the handle of the (J)Frame. Look at java.awt.Canvas.

这篇关于嵌入HWND(窗口句柄)在一个JPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆