Page 1 of 1

Undock / dock a pane from code (+ change size)

Posted: Tue Dec 24, 2024 12:41 pm
by zarkogajic
Hi Support,

How could I do the following from code:

1. Check if a pane is docked. (note: interested only in history, recover and alike - so not specific document related panes).

2. Undock it and resize and position in screen center.

3. Dock it back to where it was (if it was docked) before [2].

-žarko

Re: Undock / dock a pane from code (+ change size)

Posted: Thu Jan 23, 2025 11:12 pm
by Vasyl - PDF-XChange
1. Check if a pane is docked. (note: interested only in history, recover and alike - so not specific document related panes).

Code: Select all

IUXC_LayoutItem getObjLI(IUXC_Obj o)
{
	IUXC_LayoutItem LI;
	do
	{
		if (o == null)
			break;
		LI = o.LI;
		if (LI != null)
			break;
		o = o.Parent;
	} while (true);
	return LI;
}

IUXC_LayoutItem LI = getObjLI(pane.Obj);

bool bDocked = (LI != null) && !LI.IsFloating;
2. Undock it and resize and position in screen center.

Code: Select all

IUXC_LayoutItem LI = getObjLI(pane.Obj);
if (LI != null)
	LI.MakeFloating2(centerRect);
3. Dock it back to where it was(if it was docked) before[2].

Code: Select all

// before make pane floated - keep the dock-parent and dock-index of the pane's layout-item inside that parent
IUXC_LayoutItem LI_DkParent = LI.Parent;
LI_IndexInDkParent = LI_DkParent.GetItemIndex(LI);

// dock back
LI_DkParent.Layout.MoveItem(LI, LI_DkParent, LI_IndexInDkParent);

// NOTE: IUXC_LayoutItem.Layout property will be added in the upcoming build to simplify getting the layout object.
// However, currently, you may use a more complicated way to get the layout object:

IUXC_Layout getLayoutFromObj(IUXC_Obj o)
{
	do
	{
		if (o == null)
			break;
		IntPtr impl = IntPtr.Zero;
		o.QueryImpl(typeof(IUXC_Layout).GUID, null, out impl);
		IUXC_Layout L = (IUXC_Layout)Marshal.GetObjectForIUnknown(impl);
		if (L != null)
			return L;
		o = o.Parent;
	} while (true);
	return null;
}

Re: Undock / dock a pane from code (+ change size)  SOLVED

Posted: Fri Jan 24, 2025 7:12 am
by zarkogajic
Hi Vasyl,

Fantastic, thanks!


Undock / dock a pane from code (+ change size)

Posted: Fri Jan 24, 2025 10:08 am
by Stefan - PDF-XChange
:)