public class Wnd extends Handle
HWND
native Windows data type.Modifier and Type | Class and Description |
---|---|
static class |
Wnd.Ancestor
Enumeration of possible window ancestors.
|
static class |
Wnd.HotKey
The options class for determining a combination of hot key modifiers.
|
static class |
Wnd.ShowWindowCommand
ShowWindowCommand class represents enumeration of commands to use in
ShowWindow function.
|
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
Constructor and Description |
---|
Wnd() |
Wnd(java.awt.Component component)
Constructs an instance getting the handle from the passed AWT component.
|
Wnd(long value)
Constructs a new instance with the passed handle value.
|
Modifier and Type | Method and Description |
---|---|
DC |
beginPaint(PaintStruct paintStruct)
Prepares a specified window for painting.
|
void |
bringToTop()
Brings the window to the top of the Z order.
|
static long |
callWindowProc(Handle wndProc,
Wnd wnd,
com.jniwrapper.UInt msg,
com.jniwrapper.Pointer.Void wParam,
com.jniwrapper.Pointer.Void lParam)
Passes message information to a specified window procedure.
|
void |
centerInDesktop()
Centers the window over the desktop.
|
Point |
clientToScreen(Point point)
Converts the client-area coordinates of a specified point to screen
coordinates.
|
java.lang.Object |
clone() |
static Wnd |
createWindow(int windowStyleEx,
java.lang.String className,
java.lang.String windowName,
int windowStyle,
long x,
long y,
long nWidth,
long nHeight,
Wnd hWndParent,
Handle hMenu,
Handle hInstance,
Handle lpParam)
Creates a new window with extended style.
|
static Wnd |
createWindow(java.lang.String className)
Creates a new window by its class name.
|
static Wnd |
createWindow(java.lang.String className,
java.lang.String windowName,
int windowStyle,
long x,
long y,
long nWidth,
long nHeight,
Wnd hWndParent,
Handle hMenu,
Handle hInstance,
Handle lpParam)
Creates a new window.
|
void |
destroy()
Destroys a window.
|
boolean |
enableWindow(boolean enable)
This function is designed for enabling/disabling this window.
|
void |
endPaint(PaintStruct paintStruct)
Marks the end of painting.
|
void |
eventLoop()
Executes event loop for itself.
|
static void |
eventLoop(long hwnd)
Executes infinite event loop handling cycle for the window specified by
the passed handle value.
|
static Wnd |
findWindow(java.lang.String className)
Searches a window by a specified class name.
|
static Wnd |
findWindow(java.lang.String className,
java.lang.String windowName)
Searches the window by a specified class name and its title.
|
static Wnd |
findWindowByName(java.lang.String windowName)
Searches a window by a specified name.
|
static Wnd |
findWindowEx(Wnd parent,
java.lang.String className,
java.lang.String windowName)
Searches a child window by specified class name and its title.
|
boolean |
flashWindow(FlashInfo flashInfo)
Starts or stops window flashing depending on a passed parameter.
|
static java.util.List |
getAllWindows()
Returns all top-level windows on the screen.
|
Wnd |
getAncestor(Wnd.Ancestor ancestor)
Returns the ancestor of this window.
|
Rect |
getBounds()
Returns window bounds.
|
java.util.List |
getChildWindows()
Returns child windows that belong to the current window.
|
static java.util.List |
getChildWindows(Wnd parent)
Returns child windows that belong to a specified parent window.
|
Rect |
getClientRect()
Returns a window client rectangle.
|
Size |
getClientSize()
Returns window's client size (width and height).
|
static Wnd |
getDesktopWindow()
Returns a desktop window handle.
|
java.lang.String |
getDlgItemText(int idDlgItem)
Returns the title or text associated with a control in a dialog box.
|
static Wnd |
getFocus()
Retrieves window that has keyboard focus if the window is attached to the message
queue of calling thread.
|
static Wnd |
getForegroundWindow()
Returns a handle to the foreground window (the window with which the user is currently working).
|
Wnd.HotKey |
getHotKey()
Returns the currently set window hot key or
null if hot key isn't set. |
boolean |
getLayeredWindowAttributes(ColorRef crKey,
com.jniwrapper.Int8 bAlpha,
com.jniwrapper.UInt32 dwFlags)
Retrieves the opacity and transparency color key of a layered window.
|
Wnd |
getParent()
Returns the window parent.
|
int |
getProcessId()
Returns the process identifier.
|
Region |
getRegion()
Returns a copy of the window region of a window.
|
Size |
getSize()
Returns window size (width and height).
|
int |
getThreadId()
Returns the identifier of the thread that created this window.
|
static java.util.List |
getThreadWindows(long threadID)
Returns all non-child windows associated with a specified thread.
|
byte |
getTransparency() |
boolean |
getUpdateRect(Rect rect)
Retrieves the coordinates of the smallest rectangle that completely
encloses the update region of the specified window.
|
boolean |
getUpdateRect(Rect rect,
boolean erase)
Retrieves the coordinates of the smallest rectangle that completely
encloses the update region of the specified window.
|
Wnd |
getWindow(int uCmd)
Returns a child, parent or sibling window for the current window.
|
java.lang.String |
getWindowClassName()
Returns the name of the window class.
|
long |
getWindowExStyle() |
static Wnd |
getWindowFromPoint(int x,
int y)
Returns a handle to the window that contains the specified point.
|
long |
getWindowLong(int nIndex)
Returns an attribute of the window.
|
WindowPlacement |
getWindowPlacement()
Retrieves the show state and the restored, minimized, and maximized positions of the window.
|
Rect |
getWindowRect()
Returns the bounding rectangle of the window.
|
long |
getWindowStyle() |
java.lang.String |
getWindowText()
Returns text of a specified window's title bar (if it has one).
|
void |
invalidateRect(Rect rect,
boolean erase)
Adds a rectangle to the specified window's update region.
|
boolean |
isBorderVisible()
Checks if the window border is visible.
|
boolean |
isCaptionVisible()
Checks if the window caption is visible.
|
boolean |
isMaximized()
Checks if the window is maximized.
|
boolean |
isMinimized()
Checks if this window is minimized.
|
boolean |
isPalleteWindow() |
boolean |
isTransparent() |
boolean |
isVisible()
Returns true if the window is visible.
|
boolean |
isWindow()
Checks if this handle is real pointer to an existing window.
|
void |
moveWindow(int x,
int y,
int width,
int height)
Changes the position and dimensions of a specified window.
|
void |
moveWindow(int x,
int y,
int width,
int height,
boolean repaint)
Changes the position and dimensions of a specified window.
|
boolean |
peekMessage(long msg,
boolean remove) |
boolean |
peekMessage(Msg msg,
long filterMin,
long filterMax,
boolean remove) |
boolean |
postMessage(int msg,
long wParam,
long lParam)
Posts a message in the message queue.
|
void |
redraw(Rect updateRect,
Region updateRegion,
int flags)
Updates a specified rectangle or region in the window's client area.
|
Point |
screenToClient(Point point)
Converts the screen coordinates of a specified point on the screen to
client-area coordinates.
|
boolean |
sendMessage(int msg,
long wParam,
long lParam)
Deprecated.
use sendMessageEx(int, long, long) instead.
|
long |
sendMessage(int msg,
com.jniwrapper.Parameter wParam,
com.jniwrapper.Parameter lParam)
Sends a message to the specified window.
|
long |
sendMessageEx(int msg,
long wParam,
long lParam)
Sends a message to a window.
|
void |
setBorderVisible(boolean value)
Shows or hides the window border.
|
void |
setCaptionVisible(boolean value)
Shows or hides the window caption.
|
void |
setContinuousRepainting(boolean value)
Forces continuous window repainting.
|
boolean |
setDlgItemText(int idDlgItem,
java.lang.String string)
Sets the title or text of a control in a dialog box.
|
Wnd |
setFocus()
Sets the keyboard focus to the specified window.
|
void |
setForeground()
Puts the thread that created the specified window into the foreground and activates
the window.
|
void |
setHotKey(Wnd.HotKey hotKey)
Registers a system-wide hot key, which activates the window, that corresponds to this handle.
|
void |
setLayeredWindowAttributes(ColorRef crKey,
byte bAlpha,
int dwFlags)
Sets opacity and transparency of a layered window.
|
void |
setPalleteWindow(boolean palleteWindow)
Sets a pallete window style.
|
void |
setParent(Wnd parent)
Changes the parent of a window.
|
boolean |
setPosition(Wnd wndInsertAfter,
long x,
long y,
long cx,
long cy,
long flags)
Changes the size, position, and Z order of a window.
|
Region |
setRegion(Region region)
Sets a custom window region.
|
void |
setRegion(Region region,
boolean redraw)
Sets a new window region.
|
void |
setRounded(boolean rounded)
Makes the window rounded (with rounded corners).
|
void |
setRounded(boolean rounded,
int ellipseWidth,
int ellipseHeight)
Makes the window rounded (with rounded corners).
|
void |
setTopmost(boolean topmost)
Makes window topmost.
|
void |
setTransparency(byte transparency)
Sets window transparency.
|
void |
setTransparent(boolean transparent)
Sets or removes window transparancy.
|
void |
setTransparent(byte transparency)
Sets or remove window trancparency.
|
void |
setVisible(boolean visible)
Shows or hides the window.
|
void |
setWindowExStyle(long flags)
Sets extended window style.
|
void |
setWindowIcon(Icon icon,
Icon.IconType iconType)
Assigns a specified icon to the window.
|
void |
setWindowLong(int nIndex,
long dwNewLong)
Sets an attribute of the window.
|
long |
setWindowLong(int nIndex,
com.jniwrapper.Parameter newValue)
Sets an attribute of the window.
|
void |
setWindowPlacement(WindowPlacement placement)
Set new window placement.
|
void |
setWindowStyle(long flags)
Sets window style.
|
void |
show(Wnd.ShowWindowCommand command)
Sets a specified window's show state.
|
void |
update()
Updates the client area of the window.
|
closeHandle, equals, waitFor, waitFor
asFunction, asFunction, asTypedPointer, castTo, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
public static final int GW_HWNDFIRST
public static final int GW_HWNDLAST
public static final int GW_HWNDNEXT
public static final int GW_HWNDPREV
public static final int GW_OWNER
public static final int GW_CHILD
public static final java.lang.String FUNCTION_GET_WINDOW_THREAD_PROCESS_ID
public static final FunctionName FUNCTION_SetDlgItemText
public static final FunctionName FUNCTION_GetDlgItemText
public static final int WS_OVERLAPPED
public static final int WS_POPUP
public static final int WS_CHILD
public static final int WS_MINIMIZE
public static final int WS_VISIBLE
public static final int WS_DISABLED
public static final int WS_CLIPSIBLINGS
public static final int WS_CLIPCHILDREN
public static final int WS_MAXIMIZE
public static final int WS_CAPTION
public static final int WS_BORDER
public static final int WS_DLGFRAME
public static final int WS_VSCROLL
public static final int WS_HSCROLL
public static final int WS_SYSMENU
public static final int WS_THICKFRAME
public static final int WS_GROUP
public static final int WS_TABSTOP
public static final int WS_MINIMIZEBOX
public static final int WS_MAXIMIZEBOX
public static final int WS_OVERLAPPEDWINDOW
public static final int WS_POPUPWINDOW
public static final int WS_CHILDWINDOW
public static final int WS_TILED
public static final int WS_ICONIC
public static final int WS_SIZEBOX
public static final int WS_TILEDWINDOW
public static final int WS_EX_DLGMODALFRAME
public static final int WS_EX_NOPARENTNOTIFY
public static final int WS_EX_TOPMOST
public static final int WS_EX_ACCEPTFILES
public static final int WS_EX_TRANSPARENT
public static final int WS_EX_MDICHILD
public static final int WS_EX_TOOLWINDOW
public static final int WS_EX_WINDOWEDGE
public static final int WS_EX_CLIENTEDGE
public static final int WS_EX_CONTEXTHELP
public static final int WS_EX_RIGHT
public static final int WS_EX_LEFT
public static final int WS_EX_RTLREADING
public static final int WS_EX_LTRREADING
public static final int WS_EX_LEFTSCROLLBAR
public static final int WS_EX_RIGHTSCROLLBAR
public static final int WS_EX_CONTROLPARENT
public static final int WS_EX_STATICEDGE
public static final int WS_EX_APPWINDOW
public static final int WS_EX_OVERLAPPEDWINDOW
public static final int WS_EX_PALETTEWINDOW
public static final int WS_EX_LAYERED
public static final int LWA_COLORKEY
public static final int LWA_ALPHA
public static final int SWP_NOSIZE
public static final int SWP_NOMOVE
public static final int SWP_NOZORDER
public static final int SWP_NOREDRAW
public static final int SWP_NOACTIVATE
public static final int SWP_FRAMECHANGED
public static final int SWP_SHOWWINDOW
public static final int SWP_HIDEWINDOW
public static final int SWP_NOCOPYBITS
public static final int SWP_NOOWNERZORDER
public static final int SWP_NOSENDCHANGING
public static final int SWP_DRAWFRAME
public static final int SWP_NOREPOSITION
public static final int SWP_DEFERERASE
public static final int SWP_ASYNCWINDOWPOS
public static final int HWND_TOP
public static final int HWND_BOTTOM
public static final int HWND_TOPMOST
public static final int HWND_NOTOPMOST
public static final int GWL_WNDPROC
public static final int GWL_HINSTANCE
public static final int GWL_HWNDPARENT
public static final int GWL_STYLE
public static final int GWL_EXSTYLE
public static final int GWL_USERDATA
public static final int GWL_ID
public static final int RDW_INVALIDATE
public static final int RDW_INTERNALPAINT
public static final int RDW_ERASE
public static final int RDW_VALIDATE
public static final int RDW_NOINTERNALPAINT
public static final int RDW_NOERASE
public static final int RDW_NOCHILDREN
public static final int RDW_ALLCHILDREN
public static final int RDW_UPDATENOW
public static final int RDW_ERASENOW
public static final int RDW_FRAME
public static final int RDW_NOFRAME
public static final int OPAQUE
public static final int TRANSPARENT
public Wnd()
public Wnd(long value)
value
- native window handle.public Wnd(java.awt.Component component)
component
- the component to get the handle from.WindowTools.getWindowHandle(Component)
public void eventLoop()
public static void eventLoop(long hwnd)
hwnd
- a window handle to run the event loop for.public static Wnd findWindow(java.lang.String className, java.lang.String windowName)
className
- windowName
- public static Wnd findWindowEx(Wnd parent, java.lang.String className, java.lang.String windowName)
parent
- handle of the parent window.className
- windowName
- public static Wnd findWindow(java.lang.String className)
className
- public static Wnd findWindowByName(java.lang.String windowName)
windowName
- public static Wnd getDesktopWindow()
public static Wnd createWindow(java.lang.String className, java.lang.String windowName, int windowStyle, long x, long y, long nWidth, long nHeight, Wnd hWndParent, Handle hMenu, Handle hInstance, Handle lpParam)
className
- a registered window class name.windowName
- the window name.windowStyle
- x
- the horizontal position of the window.y
- the vertical position of the window.nWidth
- the window width.nHeight
- the window height.hWndParent
- a handle to a parent or an owner window.hMenu
- a menu handle or a child identifier.hInstance
- a handle to an application instance.lpParam
- window-creation data.public static Wnd createWindow(int windowStyleEx, java.lang.String className, java.lang.String windowName, int windowStyle, long x, long y, long nWidth, long nHeight, Wnd hWndParent, Handle hMenu, Handle hInstance, Handle lpParam)
windowStyleEx
- extended window style.className
- a registered window class name.windowName
- the window name.windowStyle
- x
- the horizontal position of the window.y
- the vertical position of the window.nWidth
- the window width.nHeight
- the window height.hWndParent
- a handle to a parent or an owner window.hMenu
- a menu handle or a child identifier.hInstance
- a handle to an application instance.lpParam
- window-creation data.public static Wnd createWindow(java.lang.String className)
className
- a new window class name.public void update()
public void destroy()
public Size getSize()
public Size getClientSize()
public Rect getBounds()
public Rect getWindowRect()
public void centerInDesktop()
public Rect getClientRect()
public void setRegion(Region region, boolean redraw)
region
- a new region.redraw
- if true, the window will be redrawn.public Region getRegion()
public boolean setPosition(Wnd wndInsertAfter, long x, long y, long cx, long cy, long flags)
wndInsertAfter
- a window to precede the positioned window in the Z
order.x
- position of the left side of the window.y
- position of the top of the window.cx
- a new width of the window.cy
- a new height of the window.flags
- window sizing and positioning flags.public DC beginPaint(PaintStruct paintStruct)
paintStruct
- paint datapublic void endPaint(PaintStruct paintStruct)
paintStruct
- paint data.public boolean sendMessage(int msg, long wParam, long lParam)
msg
- a message to be sent.wParam
- WPARAMlParam
- LPARAMpublic long sendMessageEx(int msg, long wParam, long lParam)
msg
- a message to be sent.wParam
- WPARAMlParam
- LPARAMpublic boolean peekMessage(long msg, boolean remove)
public boolean peekMessage(Msg msg, long filterMin, long filterMax, boolean remove)
public boolean postMessage(int msg, long wParam, long lParam)
msg
- a message to be posted.wParam
- WPARAMlParam
- LPARAMpublic void show(Wnd.ShowWindowCommand command)
command
- Specifies how the window is to be shown.public void setWindowLong(int nIndex, long dwNewLong)
nIndex
- nIndex the zero-based offset to the value to be retrieved.dwNewLong
- specifies a new long value.public long setWindowLong(int nIndex, com.jniwrapper.Parameter newValue)
nIndex
- nIndex the zero-based offset to the value to be retrieved.newValue
- specifies a new value.public long getWindowLong(int nIndex)
nIndex
- a zero-based offset to the value to be retrieved.public void setLayeredWindowAttributes(ColorRef crKey, byte bAlpha, int dwFlags)
crKey
- a value that specifies the transparency color key to be used
when composing the layered window.bAlpha
- opacity of the layered window.dwFlags
- an action to take.public boolean getLayeredWindowAttributes(ColorRef crKey, com.jniwrapper.Int8 bAlpha, com.jniwrapper.UInt32 dwFlags)
crKey
- Receives the transparency color key to be used when composing the layered window.
All pixels painted by the window in this color will be transparent.
This can be null
if the argument is not needed.bAlpha
- Receives the Alpha value used to describe the opacity of the layered window.
When the variable referred to by pbAlpha is 0, the window is completely transparent.
When the variable referred to by pbAlpha is 255, the window is opaque.
This can be null
if the argument is not needed.dwFlags
- Receives a layering flag.
This can be null
if the argument is not needed.true
.
If the function fails, the return value is false
.public void redraw(Rect updateRect, Region updateRegion, int flags)
updateRect
- update rectangle handle.updateRegion
- update region handle.flags
- redraw flags.public void setParent(Wnd parent)
parent
- a new parent window.public Wnd getParent()
public Wnd getAncestor(Wnd.Ancestor ancestor)
ancestor
- the ancestor to be retrievedpublic void bringToTop()
public void setForeground()
public static long callWindowProc(Handle wndProc, Wnd wnd, com.jniwrapper.UInt msg, com.jniwrapper.Pointer.Void wParam, com.jniwrapper.Pointer.Void lParam)
wndProc
- a window procedure.wnd
- handle to window procedure to receive the message.msg
- messagewParam
- WPARAMlParam
- LPARAMpublic void moveWindow(int x, int y, int width, int height, boolean repaint)
x
- a new left side.y
- a new top side.width
- a new width.height
- a new height.repaint
- specifies whether the window is to be repainted.public void moveWindow(int x, int y, int width, int height)
x
- a new left side.y
- a new top side.width
- a new width.height
- a new height.public boolean getUpdateRect(Rect rect, boolean erase)
erase
- specifies whether the background in the update region is to
be erased.public boolean getUpdateRect(Rect rect)
public boolean flashWindow(FlashInfo flashInfo)
flashInfo
- a structure that configures the flashing.public java.lang.String getWindowClassName()
public Wnd getWindow(int uCmd)
uCmd
- type of the returned window, one of GW_ constants.public Point screenToClient(Point point)
point
- screen coordinates.public Point clientToScreen(Point point)
point
- contains the client coordinates to be converted.public static java.util.List getAllWindows()
public static java.util.List getChildWindows(Wnd parent)
parent
- a parent window whose child windows are to be enumerated .
If this parameter is NULL, this function is equivalent to getAllWindows()
public java.util.List getChildWindows()
public static java.util.List getThreadWindows(long threadID)
threadID
- specifies the thread whose windows are to be enumerated.public java.lang.String getWindowText()
public void setVisible(boolean visible)
visible
- if true
, shows this window; otherwise, hides this window.public boolean isVisible()
public void setWindowStyle(long flags)
flags
- public long getWindowStyle()
public void setWindowExStyle(long flags)
flags
- public long getWindowExStyle()
public boolean isTransparent()
public void setTransparent(boolean transparent)
sun.java2d.noddraw=true
JVM option is required for transparency feature.transparent
- specifies whether or not to make window transparentpublic void setTransparent(byte transparency)
transparency
- 0 makes the window completely opaque, 255 makes
it completely transparent.public byte getTransparency()
public void setTransparency(byte transparency)
sun.java2d.noddraw=true
JVM option is required for transparency feature.transparency
- 255 makes the window completely transparent, 0 makes
it completely opaque.public boolean isPalleteWindow()
public void setPalleteWindow(boolean palleteWindow)
palleteWindow
- public void setTopmost(boolean topmost)
topmost
- public void setRounded(boolean rounded, int ellipseWidth, int ellipseHeight)
rounded
- ellipseWidth
- ellipseHeight
- public void setRounded(boolean rounded)
rounded
- public void setWindowIcon(Icon icon, Icon.IconType iconType)
icon
- public void setCaptionVisible(boolean value)
value
- public boolean isCaptionVisible()
public void setBorderVisible(boolean value)
value
- public boolean isBorderVisible()
public Region setRegion(Region region)
region
- public void setContinuousRepainting(boolean value)
value
- if true, continuous window repainting; if false - default.public Wnd setFocus()
public static Wnd getFocus()
public int getThreadId()
public int getProcessId()
public void invalidateRect(Rect rect, boolean erase)
rect
- the client coordinates of the rectangle to be added to the update region. If it is null
, the entire client area is added to the update region.erase
- Specifies whether the background within the update region is to be erased when the update region is processedpublic void setHotKey(Wnd.HotKey hotKey)
hotKey
- specifies the hot key.java.lang.RuntimeException
- if the method is unsuccessful.public Wnd.HotKey getHotKey()
null
if hot key isn't set.null
if hot key isn't set.public boolean isWindow()
public static Wnd getForegroundWindow()
public static Wnd getWindowFromPoint(int x, int y)
x
- specifies the x-coordinate of the pointy
- specifies the y-coordinate of the pointpublic boolean isMaximized()
public boolean isMinimized()
public WindowPlacement getWindowPlacement()
public void setWindowPlacement(WindowPlacement placement)
placement
- new window placementpublic long sendMessage(int msg, com.jniwrapper.Parameter wParam, com.jniwrapper.Parameter lParam)
msg
- messagewParam
- WPARAMlParam
- LPARAMpublic boolean setDlgItemText(int idDlgItem, java.lang.String string)
idDlgItem
- Specifies the control with a title or text to be setstring
- String that contains the text to be copied to the controlpublic java.lang.String getDlgItemText(int idDlgItem)
idDlgItem
- Specifies the control with a title or text to be setpublic boolean enableWindow(boolean enable)
enable
- true - enables this window; false - otherwise