|
Hi!
I used the Navigate method to regulate the
exception Thanks.
But now, the problem is that I can't
still write anythinks in my page HTML.
I don't know
where goes wrong!
thank for your
help.
Asra.
/********************************/
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
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.Display;
import org.eclipse.swt.widgets.Shell;
public class ShellExplorer {
protected static Display display;
protected static Shell shell;
protected OleAutomation automationHtml;
protected OleControlSite controlSiteHtml;
protected OleFrame oleFrameHtml;
public
ShellExplorer(){
oleFrameHtml = new OleFrame(shell, SWT.NONE);
controlSiteHtml = new OleControlSite(oleFrameHtml, SWT.NONE, "Shell.Explorer");
//webbrowser
controlSiteHtml.setSize(100, 100);
controlSiteHtml.doVerb(OLE.OLEIVERB_SHOW);
controlSiteHtml.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
automationHtml = new OleAutomation(controlSiteHtml);
int[] ids = automationHtml.getIDsOfNames(new String[]{"Navigate", "URL"});
Variant[] rgvarg
= new Variant[] {new
Variant("C:\\toto.html")};
int[] rgdispidNamedArgs = new int[]{ids[1]};
automationHtml.invoke(ids[0], rgvarg, rgdispidNamedArgs);
int[] rgdispid = automationHtml.getIDsOfNames(new String[]{"Document"}); //get a document
int dispIdMember
= rgdispid[0];
Variant varDocument
= automationHtml.getProperty(dispIdMember);
OleAutomation doc = varDocument.getAutomation();
int[] rgdispid2 = doc.getIDsOfNames(new String[]{"write"}); //write in a document
Variant[] rgvarg2
= new Variant[1];
rgvarg2[0] = new Variant("I'm here");
automationHtml.invoke(rgdispid2[0], rgvarg2);
}
public
static
void main (String [] args) {
display = new Display ();
shell = new Shell (display);
RowLayout fl = new RowLayout();
shell.setLayout(fl);
ShellExplorer se = new
ShellExplorer();
shell.pack ();
shell.open ();
while (!shell.isDisposed
()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
/********************************/
Your varDocument does not contain a VT_DISPATCH
object. It probably contains nothing (VT_EMPTY).
Shell.Explorer will not return a valid document
until you have opened a valid URL or loaded a valid file.
Try calling the GoHome method or the Navigate
method first.
See org.eclipse.swt.win32.ole for an
example.
Hi !!
I try to run this program which must write in a brower a text
HTML.
When I run it, I get an exception when i
try to execute this command:
"OleAutomation doc = varDocument.getAutomation();"
Any ideas ? Thanks.
/*****Exception********/
org.eclipse.swt.SWTException: Failed to change Variant type result =
-1
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:332)
at org.eclipse.swt.ole.win32.Variant.getAutomation(Variant.java:200)
at Main.ShellExplorer.<init>(ShellExplorer.java:38)
at Main.ShellExplorer.main(ShellExplorer.java:52)
Exception in thread "main"
/*****Program********/
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
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.Display;
import org.eclipse.swt.widgets.Shell;
public class ShellExplorer {
protected static Display display;
protected static Shell shell;
protected OleAutomation automationHtml;
protected OleControlSite controlSiteHtml;
protected OleFrame oleFrameHtml;
public
ShellExplorer(){
oleFrameHtml = new OleFrame(shell, SWT.NONE);
controlSiteHtml = new OleControlSite(oleFrameHtml, SWT.NONE, "Shell.Explorer"); //webbrowser
controlSiteHtml.setSize(100, 100);
controlSiteHtml.doVerb(OLE.OLEIVERB_SHOW);
controlSiteHtml.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
automationHtml = new OleAutomation(controlSiteHtml);
int[] rgdispid = automationHtml.getIDsOfNames(new String[]{"Document"}); //get a document
int dispIdMember = rgdispid[0];
Variant varDocument
= automationHtml.getProperty(dispIdMember);
OleAutomation doc = varDocument.getAutomation();
int[] rgdispid2 = doc.getIDsOfNames(new String[]{"write"}); //write in a document
Variant[] rgvarg = new Variant[1];
rgvarg[0] = new Variant("<body>browser</body>");
automationHtml.invoke(rgdispid2[0], rgvarg);
}
public
static
void
main (String [] args) {
display =
new
Display ();
shell =
new
Shell (display);
RowLayout fl = new RowLayout();
shell.setLayout(fl);
ShellExplorer se = new ShellExplorer();
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
|