Option Explicit Dim pict(3) As String '用来存储图片 pict(0) = App.Path & "\0.jpg" pict(1) = App.Path & "\006[4].jpg" pict(2) = App.Path & "\006[5].jpg" pict(3) = App.Path & "\008[1].jpg" Private Sub Timer1_Timer() Static i As Integer If cmddemo.Caption = "停止(&T)" Then Image1.Picture = LoadPicture(pict(i)) i = i + 1 If i = 3 Then i = 0 End If End Sub
Dim arr() As String arr(0)=App.Path & "1.bmp" Picture1.Picture=LoadPicture(arr(0))
Dim a As StdPictureSet a = LoadPicture("C:\My Documents\THgroup1.ico") Set Me.Picture = a
Dim a As StdPictureSet a = LoadPicture("C:\My Documents\THgroup1.ico") Set Me.Picture = a
如果是这样,楼主直接用 Set Me.Picture = LoadPicture("C:\My Documents\THgroup1.ico") 不就得了,何需用什么stdPicture对象!!!哎。
楼主,我跟你遇到了一样的问题,刚想发帖,没想到已经有了. 干脆帮忙顶一个吧. 这是我目前用的方法.Dim MyFilelen As Long Dim TempPath As String Dim MyBinary() As Byte TempPath = App.Path & "\temp.jpg" Open "E:\Visual Basic\Visual Basic\001.jpg" For Binary As #1 MyFilelen = LOF(1) ReDim MyBinary(MyFilelen) Get #1, , MyBinary Close Open TempPath For Binary As #2 Put #2, , MyBinary Close Picture1.Picture = LoadPicture(TempPath) Kill TempPath
Option ExplicitPrivate Type GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(7) As Byte End TypePrivate Declare Function CreateStreamOnHGlobal Lib "ole32.dll" (ByRef hGlobal As Any, ByVal fDeleteOnResume As Long, ByRef ppstr As Any) As Long Private Declare Function OleLoadPicture Lib "olepro32.dll" (ByVal lpStream As IUnknown, ByVal lSize As Long, ByVal fRunMode As Long, ByRef riid As GUID, ByRef lplpObj As Any) As Long Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByRef pclsid As GUID) As Long' HKEY_CLASSES_ROOT\Interface\{7BF80980-BF32-101A-8BBB-00AA00300CAB} = IPicture Private Const SIPICTURE As String = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"' convert a byte array to IPicture Public Function PictureFromRes(ByRef b() As Byte) As IPicture On Error GoTo errorhandler
Dim istrm As IUnknown Dim tGuid As GUID
If Not CreateStreamOnHGlobal(b(LBound(b)), False, istrm) Then CLSIDFromString StrPtr(SIPICTURE), tGuid OleLoadPicture istrm, UBound(b) - LBound(b) + 1, False, tGuid, PictureFromRes End If
Set istrm = Nothing Exit Function errorhandler: Debug.Print "Could not convert to IPicture!" End FunctionPrivate Sub Command1_Click() Dim buff() As Byte buff = LoadResData(101, "jpg") Set Me.Picture1.Picture = PictureFromRes(buff) End Sub
a(0)=图片
loadPicture(a(0))
Dim pict(3) As String '用来存储图片
pict(0) = App.Path & "\0.jpg"
pict(1) = App.Path & "\006[4].jpg"
pict(2) = App.Path & "\006[5].jpg"
pict(3) = App.Path & "\008[1].jpg"
Private Sub Timer1_Timer()
Static i As Integer
If cmddemo.Caption = "停止(&T)" Then
Image1.Picture = LoadPicture(pict(i))
i = i + 1
If i = 3 Then i = 0
End If
End Sub
arr(0)=App.Path & "1.bmp"
Picture1.Picture=LoadPicture(arr(0))
Set Me.Picture = a
Set Me.Picture = a
LoadPicture("C:\My Documents\THgroup1.ico")
你那个文件是在内存中?晕倒
bitblt
bitblt
Set Me.Picture = LoadPicture("C:\My Documents\THgroup1.ico")
不就得了,何需用什么stdPicture对象!!!哎。
干脆帮忙顶一个吧.
这是我目前用的方法.Dim MyFilelen As Long
Dim TempPath As String
Dim MyBinary() As Byte
TempPath = App.Path & "\temp.jpg"
Open "E:\Visual Basic\Visual Basic\001.jpg" For Binary As #1
MyFilelen = LOF(1)
ReDim MyBinary(MyFilelen)
Get #1, , MyBinary
Close
Open TempPath For Binary As #2
Put #2, , MyBinary
Close
Picture1.Picture = LoadPicture(TempPath)
Kill TempPath
提供对系统 Clipboard 的访问。语法Clipboard说明Clipboard 对象用于操作剪贴板上的文本和图形。它使用户能够复制、剪切和粘贴应用程序中的文本和图形。在复制任何信息到 Clipboard 对象中之前,应使用 Clear 方法清除 Clipboard 对象中的内容,例如 Clipboard.Clear。注意所有 Windows 应用程序共享 Clipboard 对象,因此当切换到其它应用程序时,剪贴板内容会改变。Clipboard 对象可包含多段数据,只要每段数据的格式不同。例如,可用 SetData 方法把位图以 vbCFDIB 格式放到 Clipboard 中,接着再用 SetText 方法以 vbCFText 格式将文本放到 Clipboard 中。然后用 GetText 方法检索文本或用 GetData 方法检索图形。当用代码或菜单命令把另一段数据放到 Clipboard 中时,原 Clipboard 中相同格式的数据会丢失。
返回一个 Clipboard 对象,该对象提供了对系统 Clipboard 的访问途径。语法Clipboard说明Clipboard 对象是用来对 Clipboard 上的文本和图形进行操作的。使用该对象就可以让用户把文本或者图形复制、剪切并粘贴到应用程序中。在把任何材料复制到 Clipboard 对象中之前,应先执行 Clear 方法(比如 Clipboard.Clear)来清除该对象的内容。注意,Clipboard 对象为所有 Windows 应用程序所共享,因此,当切换到另一个应用程序时,其内容可能会被更改。Clipboard 对象可以包含许多数据片段,只要每个片段都有不同的格式。例如,可以用 SetData 方法将一个具有 vbCFDIB 格式的位图放到的 Clipboard 上,然后用 SetText 方法将具有 vbCFText 格式的文本放到 Clipboard 上。然后就可用 GetText 方法获取文本或用 GetData 方法获取图形了。不论是通过代码还是菜单命令,只要把具有同样格式的另一个数据集合放到 Clipboard 上去,Clipboard 上的数据就会丢失。
参看:http://www.honjian.com/view.asp?id=260
set me.picture=loadrespicture(XXXX)的方法。
是这样的 我在资源文件文件有个自定义的资源 jpg.mid,avi,mp3 等 我如何使用他们呢?
不要把他们先保存到磁盘里然后在用(这样一来能让人看见还不变慢)总之就是不想这样去用。
从资源文件中读取各种格式图片
更新日期 2003-7-24 程序类别 VB源码¦用户界面
文件大小 不详 授权方式 免费
应用平台 win9x/win2000 推荐程度
程序主页 Home Page 下载/浏览 4/6
下载地址 下载1
简介:
暂时没有该代码的介绍
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End TypePrivate Declare Function CreateStreamOnHGlobal Lib "ole32.dll" (ByRef hGlobal As Any, ByVal fDeleteOnResume As Long, ByRef ppstr As Any) As Long
Private Declare Function OleLoadPicture Lib "olepro32.dll" (ByVal lpStream As IUnknown, ByVal lSize As Long, ByVal fRunMode As Long, ByRef riid As GUID, ByRef lplpObj As Any) As Long
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByRef pclsid As GUID) As Long' HKEY_CLASSES_ROOT\Interface\{7BF80980-BF32-101A-8BBB-00AA00300CAB} = IPicture
Private Const SIPICTURE As String = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"' convert a byte array to IPicture
Public Function PictureFromRes(ByRef b() As Byte) As IPicture
On Error GoTo errorhandler
Dim istrm As IUnknown
Dim tGuid As GUID
If Not CreateStreamOnHGlobal(b(LBound(b)), False, istrm) Then
CLSIDFromString StrPtr(SIPICTURE), tGuid
OleLoadPicture istrm, UBound(b) - LBound(b) + 1, False, tGuid, PictureFromRes
End If
Set istrm = Nothing
Exit Function
errorhandler:
Debug.Print "Could not convert to IPicture!"
End FunctionPrivate Sub Command1_Click()
Dim buff() As Byte
buff = LoadResData(101, "jpg")
Set Me.Picture1.Picture = PictureFromRes(buff)
End Sub
不是吗?