Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with OLE control
Problem with OLE control [message #373045] Fri, 29 August 2003 11:08 Go to next message
Eclipse UserFriend
Originally posted by: xiecai.yahoo.com

I am newbie with SWT, after reading some article in eclipse.org, I try to
write something to call IE browser using OLE, I got problem: the IE window
doesn't work well. I post my code below, please help me check out the
error point.

thanks!

////////////////////////////////

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.ole.win32.*;
import org.eclipse.swt.internal.ole.win32.*;

public class BrowserTest {
static OleControlSite controlSite;
static OleAutomation webBrowser;
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
Button btn = new Button(shell, SWT.PUSH);
btn.setText("Open IE browser...");
btn.pack();
btn.setLocation(10,10);
btn.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
Shell browser = new Shell(shell, SWT.NONE);
//browser.open();
try{

OleFrame frame = new OleFrame(browser, SWT.NONE);
controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
controlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);
}catch(SWTError se){
System.out.println("Unable to open activeX control");
return;
}
browser.open();

webBrowser = new OleAutomation(controlSite);
int[] ids = webBrowser.getIDsOfNames(new String[]{"Navigate", "URL"});
Variant[] rgvarg = new Variant[] {new
Variant("http://www.google.com")};
int[] rgdispidNamedArgs = new int[]{ids[1]};
webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs);

}
});

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
webBrowser.dispose();
display.dispose();

}
}
Re: Problem with OLE control [message #373047 is a reply to message #373045] Fri, 29 August 2003 12:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: asra.choukri.hyperoffice.fr

Hi Aquarius!

It is only enough to put a FillLayout at your browser .

.......
Shell browser = new Shell(shell, SWT.NONE);

browser.setLayout(new FillLayout());

......

Asra.

"Aquarius" <xiecai@yahoo.com> a
Re: Problem with OLE control [message #373050 is a reply to message #373047] Fri, 29 August 2003 14:02 Go to previous message
Eclipse UserFriend
Originally posted by: xiecai.yahoo.com

Hi asra,

It works,it works.

Thanks



asra wrote:

> Hi Aquarius!

> It is only enough to put a FillLayout at your browser .

> .......
> Shell browser = new Shell(shell, SWT.NONE);

> browser.setLayout(new FillLayout());

> ......

> Asra.

> "Aquarius" <xiecai@yahoo.com> a écrit dans le message de news:
> binq8g$u4m$1@eclipse.org...
> >
> > I am newbie with SWT, after reading some article in eclipse.org, I try to
> > write something to call IE browser using OLE, I got problem: the IE window
> > doesn't work well. I post my code below, please help me check out the
> > error point.
> >
> > thanks!
> >
> > ////////////////////////////////
> >
> > import org.eclipse.swt.*;
> > import org.eclipse.swt.widgets.*;
> > import org.eclipse.swt.events.*;
> > import org.eclipse.swt.ole.win32.*;
> > import org.eclipse.swt.internal.ole.win32.*;
> >
> > public class BrowserTest {
> > static OleControlSite controlSite;
> > static OleAutomation webBrowser;
> > public static void main(String[] args) {
> > Display display = new Display();
> > final Shell shell = new Shell(display);
> > Button btn = new Button(shell, SWT.PUSH);
> > btn.setText("Open IE browser...");
> > btn.pack();
> > btn.setLocation(10,10);
> > btn.addSelectionListener(new SelectionAdapter(){
> > public void widgetSelected(SelectionEvent e){
> > Shell browser = new Shell(shell, SWT.NONE);
> > //browser.open();
> > try{
> >
> > OleFrame frame = new OleFrame(browser, SWT.NONE);
> > controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
> > controlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);
> > }catch(SWTError se){
> > System.out.println("Unable to open activeX control");
> > return;
> > }
> > browser.open();
> >
> > webBrowser = new OleAutomation(controlSite);
> > int[] ids = webBrowser.getIDsOfNames(new String[]{"Navigate", "URL"});
> > Variant[] rgvarg = new Variant[] {new
> > Variant("http://www.google.com")};
> > int[] rgdispidNamedArgs = new int[]{ids[1]};
> > webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs);
> >
> > }
> > });
> >
> > shell.open();
> > while (!shell.isDisposed()) {
> > if (!display.readAndDispatch())
> > display.sleep();
> > }
> > webBrowser.dispose();
> > display.dispose();
> >
> > }
> > }
> >
> >
Previous Topic:Table with no selection?
Next Topic:How to attach a pop-up menu to an event and wait for it?
Goto Forum:
  


Current Time: Fri Nov 07 11:26:18 EST 2025

Powered by FUDForum. Page generated in 0.04259 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top