Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to extract vt_bstr send byRef from Variant
how to extract vt_bstr send byRef from Variant [message #449281] Thu, 20 January 2005 13:11 Go to next message
Pratik is currently offline PratikFriend
Messages: 9
Registered: July 2009
Junior Member

I have an embedded a "shell.explorer" in java (eclipse/SWT), which seems to
work fine. now trying to handle the event BeforeNavigate2 for that component
from java. but im not able to get/decode the value of one of the parameter
which is send by reference.

any help in this regard would be appreciated.

here are the details:

event i wish to handle:
Private Sub object_BeforeNavigate2( _
ByVal pDisp As Object, _
ByRef url As Variant, _
ByRef Flags As Variant, _
ByRef TargetFrameName As Variant, _
ByRef PostData As Variant, _
ByRef Headers As Variant, _
ByRef Cancel As Boolean)

in java i get this object on event "org.eclipse.swt.ole.win32.OleEvent"
where the parameters are send as an array of Variant
(org.eclipse.swt.ole.win32.Variant) arguments. im interested in the argument
"url" so that i can selectively block navigation.

the code im trying is:

* @param variant
* @return
private String getBSTR(Variant variant) {
// pratik: Auto-generated method stub
String str = null;
int byRef = variant.getByRef();
short type = variant.getType();
if(type == (OLE.VT_BYREF | OLE.VT_VARIANT)){

System.out.println("DEBUG:-:-IEViewPage::getBSTR() - (OLE.VT_BYREF |
short type2 = getType2(variant);
if(type2 == OLE.VT_BSTR){
System.out. println("DEBUG:-IEViewPage::getBSTR() - is a
//FIXME-PRATIK: now what ?
// im stuck here im not sure what do do this point onwards.

System.out.println("DEBUG:-AdvanceManagementDetailsPage::getBSTR() - "+str);
return str;

* @param variant
* @return
private short getType2(Variant variant) {
int pPostData = variant.getByRef();
short[] vt_type = new short[1];
OS.MoveMemory(vt_type, pPostData, 2);
return vt_type[0];
} nce/events/beforenavigate2.asp


Re: how to extract vt_bstr send byRef from Variant [message #449289 is a reply to message #449281] Thu, 20 January 2005 15:37 Go to previous message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
See how the org.eclipse.swt.browser.Browser class on Windows does the same
thing: ipse%20SWT%20Browser/win32/org/eclipse/swt/browser/Browser.j ava?rev=HEAD&content-type=text/vnd.viewcvs-markup

OleListener listener = new OleListener() {
public void handleEvent(OleEvent event) {
switch (event.type) {
case BeforeNavigate2: {
Variant varResult = event.arguments[1];
String url = varResult.getString();

site.addEventListener(BeforeNavigate2, listener);

where site is an instance of a class that extends OleControlSite.

Previous Topic:Problem with table.getSelection() !?!?
Next Topic:OpenGL Linux: no depth testing
Goto Forum:

Current Time: Thu Oct 29 05:41:58 GMT 2020

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

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

Back to the top