0

我花了一些时间尝试通过在 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 的后续调用给了我"The function completed successfully"。此外,如果我调用 GetAncestor(childButton,3),我会将句柄返回给 parentWindowHandler。我也可以调用 GetWindowTextA(childButton..bla) 并获得Show Message字符串。所以,显然我已经创建了 parentWindow 的一个孩子,它就在那里。但是,它是不可见的。接下来想到的是我的窗口/标签位于其父级的 z-index 的底部,因此必须进行一些其他调用,我打算这样做。但如果我走错了方向,我只会浪费一点时间。

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

任何指针?

4

1 回答 1

0

是的,这正是我的想法,但略有不同。需要将 WM_PAINT 消息发送到父窗口以使其刷新。

于 2010-10-27T13:28:10.173 回答