ActiveX / OLE in SWT: Scrollbalken verschwinden nach einem Resize

JDad

Mitglied
Hallo!

Ich habe folgendes Problem: In meiner SWT-Applikation habe ich MS-Word eingebettet. Alles funktioniert prima bis auf die Scrollbalken. Diese verschwinden nach einem Resize des Fensters.

Zum Erstellen der Scrollbalken habe ich eine Methode geschrieben (siehe Code).

Hat einer eine Idee?

Java:
import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class WordOLE
{
    OleClientSite clientSite;
    
    public static void main(String[] args)
    {
        new WordOLE();
    }
    
    public WordOLE()
    {
        final Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        
        try
        {
            File file = new File("C:\\test.rtf");
            OleFrame frame = new OleFrame(shell, SWT.NONE);
            clientSite = new OleClientSite(frame, SWT.NONE, "Word.Document");
            clientSite.doVerb(OLE.OLEIVERB_SHOW);//.OLEIVERB_INPLACEACTIVATE);
            
        }
        catch (SWTError e)
        {
            System.out.println("Unable to open activeX control");
            return;
        }
        shell.open();

        final OleAutomation msWord = new OleAutomation(clientSite);

        setScrollBarsVisible(true);
        
        while (!shell.isDisposed())
        {
            if (!display.readAndDispatch())
                display.sleep();
        }
        msWord.dispose();
        display.dispose();
    }
    
    private void setScrollBarsVisible(boolean pVisible)
    {
        OleAutomation dispInterface = new OleAutomation(clientSite);
        // Get Application
        int[] appId = dispInterface.getIDsOfNames(new String[] { "Application" }); //$NON-NLS-1$
        if (appId != null)
        {
            Variant pVarResult = dispInterface.getProperty(appId[0]);
            if (pVarResult != null)
            {
                OleAutomation application = pVarResult.getAutomation();
                int[] dispid = application.getIDsOfNames(new String[] { "DisplayScrollBars" }); //$NON-NLS-1$
                if (dispid != null)
                {
                    Variant rgvarg = new Variant(true);
                    application.setProperty(dispid[0], rgvarg);
                }
                application.dispose();
            }
        }
        dispInterface.dispose();
    }
}
 
Zurück