Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1460

Take advantage of IThumbNailProvider

$
0
0
Here is a simple example how to to "skin" your form with a thumbnail.
Since with this thumbnailhandler you can use up to max 2048 pixels depending on what source you use!

I just choosed to make a printscreen of my current job...

Code:


Public Function GetPIDLFromPath(ByVal sPath As String) As Long
 
  If (Len(sPath) = 0) Or (sPath = "") Then Exit Function
 
  GetPIDLFromPath = ILCreateFromPathW(StrPtr(sPath))
End Function

Public Function ShCreateIThumbNailProvider(ByVal pidlItem As Long, ByRef pITNP As IThumbnailProvider) As Long
  Dim hr As Long
  Dim pISI As IShellItem
  Static IID_IThumbnailProvider As UUID
 
  If pidlItem = 0 Then
    ShCreateIThumbNailProvider = -1
    Exit Function
  End If
 
  hr = SHCreateAnyItemFromIDList(pidlItem, IID_IShellItem, pISI)
 
  If hr = S_OK Then
    IIDFromString StrPtr("{E357FCCD-A995-4576-B01F-234630154E96}"), IID_IThumbnailProvider
    hr = pISI.BindToHandler(0&, BHID__ThumbnailHandler, IID_IThumbnailProvider, pITNP)
    If hr = S_OK Then
      ShCreateIThumbNailProvider = hr
    End If
  End If
  ShCreateIThumbNailProvider = hr
End Function

Private Sub Command11_Click()
  Dim pidl As Long
  Dim pITNP As IThumbnailProvider
  Dim hBmp As Long
 
  pidl = m_cShell32.GetPIDLFromPath("C:\Test.jpg")
 
  m_cShell32.ShCreateIThumbNailProvider pidl, pITNP
 
  pITNP.GetThumbnail 2048, hBmp, WTSAT_ARGB
  Set Form1.Picture = m_cOle32.HandleToPicture(hBmp, vbPicTypeBitmap)
  DeleteObject hBmp
  Set pITNP = Nothing
End Sub

As far I have understod this thumbnail handler is far more effective then the others.
Regarding to the documenation the adornments for thumbnails you as a coder can not affect them in this stage.
The adornments are affected by the the current theme attached. And take it from there with the theme API's.

Cheers and Have Fun ;):cool:
Attached Images
  

Viewing all articles
Browse latest Browse all 1460

Trending Articles



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