Hi Jan,

Thank you for your help, getting the window handle will help me solve my 
problem. I was able to get the window handle using Java rather than Basic:

        XSystemDependentWindowPeer peer = (XSystemDependentWindowPeer) 
UnoRuntime.queryInterface(
                XSystemDependentWindowPeer.class, myFrame.getContainerWindow());
        
        Object handle = peer.getWindowHandle(new byte[4], 
SystemDependent.SYSTEM_WIN32));

Thank you also to the rest of you who answered for your suggestions. 

George

-----Original Message-----
From: Jan Füssel [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 31, 2008 11:57 AM
To: dev@api.openoffice.org
Subject: Re: [api-dev] Using an Xframe as a parent for a Java dialog

Hi,

i've currently a solution to open a modless java-dialog, which need SWT and 
only works on a windows machine.

To get Windows Handle I used the following Basic-Code:

Dim oWindow : oWindow = ThisComponent.CurrentController.Frame.ContainerWindow
Dim HWND : HWND = oWindow.getWindowHandle(Array(),
com.sun.star.lang.SystemDependent.SYSTEM_WIN32)

With that handle I call java Java-Method which start an SWT-Dialog:

private void createDialog(int handle) {
        final MyDialog myDialog = MyDialog.create(handle, componentContext);
        myDialog.show();
}

Here a little piece of the MyDialog Class:

public class MyDialog {

    private final Shell myShell;

    private MyDialog(Shell shell) {
        myShell = shell;
        myShell.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent e) {
                myShell.setVisible(true);
            }
        });
    }

    public static MyDialog create(int handle, XComponentContext
componentContext) {
        final int style = SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE;
        final Display display = new Display();
        final Shell shell;
        if (handle > 0) {
            final Shell parent = Shell.win32_new(display, handle);
            shell = new Shell(parent, style);
        } else {
            shell = new Shell(style);
        }
        return new MyDialog(shell);
    }

    public void show() {
        createMyShell();
        myShell.open();
        final Composite parent = myShell.getParent();
        final Display display;
        if (parent != null) {
            display = parent.getDisplay();
        } else {
            display = Display.getDefault();
        }
        while (!myShell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }
}

I hope this little pieces of code could show you a way to resolve your problem.

Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to