Public Property Get Picture() As StdPicture
'读取
    Set Picture = imgPicture.Picture
End PropertyPublic Property Get Picture() As Picture
'读取
    Set Picture = imgPicture.Picture
End Property

解决方案 »

  1.   

    应该没有太大区别~按F2进对象浏览器可以查看Picture的定义:
    Property Picture As IPictureDispIPictureDisp和StdPicture又都是stdole里的Class有相同的属性:
    Handle As OLE_HANDLE
    Height As OLE_YSIZE_HIMETRIC
    hPal As OLE_HANDLE
    Type As Integer
    Width As OLE_XSIZE_HIMETRIC和方法:
    Sub Render(hdc As Long, x As Long, y As Long, cx As Long, cy As Long, xSrc As OLE_XPOS_HIMETRIC, ySrc As OLE_YPOS_HIMETRIC, cxSrc As OLE_XSIZE_HIMETRIC, cySrc As OLE_YSIZE_HIMETRIC, prcWBounds As Any)
      

  2.   


    stdPicture类一共有两个接口,其中就包括Picture接口,另一个是IPicture接口
    Picture接口是stdPicture的默认接口,所以一定程度上,说stdPicture类型等于Picture类型也并没有错(因为很少使用IPicture接口)IPicture接口比Picture接口多了一些属性,如下面这些(不完全):
     Attributes
     CurDC
     KeepOriginalFormat
     Type等等我们常见的VB内部控件的Pictue属性,通过?TypeName(Me.Picture)得知是Picture类,但从对象浏览器看到的却是IPictureDisp,这是因为IPictureDisp是Picture类型的一个别名或映射。纠正楼上的一点错误,楼主这句:  Public Property Get Picture() As Picture 中的As Picture是指Picture类型,而非“Picture属性”。
    Picture类型在VB的对象浏览器中是看不见的——显示隐藏也。下面的公式大致说明了这种关系:
    stdPicture = Picture + IPicture
    Picture = IPictureDisp
      

  3.   

    查了下MSDN,糊涂了……Standard Picture Object:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/olectrl_4g50.asp
    StdPicture Object:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbobjpicture.asp
    IPicture:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/ctin_p_482t.asp
    IPictureDisp:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/ctin_p_4gfk.aspStandard Picture Object 里面说的是
    ...Its primary interfaces are IPicture and IPictureDisp...
    那么标准的 Picture 是该有 IPicture 和 IPictureDisp 的接口
    可VB控件的 Picture 属性又都是 Property Picture As IPictureDisp然后 IPictureDisp 的说明又是:
    Use this interface to change or retrieve the properties of a picture object
    VB里的 IPictureDisp 比他多出一个 Render 方法
    估计是用标准的 IPictureDisp 再加上 IPicture 的 Render唯一一个是 Visual Basic Reference 的 StdPicture Object 的说明
    ...enables you to manipulate ... images assigned to objects having a Picture property.可以这样用StdPicture
    Dim t As StdPicture
    Set t = Me.Picture
    所以VB里面 stdPicture 和 IPictureDisp 应该是相同的类
    然后不管 TypeName(Me.Picture) 还是 TypeName(t) 得到的都是 Picture
    那么 stdPicture 和 IPictureDisp 就都该是 Picture 的别名或映射才对吧~
    虽然这个 Picture 已经不是那个 Standard Picture Object 了……
      

  4.   

    只存在stdPicture类
    Picture类是VB编译器修饰出来的(不信的话在对象浏览器中查找Picture类试试)
    VB编译器会自动将Picture映射成stdPicturestdPicture是在stdole2.tlb中定义的
    VB故意将它的类名(TypeName)设置成Picture
    以保证与MSDN文档兼容
    (否则会出现TypeName(me.Picture)="StdPicture"的怪事)stdPicture是COM类
    它继承了IPictureDisp、IPicture两个COM接口
    其中IPictureDisp是它的默认接口
    所以stdPicture类的方法与IPictureDisp相同TypeName是的到类的名字
    而不是得到接口的名字
    如果你的一个类(假设是MyPicture)继承了IPictureDisp接口
    你用MyPicture对象的IPictureDisp接口去调用TypeName
    其结果是MyPicture,而不是IPictureDisp
      

  5.   

    Ringfo(糯米(找了好些年,竟没发现VB高手)) 纠正楼上的一点错误,楼主这句:  Public Property Get Picture() As Picture 中的As Picture是指Picture类型,而非“Picture属性”。
    Picture类型在VB的对象浏览器中是看不见的——显示隐藏也。-------------------------------------------------------------在VB的对象浏览器右击鼠标弹出快捷菜单
    选上“显示隐藏成员”
    这时就能在对象浏览器中看隐藏成员了(比如现在看得见IPicture、VarPtr等)如果还不相信的话
    用OLEView察看stdole2.tlb=============================================================刚才仔细用OLEView察看stdole2.tlb
    发现我上面讲错了一点Picture是存在的
    只不过它是接口而不是类
    stdole2.tlb用typedef定义IPicture等同于Picture
        [
          odl,
          uuid(7BF80980-BF32-101A-8BBB-00AA00300CAB),
          helpstring("Picture Object"),
          hidden
        ]
        interface IPicture : IUnknown {
            [propget]
            HRESULT _stdcall Handle([out, retval] OLE_HANDLE* phandle);
            [propget]
            HRESULT _stdcall hPal([out, retval] OLE_HANDLE* phpal);
            [propget]
            HRESULT _stdcall Type([out, retval] short* ptype);
            [propget]
            HRESULT _stdcall Width([out, retval] OLE_XSIZE_HIMETRIC* pwidth);
            [propget]
            HRESULT _stdcall Height([out, retval] OLE_YSIZE_HIMETRIC* pheight);
            HRESULT _stdcall Render(
                            [in] int hdc, 
                            [in] long x, 
                            [in] long y, 
                            [in] long cx, 
                            [in] long cy, 
                            [in] OLE_XPOS_HIMETRIC xSrc, 
                            [in] OLE_YPOS_HIMETRIC ySrc, 
                            [in] OLE_XSIZE_HIMETRIC cxSrc, 
                            [in] OLE_YSIZE_HIMETRIC cySrc, 
                            [in] void* prcWBounds);
            [propput]
            HRESULT _stdcall hPal([in] OLE_HANDLE phpal);
            [propget]
            HRESULT _stdcall CurDC([out, retval] int* phdcOut);
            HRESULT _stdcall SelectPicture(
                            [in] int hdcIn, 
                            [out] int* phdcOut, 
                            [out] OLE_HANDLE* phbmpOut);
            [propget]
            HRESULT _stdcall KeepOriginalFormat([out, retval] VARIANT_BOOL* pfkeep);
            [propput]
            HRESULT _stdcall KeepOriginalFormat([in] VARIANT_BOOL pfkeep);
            HRESULT _stdcall PictureChanged();
            HRESULT _stdcall SaveAsFile(
                            [in] void* pstm, 
                            [in] VARIANT_BOOL fSaveMemCopy, 
                            [out] long* pcbSize);
            [propget]
            HRESULT _stdcall Attributes([out, retval] long* pdwAttr);
            HRESULT _stdcall SetHdc([in] OLE_HANDLE hdc);
        };    [
          uuid(7BF80981-BF32-101A-8BBB-00AA00300CAB)
        ]
        dispinterface Picture {
            properties:
                [id(00000000), readonly]
                OLE_HANDLE Handle;
                [id(0x00000002)]
                OLE_HANDLE hPal;
                [id(0x00000003), readonly]
                short Type;
                [id(0x00000004), readonly]
                OLE_XSIZE_HIMETRIC Width;
                [id(0x00000005), readonly]
                OLE_YSIZE_HIMETRIC Height;
            methods:
                [id(0x00000006)]
                void Render(
                                int hdc, 
                                long x, 
                                long y, 
                                long cx, 
                                long cy, 
                                OLE_XPOS_HIMETRIC xSrc, 
                                OLE_YPOS_HIMETRIC ySrc, 
                                OLE_XSIZE_HIMETRIC cxSrc, 
                                OLE_YSIZE_HIMETRIC cySrc, 
                                void* prcWBounds);
        };    typedef [public]
        Picture IPictureDisp;    [
          uuid(0BE35204-8F91-11CE-9DE3-00AA004BB851)
        ]
        coclass StdPicture {
            [default] dispinterface Picture;
            interface IPicture;
        };
      

  6.   

    打错了stdole2.tlb用typedef定义IPictureDisp等同于Picture
      

  7.   

    高手如云啊!还是听得糊里糊涂的,我认为就是 图片属性用 As StdPicture和 As Picture两个都基本一样。再问,我自定义控件的MouseIcon(鼠标指针)属性用哪种数据类型,我现在用了 As StdPicture但事实这样是不对的,如果选择图标时选择一个图片文件(*.bmp;*.jpg)等就是有错的,这表示我的数据类型一定没有使用对,那到底应该用哪个数据类型呢?没有找到有一ICON类似的数据类型啊。