[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] how to extract vt_bstr send byRef from Variant

Hi,

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 |
OLE.VT_VARIANT)");
            short type2 = getType2(variant);
            if(type2 == OLE.VT_BSTR){
                System.out. println("DEBUG:-IEViewPage::getBSTR() - is a
OLE.VT_BSTR");
                //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];
    }

http://msdn.microsoft.com/workshop/browser/webbrowser/reference/events/beforenavigate2.asp
https://bugs.eclipse.org/bugs/show_bug.cgi?id=8727#c2


Thanks.

-Pratik