Thumbnail in picture control

Thumbnail in picture control

jplujan
Advocate Advocate
304 Views
0 Replies
Message 1 of 1

Thumbnail in picture control

jplujan
Advocate
Advocate

I have the following code, which shows me the image of the file in a bitmap control.

 

 

    Public Function VerThumbnail(doc As String, ctr As PictureBox) As Image
        Dim retorno As Image
        Dim oApprentice As ApprenticeServerComponent
        Dim oDoc As ApprenticeServerDocument

        oApprentice = New ApprenticeServerComponent

        Try
            oDoc = oApprentice.Open(doc)

        Catch
            'MessageBox.Show("cannot open the file!")
            Return Nothing

        End Try

        Dim oPD As stdole.IPictureDisp = oDoc.Thumbnail
        Dim oMF As Metafile = New Metafile(New IntPtr(oPD.Handle), New WmfPlaceableFileHeader)
        Dim oCallBack As Image.GetThumbnailImageAbort = New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
        retorno = oMF.GetThumbnailImage(ctr.Width, ctr.Height, oCallBack, IntPtr.Zero)

        Return retorno

    End Function

    Private Function ThumbnailCallback() As Boolean
        Return False
    End Function

 

The case that the code works for me sometimes in some files I can see without any problem the image and in others it does not matter that they are ipart file as part, in theory he says he can't open the file


Thanks in advance

0 Likes
305 Views
0 Replies
Replies (0)