Bug 10977 - Safearray support for ActiveX-Integration
Summary: Safearray support for ActiveX-Integration
Status: RESOLVED DUPLICATE of bug 93652
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows All
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-07 12:52 EST by Ulf Fildebrandt CLA
Modified: 2009-08-19 12:33 EDT (History)
6 users (show)

See Also:


Attachments
Class Bug10977 - example showing how to read from and write to a SAFEARRAY (7.38 KB, text/plain)
2004-10-06 14:16 EDT, Veronika Irvine CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ulf Fildebrandt CLA 2002-03-07 12:52:40 EST
I have got the problem that I integrated the Internet Explorer like in the
example. Now I have registered for the event BeforeNavigate2 in the
interface DWebBrowserEvents2. When I submit a form in the IE control I run
into the event handler but now I want to look what information is in
PostData.
When I take a look at the type of the Variant it is of VT_BYREF |
VT_VARIANT.

Veronika Irvine answered:
Variant only supports a small bit of functionality required to make the
basic ActiveX stuff work.

So the short answer is that there is no "nice" way to do this - one day I
will get around to it but there is a large number of types defined in
VARIANT and I really prefer to have a test case for each type, and ...

Please can someone implement these functionality?
Comment 1 Veronika Irvine CLA 2002-05-27 10:19:22 EDT
Will look at after R2.0.
Comment 2 Veronika Irvine CLA 2002-08-22 10:24:25 EDT
Here is a workaround for accessing a variant that contains an array:

    Varinat variantByRef; // variantByRef is a VT_BYREF reference to a safearray
                          // obtained through some IDispatch call 
                          // or as a property get.
                          // In this example the safearray contains data of 
                          // type VT_UI1 (or unsigned shorts) with a size of 
                          // 2 bits each.
    int pPostData = variantByRef.getByRef();
    short[] vt_type = new short[1];
    OS.MoveMemory(vt_type, pPostData, 2);
    System.out.println("vt type is "+vt_type[0]);
    if (vt_type[0] == (short)(OLE.VT_BYREF | OLE.VT_VARIANT)) {
        int[] pVariant = new int[1];
        OS.MoveMemory(pVariant, pPostData + 8, 4);
        vt_type = new short[1];
        OS.MoveMemory(vt_type, pVariant[0], 2);
        System.out.println("second vt type is "+vt_type[0]);
        if (vt_type[0] == (short)(OLE.VT_ARRAY | OLE.VT_UI1)) {
            int[] pSafearray = new int[1];
            OS.MoveMemory(pSafearray, pVariant[0] + 8, 4);
            short[] cDims = new short[1];
            OS.MoveMemory(cDims, pSafearray[0], 2);
            System.out.println("dimension of array is "+cDims[0]);
            int[] pvData = new int[1];
            OS.MoveMemory(pvData, pSafearray[0] + 12, 4);
            int offset = 0;
            int safearrayboundOffset = 0;
            for (int i = 0; i < cDims[0]; i++) {
                int[] cElements = new int[1];
                OS.MoveMemory(cElements, pSafearray[0] + 16 +
safearrayboundOffset, 4);
                safearrayboundOffset += 8;
                System.out.println("element count for dimension "+i+" is
"+cElements[0]);
                for (int j = 0; j < cElements[0]; j++) {
                    char[] ui1_data = new char[1];
                    OS.MoveMemory(ui1_data, pvData[0]+offset, 1);
                    System.out.println("data at "+j+" is "+ui1_data[0]);
                    offset += 1;
                }
            }
        }
    }




Comment 3 Stefan Matthias Aust CLA 2003-04-09 06:09:49 EDT
Please also support safearrays as input arguments. For example, if you need to
set the context menu of Microsoft's DHTML edit control, you need to supply two
arrays. This seems to be impossible (for me) with the current implementation.
Comment 4 Veronika Irvine CLA 2004-09-24 10:42:16 EDT
The problem described is a bug which will not be fixed in the current version 
of eclipse.

If you would like to contribute a fix for this problem, please attach a patch 
file and reopen this bug report.
Comment 5 Veronika Irvine CLA 2004-10-06 14:16:23 EDT
Created attachment 15024 [details]
Class Bug10977 - example showing how to read from and write to a SAFEARRAY

The attached file contains an example which reads from a PostData object in a
BeforeNavigate2 event and creates a PostData object in a call to Navigate.

PostData is an example of a SAFEARRAY which contains a one dimensional array of
VT_UI1 (bytes).
Comment 6 Veronika Irvine CLA 2004-10-06 14:25:18 EDT
The following URL is useful for testing PostData interaction.  It contains a 
text field which gets updated from the contents of the PostData field:

http://snowwhite.it.brighton.ac.uk/~mas/mas/courses/html/html3.html

(scroll down towards the bottom of the page to the section on "Post")
Comment 7 Cian Foley CLA 2005-10-18 12:25:06 EDT
Has there been any effort to fix this bug?  will the post data appear on the 
data field on the event object when fixed?  is there any way of getting the 
original event whilst using the browser control to get at the variant 
containing the post data?
Comment 8 padamev297 CLA 2009-04-07 02:13:05 EDT
Can someone tell me the status of this bug.
Status: RESOLVED. Is that mean , it has been fixed?
Moreover the workaround given here doesn't work for me as when i am using the 
 OS.XXX
i am getting a warning message restricted access on package org.eclipse.swt.internal.win32.
Do i need to add this function in the org.eclipse.swt.internal.win32 package itself?
Comment 9 Felipe Heidrich CLA 2009-08-19 12:33:33 EDT

*** This bug has been marked as a duplicate of bug 93652 ***