[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] how to detect if the cursor is on a bold text in an ActiveX

Hi!

Anyone knows how to detect if the cursor is on a bold text in an ActiveX
"DHTMLEdit.DHTMLEdit".
 This program should return me the status of the current text  when I click
on the button "State".  But that does not go.

Any ideas ?
Thanks.

/**Programme**/
import org.eclipse.swt.SWT;

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.OleControlSite;

import org.eclipse.swt.ole.win32.OleFrame;

import org.eclipse.swt.ole.win32.Variant;

import org.eclipse.swt.widgets.Button;

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Event;

import org.eclipse.swt.widgets.Listener;

import org.eclipse.swt.widgets.Shell;

public class TestOleHtmlInBold {

    protected static Shell shell;

    protected static Composite composite;

    protected static OleAutomation automationHtml;

    protected static OleControlSite controlSiteHtml;

    protected static OleFrame oleFrameHtml;

    protected final static int DECMD_BOLD = 5000;

    protected final static int OLECMDEXECOPT_DODEFAULT = 0;

    protected final static int DECMDF_ENABLED = 3;

    protected final static int DECMD_LATCHED = 7;

    protected final static int DECMDF_DISABLED = 1;

    protected final static int DECMDF_NOTSUPPORTED = 0;

    protected final static int DECMDF_NINCHED = 11;

    public static void createComposite(Composite parent){

        oleFrameHtml = new OleFrame(parent, SWT.NONE);

        controlSiteHtml = new OleControlSite(oleFrameHtml, SWT.NONE,
"DHTMLEdit.DHTMLEdit");

        controlSiteHtml.doVerb(OLE.OLEIVERB_SHOW);

        OleAutomation automation = new OleAutomation(controlSiteHtml);

        automationHtml = new OleAutomation(controlSiteHtml);

    }

    public static void main (String [] args) {

        Display display = new Display ();

        shell = new Shell (display);

        FillLayout fillLayout = new FillLayout ();

        fillLayout.type = SWT.VERTICAL;

        shell.setLayout (fillLayout);

        createComposite(shell);

        Button button = new Button (shell, SWT.PUSH);

        button.setText ("Bold");

        button.addListener (SWT.Selection, new Listener () {

            public void handleEvent (Event event) {

                int[] rgids = automationHtml.getIDsOfNames(new String[]
{"ExecCommand"});

                Variant[] rgvars = new Variant[2];

                rgvars[0] = new Variant(DECMD_BOLD);

                rgvars[1] = new Variant(OLECMDEXECOPT_DODEFAULT);

                automationHtml.invoke(rgids[0], rgvars);

        }});

        Button button2 = new Button (shell, SWT.PUSH);

        button2.setText ("State");

        button2.addListener (SWT.Selection, new Listener () {

    public void handleEvent (Event event) {

        int result = controlSiteHtml.queryStatus(DECMD_BOLD);

        switch (result){

            case DECMD_LATCHED : System.out.println("bold is enabled");

            break;

            case DECMDF_NINCHED:System.out.println("bold is NOT enabled");;

            break;

        default: System.out.println("bold is NOT enabled");

            break;

    }

    }});

    shell.pack ();

    shell.open ();

    while (!shell.isDisposed ()) {

            if (!display.readAndDispatch ())

        display.sleep ();

    }

    display.dispose ();

    }

}