Class JCWindowsManager
Class to manage windows initialization and positioning, it is the input of Initialize(JCWindowsManager)
public class JCWindowsManager
- Inheritance
-
JCWindowsManager
- Inherited Members
- Extension Methods
Remarks
To be used only on Windows OSes
Properties
CanManageWndProc
true if Java AWT/Swing window can manages message pump
public bool CanManageWndProc { get; }
Property Value
Default
The default implementation of JCWindowsManager
public static JCWindowsManager Default { get; }
Property Value
HasRemoteMeasureOverride
true if Java AWT/Swing window can manage https://learn.microsoft.com/en-us/dotnet/api/system.windows.interop.hwndhost.measureoverride
public bool HasRemoteMeasureOverride { get; }
Property Value
HwndParent
The HandleRef received from WPF/WinForms graphic system
public HandleRef HwndParent { get; }
Property Value
IsRemoteManaged
true if Java AWT/Swing window manages itself positioning and it is detached from WPF/WinForms graphic system
public bool IsRemoteManaged { get; }
Property Value
JCGraphicContainer
The IJCGraphicContainer created by GetJCGraphicContainer(IJavaObject, bool) or GetJCGraphicContainer(string, bool)
public IJCGraphicContainer JCGraphicContainer { get; }
Property Value
RemoteWindow
The IntPtr pointer to Java AWT/Swing window
public IntPtr RemoteWindow { get; }
Property Value
Methods
DestroyWindow(HandleRef)
Invoked during destroy of WPF/WinForms container associated to Java AWT/Swing graphic object
public virtual void DestroyWindow(HandleRef hwndParent)
Parameters
Remarks
GetAncestor(IntPtr, uint)
public static extern IntPtr GetAncestor(IntPtr hwnd, uint gaFlags)
Parameters
hwnd
IntPtrA handle to the window whose ancestor is to be retrieved. If this parameter is the desktop window, the function returns Zero.
gaFlags
uintThe ancestor to be retrieved.
Returns
- IntPtr
The return value is the handle to the ancestor window.
GetLastError()
public static extern uint GetLastError()
Returns
- uint
The return value is the calling thread's last-error code.
GetParent(IntPtr)
public static extern IntPtr GetParent(IntPtr hWnd)
Parameters
hWnd
IntPtrA handle to the window whose parent window handle is to be retrieved.
Returns
- IntPtr
If the window is a child window, the return value is a handle to the parent window. If the function fails, the return value is Zero. To get extended error information, call GetLastError().
GetWindowLongPtr(IntPtr, int)
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptra, https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)
Parameters
hWnd
IntPtrA handle to the window and, indirectly, the class to which the window belongs.
nIndex
intThe zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. To retrieve any other value, specify one of the JCWindowsManager.GWL values.
Returns
- IntPtr
If the function succeeds, the return value is the requested value. If the function fails, the return value is Zero. To get extended error information, call GetLastError().
Remarks
This static method is required because legacy OSes do not support GetWindowLongPtr
GetWindowRect(IntPtr, out int, out int, out int, out int)
public static bool GetWindowRect(IntPtr hwnd, out int x, out int y, out int width, out int height)
Parameters
hwnd
IntPtrA handle to the window.
x
intThe position of the left side of the window, in client coordinates.
y
intThe position of the top of the window, in client coordinates.
width
intThe width of the window, in pixels.
height
intThe height of the window, in pixels.
Returns
- bool
If the function succeeds, the return value is true. If the function fails, the return value is false. To get extended error information, call GetLastError().
Initialize(IJCGraphicContainer, HandleRef)
Invoked during initialization of WPF/WinForms container associated to Java AWT/Swing graphic object
public void Initialize(IJCGraphicContainer container, HandleRef hwndParent)
Parameters
container
IJCGraphicContainerThe IJCGraphicContainer managing the graphic container
hwndParent
HandleRefThe HandleRef received from WPF/WinForms graphic system
Remarks
MeasureOverride(ref double, ref double)
Returns the size of the window represented by the WPF/WinForms container associated to Java AWT/Swing graphic object, as requested by layout engine operations.
public virtual void MeasureOverride(ref double width, ref double height)
Parameters
width
doubleA value greater than or equal to 0 that specifies the Width.
height
doubleA value greater than or equal to 0 that specifies the Height
Remarks
OnBuildWindow()
Invoked during initialization of WPF/WinForms container associated to Java AWT/Swing graphic object if IsRemoteManaged is false.
The standard operation done are:
- removes the styles WS_CAPTION, WS_THICKFRAME, WS_MINIMIZEBOX, WS_MAXIMIZEBOX and WS_SYSMENU
- set Java AWT/Swing window to be WS_CHILDWINDOW
- connects WPF/WinForms window and Java AWT/Swing window
public virtual HandleRef OnBuildWindow()
Returns
- HandleRef
The HandleRef expected from https://learn.microsoft.com/en-us/dotnet/api/system.windows.interop.hwndhost.buildwindowcore
OnWindowPositionChanged(bool, double, double, double, double)
Invoked when a repaint of WPF/WinForms container associated to Java AWT/Swing graphic object occurs and Java AWT/Swing graphic object needs a resize
public virtual void OnWindowPositionChanged(bool isVisible, double x, double y, double width, double height)
Parameters
isVisible
booltrue if WPF/WinForm container associated to Java AWT/Swing graphic object is visible and Java AWT/Swing graphic object shall be visible, otherwise false
x
doubleThe x-coordinate location of the left side of the rectangle.
y
doubleThe y-coordinate location of the top side of the rectangle.
width
doubleA non-negative value that represents the Width of the rectangle.
height
doubleA non-negative value that represents the Height of the rectangle.
Remarks
https://learn.microsoft.com/en-us/dotnet/api/system.windows.interop.hwndhost.onwindowpositionchanged
SetParent(IntPtr, IntPtr)
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent)
Parameters
hWndChild
IntPtrA handle to the child window.
hWndNewParent
IntPtrA handle to the new parent window. If this parameter is Zero, the desktop window becomes the new parent window.
Returns
- IntPtr
If the function succeeds, the return value is a handle to the previous parent window. If the function fails, the return value is Zero. To get extended error information, call GetLastError().
SetWindowLongPtr(IntPtr, int, IntPtr)
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptra, https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw
public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
Parameters
hWnd
IntPtrA handle to the window and, indirectly, the class to which the window belongs.
nIndex
intThe zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. To retrieve any other value, specify one of the JCWindowsManager.GWL values.
dwNewLong
IntPtrThe replacement value.
Returns
- IntPtr
If the function succeeds, the return value is the previous value of the specified offset. If the function fails, the return value is Zero. To get extended error information, call GetLastError().
Remarks
This static method is required because legacy OSes do not support SetWindowLongPtr
SetWindowPos(IntPtr, IntPtr, int, int, int, int, SetWindowPosFlags)
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, JCWindowsManager.SetWindowPosFlags uFlags)
Parameters
hWnd
IntPtrA handle to the window.
hWndInsertAfter
IntPtrA handle to the window to precede the positioned window in the Z order.
X
intThe new position of the left side of the window, in client coordinates.
Y
intThe new position of the top of the window, in client coordinates.
cx
intThe new width of the window, in pixels.
cy
intThe new height of the window, in pixels.
uFlags
JCWindowsManager.SetWindowPosFlagsThe window sizing and positioning flags. This parameter can be a combination of JCWindowsManager.SetWindowPosFlags values.
Returns
- bool
If the function succeeds, the return value is true. If the function fails, the return value is false. To get extended error information, call GetLastError().
ShowWindow(IntPtr, int)
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow)
Parameters
hWnd
IntPtrA handle to the window.
nCmdShow
intControls how the window is to be shown. See JCWindowsManager.ShowWindowCommand