Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15765

Querying an image control for the IPicture Interface

$
0
0
Hi,

Can anybody tell me what I am doing wrong ,

The following code is supposed to give me pointer to the IPicture interface from an Image control in my userform but fails ...

BTW, i am using the low level DispCallFunc api in the vtblCall routine .

I have also tried getting the IPictureDisp interface but without any luck.



Code:

Sub Test()

    Const CC_STDCALL As Long = 4
    Const S_OK As Long = 0
    Const IUnknownQueryInterface = 0
    Const IUnknownRelease = 8
    Const IPicture_interface = "{7bf80980-bf32-101a-8bbb-00aa00300cab}" 'IPicture uuid
    'Const IPictureDisp_interface = "{7bf80981-bf32-101a-8bbb-00aa00300cab}" ' IPictureDisp uuid

    Dim uGUID(0 To 3) As Long
    Dim pUnk As Long, pPicInterFace As Long
   

    If IIDFromString(StrPtr(IPicture_interface), VarPtr(uGUID(0))) = S_OK Then
        pUnk = ObjPtr(Me.Image1)
        If vtblCall(pUnk, IUnknownQueryInterface, vbLong, CC_STDCALL, VarPtr(uGUID(0)), VarPtr(pPicInterFace)) = S_OK Then
            MsgBox pPicInterFace  '<== code never reaches this point !!
            vtblCall pPicInterFace, IUnknownRelease, vbLong, CC_STDCALL
        End If
    End If
 
End Sub

I get -2147467262 "No such interface supported" however, I know the Image control DOES implement the IPicture interface ... I am confused !

Viewing all articles
Browse latest Browse all 15765


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>