ест функция от tyomitch-а
- Код: Выделить всё
Private Function CreatePictureFromBitmap(ByVal hBmp As Long, PicType As Long) As StdPicture
Dim Pic As PicBmp, IID_IDispatch As GUID
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
With Pic
.Size = Len(Pic)
.Type = PicType
.hBmp = hBmp
.hPal = 0
End With
OleCreatePictureIndirect Pic, IID_IDispatch, 1, CreatePictureFromBitmap
End Function
и иконка в Picture с ресаизом
- Код: Выделить всё
Private Function FitIconToPicture(ByVal hIcon As Long) As Picture
Dim hDC As Long, hBmp As Long, hBmpOld As Long
Set Picture1.Picture = CreatePictureFromBitmap(hIcon, &H3) ‘1
hDC = CreateCompatibleDC(Picture1.hDC)
hBmp = CreateCompatibleBitmap(hDC, 20, 20)
hBmpOld = SelectObject(hDC, hBmp)
StretchBlt hDC, 0, 0, 20, 20, Picture1.hDC, 0, 0, 32, 32, vbSrcCopy
SelectObject hDC, hBmpOld
DeleteDC hDC
Set Picture1.Picture = CreatePictureFromBitmap(hBmp, &H1) ‘2
Set FitIconToPicture = Picture1.Picture
End Function
После первого Set Picture1.Picture = CreatePictureFromBitmap
рисунок цветной
После второго, черно-белый. причем, "черно" как уголь
Где я ошибаюсь?