Table of Contents

Class JCWindowsManager

Namespace
MASES.JCOBridge.C2JBridge
Assembly
C2JBridge.dll

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

bool

Default

The default implementation of JCWindowsManager

public static JCWindowsManager Default { get; }

Property Value

JCWindowsManager

HasRemoteMeasureOverride

public bool HasRemoteMeasureOverride { get; }

Property Value

bool

HwndParent

The HandleRef received from WPF/WinForms graphic system

public HandleRef HwndParent { get; }

Property Value

HandleRef

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

bool

JCGraphicContainer

public IJCGraphicContainer JCGraphicContainer { get; }

Property Value

IJCGraphicContainer

RemoteWindow

The IntPtr pointer to Java AWT/Swing window

public IntPtr RemoteWindow { get; }

Property Value

IntPtr

Methods

DestroyWindow(HandleRef)

Invoked during destroy of WPF/WinForms container associated to Java AWT/Swing graphic object

public virtual void DestroyWindow(HandleRef hwndParent)

Parameters

hwndParent HandleRef

The HandleRef received from WPF/WinForms graphic system

Remarks

GetAncestor(IntPtr, uint)

public static extern IntPtr GetAncestor(IntPtr hwnd, uint gaFlags)

Parameters

hwnd IntPtr

A handle to the window whose ancestor is to be retrieved. If this parameter is the desktop window, the function returns Zero.

gaFlags uint

The 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 IntPtr

A 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)

public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)

Parameters

hWnd IntPtr

A handle to the window and, indirectly, the class to which the window belongs.

nIndex int

The 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 IntPtr

A handle to the window.

x int

The position of the left side of the window, in client coordinates.

y int

The position of the top of the window, in client coordinates.

width int

The width of the window, in pixels.

height int

The 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 IJCGraphicContainer

The IJCGraphicContainer managing the graphic container

hwndParent HandleRef

The 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 double

A value greater than or equal to 0 that specifies the Width.

height double

A 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 bool

true 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 double

The x-coordinate location of the left side of the rectangle.

y double

The y-coordinate location of the top side of the rectangle.

width double

A non-negative value that represents the Width of the rectangle.

height double

A non-negative value that represents the Height of the rectangle.

Remarks

SetParent(IntPtr, IntPtr)

public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent)

Parameters

hWndChild IntPtr

A handle to the child window.

hWndNewParent IntPtr

A 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)

public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong)

Parameters

hWnd IntPtr

A handle to the window and, indirectly, the class to which the window belongs.

nIndex int

The 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 IntPtr

The 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 IntPtr

A handle to the window.

hWndInsertAfter IntPtr

A handle to the window to precede the positioned window in the Z order.

X int

The new position of the left side of the window, in client coordinates.

Y int

The new position of the top of the window, in client coordinates.

cx int

The new width of the window, in pixels.

cy int

The new height of the window, in pixels.

uFlags JCWindowsManager.SetWindowPosFlags

The 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 IntPtr

A handle to the window.

nCmdShow int

Controls how the window is to be shown. See JCWindowsManager.ShowWindowCommand

Returns

bool

If the window was previously visible, the return value is true. If the window was previously hidden, the return value is false.