[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] HELP: Get back OleEvent (KEYPress, KEYUp) in OLEFrame

Hi,

I try to get back the events of a OLEFrame. With the following code, I get
back no event. I don't  know if my values are incorrect or the other thing.

Any one can help me?
Thanks very much.


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

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

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

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

/**

* @author asra

*/

public class OleHtml implements OleListener {


protected static Shell shell;

protected OleAutomation automationHtml;

protected OleControlSite controlSiteHtml;

protected OleFrame oleFrameHtml;

protected int DISPID_KEYUP = -604;

protected int DISPID_KEYPRESS = -603;


public OleHtml()

{

    createControl(shell, SWT.NONE);

}


public void createControl(Composite parent, int style)

{

    oleFrameHtml = new OleFrame(parent, style);

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

    controlSiteHtml.setSize(-1, 200);

    controlSiteHtml.doVerb(OLE.OLEIVERB_SHOW);

    automationHtml = new OleAutomation(controlSiteHtml);


    controlSiteHtml.addEventListener(DISPID_KEYUP, new OleListener() {

        public void handleEvent(OleEvent event) {

            System.out.println("Key UP");

        }

    });


    controlSiteHtml.addEventListener(DISPID_KEYPRESS, new OleListener() {

        public void handleEvent(OleEvent event) {

            System.out.println("Key Press");

        }

    });


}


public static void main (String [] args) {

    Display display = new Display ();

    shell = new Shell (display);

    shell.setLayout(new FillLayout());


    OleHtml oleHtml = new OleHtml();


    shell.pack ();

    shell.open ();

    while (!shell.isDisposed ()) {

    if (!display.readAndDispatch ()) display.sleep ();

       }

    display.dispose ();

}


public void handleEvent(OleEvent event) {

    System.out.println("Here handleEvent ...............................");

}


}