Private Const RT_BITMAP = 2&
Private Const RT_ICON = 3&
Private Const RT_CURSOR = 1&
Private Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(7) As Byte
End TypePrivate Type PicBmp
    Size As Long
    Type As Long
    hBmp As Long
    hPal As Long
    Reserved As Long
End TypePrivate Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long, ByVal iType As Integer) As Picture    Dim R As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID    'Fill GUID info
    With IID_IDispatch
        .Data1 = &H20400
        .Data4(0) = &HC0
        .Data4(7) = &H46
    End With    'Fill picture info
    With Pic
        .Size = Len(Pic) ' Length of structure
        .hBmp = hBmp ' Handle to bitmap
        .hPal = hPal ' Handle to palette (may be null)
        
        If iType = 0 Then
            .Type = vbPicTypeBitmap ' Type of Picture (bitmap)
        Else
            .Type = vbPicTypeIcon
        End If
    End With    'Create the picture
    R = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)    'Return the new picture
    Set CreateBitmapPicture = IPic
    
End Function用这个函数可以将ICON的Handle转化为Picture,然后就可以用了.

解决方案 »

  1.   

    你试试 这个::
    ===============================
    Dim X As New StdPictureX.hPal = '你的Icon Handle
    Set Picture1.Picture = X 
      

  2.   

    to sonicdater(发呆呆) :
    我试了一下,调试报错阿?to:uguess(uguess) 
    能给个调用的例子吗?谢谢!
      

  3.   

    Option ExplicitPrivate Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
    Private Const RT_BITMAP = 2&
    Private Const RT_ICON = 3&
    Private Const RT_CURSOR = 1&
    Private Type GUID
        Data1 As Long
        Data2 As Integer
        Data3 As Integer
        Data4(7) As Byte
    End TypePrivate Type PicBmp
        Size As Long
        Type As Long
        hBmp As Long
        hPal As Long
        Reserved As Long
    End TypePrivate Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long, ByVal iType As Integer) As Picture    Dim R As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID    'Fill GUID info
        With IID_IDispatch
            .Data1 = &H20400
            .Data4(0) = &HC0
            .Data4(7) = &H46
        End With    'Fill picture info
        With Pic
            .Size = Len(Pic) ' Length of structure
            .hBmp = hBmp ' Handle to bitmap
            .hPal = hPal ' Handle to palette (may be null)
            
            If iType = 0 Then
                .Type = vbPicTypeBitmap ' Type of Picture (bitmap)
            Else
                .Type = vbPicTypeIcon
            End If
        End With    'Create the picture
        R = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)    'Return the new picture
        Set CreateBitmapPicture = IPic
        
    End Function
    Private Sub Form_Load()
    Dim hBmp As Long '这就是你获得的ICON的句柄
        
        Command1.Picture = CreateBitmapPicture(hBmp, 0, RT_ICON)End Sub
    窗体上要有一个CommandButton,且Style=1.