2010-10-27 150 views
0

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

这里是我的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)并将获取显示消息字符串。 所以,显然我创建了parentWindow的一个子元素,它就在那里。但是,它不可见。接下来要记住的是,我的窗口/标签位于父级的z-index的底部,因此必须进行一些其他调用,我打算这样做。但是如果我在错误的方向,我会浪费一点时间。

我如何让这个孩子可见或我做错了什么。 您应该注意,我不会在回叫中调用此函数或发送任何味精。

任何指针?

回答

0

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

相关问题