Private Sub Form_Load()
Dim pic As StdPicture
Set pic = LoadPicture("D:\sample.jpg")
MsgBox (pic.Height)
MsgBox (pic.Width)
End Sub
或者:
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Sub Command1_Click()
Dim PicInfo As BITMAP
Dim pic As StdPicture
Set pic = LoadPicture("D:\sample.jpg")
GetObject pic.Handle, Len(PicInfo), PicInfo
MsgBox PicInfo.bmHeight
MsgBox PicInfo.bmWidth
End Sub
Dim pic As StdPicture
Set pic = LoadPicture("D:\sample.jpg")
MsgBox (pic.Height)
MsgBox (pic.Width)
End Sub
或者:
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Sub Command1_Click()
Dim PicInfo As BITMAP
Dim pic As StdPicture
Set pic = LoadPicture("D:\sample.jpg")
GetObject pic.Handle, Len(PicInfo), PicInfo
MsgBox PicInfo.bmHeight
MsgBox PicInfo.bmWidth
End Sub
with picturebox
.autosize=true
.loadpicture(yourpicture).heigth 和 .width 就是所求
end with
http://www.vbeden.com/download/code_4/kg.ziphttp://www.vbeden.com/vbcode/code_4.htm