Private Declare Function OleCreatePictureIndirect Lib "oleaut32" (ByRef lpPictDesc As PicBmp, riid As GUID, ByVal fOwn As Long, ByRef lplpvObj As Any) As Long
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Type PicBmp
Size As Long
Type As PictureTypeConstants
hBmp As Long
hPal As Long
Reserved As Long
End Type
Public Function GetPicture(PyVal hPic as long) As IPictureDisp
Dim p As PicBmp, g As GUID
With p
.hBmp = hPic
.Size = Len(p)
.Type = vbPicTypeBitmap
End With
'IDispatch
With g
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
'Внимание. 0 означает, что картинка не становится собственностью объекта StdPicture и не будет уничтожена при его уничтожении.
OleCreatePictureIndirect p, g, 0, GetPicture
End Function
....
SavePicture GetPicture(hBitmap), "file"
....
Сейчас этот форум просматривают: Yandex-бот и гости: 131