I wonder how an Eclipse RCP application can be embedded into a .NET window. Someone from the RCP newsgroup gave me the advice to try out windows FindWindow and SetParent functions – wich leads me to this C# example.

Here is the conclusion:

In the C# application one can acquire the handle of the RCP application and set the windows parent to some control handle from the C# application.


...
wHandle = FindWindow (null, "RCP Product");
groupBoxHandle = this.groupBox1.Handle;
setParent (wHandle, groupBoxHandle);
int style = GetWindowLong(wHandle, GWL_STYLE);
SetWindowPos(wHandle, groupBoxHandle, 0, 0,
    this.groupBox1.Bounds.Width-20,
    this.groupBox1.Bounds.Height-20,
    SWP_NOZORDER | SWP_NOMOVE | SWP_DRAWFRAME );
MoveWindow(wHandle,5,20,
    this.groupBox1.Bounds.Width-8,
    this.groupBox1.Bounds.Height-25,
    true);
...

It’ll be nice too, to delegate resize events to the RCP’s window.


void resized(object sender, System.EventArgs e) {
    MoveWindow(wHandle,5,20,
        this.groupBox1.Bounds.Width-8,
        this.groupBox1.Bounds.Height-25,
        true);
}

The RCP application can be started as stripped window without title bar etc. Just set a new shell style at the WorkbenchWindowAdvisor’s method preWindowOpen:


configurer.setShellStyle(SWT.APPLICATION_MODAL);

The following screenshot shows the RCP mail sample application within a .NET window.

net-rcp.jpg

Of course this will not solve any interoperability issues but will offer an interesting option for RCP integration.