【问题标题】:How to create a Microsoft Windows Child window using JNA如何使用 JNA 创建 Microsoft Windows 子窗口
【发布时间】:2010-10-27 13:21:53
【问题描述】:

我花了一些时间尝试通过在 JNA (Java Native Access) 上使用以下代码来创建现有窗口的子窗口,但我想这与尝试使用 Windows 的所有其他编程语言几乎相同API。

这是我对 CreateWindowsExA 的声明:

public int CreateWindowExA(int i, String string, String string0, int i0, int i1, int i2, int i3, int i4, int ninja, Object object, Object object0, int i5);

我是这样称呼它的:

int childLabel = user32.CreateWindowExA
(
   0, //sets style to default
   "STATIC", //window style is label
   "Show Message", //label text is show Message
   1342177280, // WS_CHILD + WS_VISIBLE  = &H40000000 + &H10000000
   10,         //x
   90,         //y
   100,        //width
   0,          //height 
   parentWindowHandler,   //a valid handler to a window (has been tested and is valid)
   null,    // a handler to a menu             
   null,  //A handle to the instance of the module to be associated with the window. (NO IDEA)
   0      //arguments list (no idea)
);

调用该函数后,我得到一个 有效的处理程序 到按钮... 但它是不可见的。对 getLastError 的调用和对 TranslateMessage 的后续调用给了我“函数已成功完成”。 此外,如果我调用 GetAncestor(childButton,3),我会将句柄返回给 parentWindowHandler。 我也可以调用 GetWindowTextA(childButton..bla) 并获得 Show Message 字符串。 所以,显然我已经创建了 parentWindow 的一个孩子,它就在那里。但是,它是不可见的。接下来想到的是我的窗口/标签位于其父级的 z-index 的底部,因此必须进行一些其他调用并且我打算这样做。但如果我走错了方向,我只会浪费一点时间。

我如何让这个孩子可见或我做错了什么。 您应该注意,我不会在回调中调用它或发送任何消息。

任何指针?

【问题讨论】:

    标签: c# windows jna createwindowex


    【解决方案1】:

    是的,这正是我的想法,但略有不同。需要向父窗口发送一条 WM_PAINT 消息,以便它刷新。

    【讨论】:

      猜你喜欢
      • 2011-05-01
      • 2013-02-24
      • 2011-10-26
      • 1970-01-01
      • 2012-04-08
      • 2012-09-11
      • 2010-10-21
      • 2010-10-30
      • 2010-11-13
      相关资源
      最近更新 更多