# 提供API 的做法

Posted by Sephiroth on July 12, 1999 at 14:17:51:

In Reply to: Re: 如何用vb6取得图档的大小等相关资讯 posted by 小琳 on July 10, 1999 at 14:33:03:

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 mobjPicture As StdPicture

Private Sub Form_Load()

Set mobjPicture = LoadPicture("C:\Test.jpg")

End Sub

Private Sub Form_Click()

Dim oBmp As BITMAP, tIconInfo As ICONINFO
Dim iPicWidth As Integer, iPicHeight As Integer
'// 依图片种类算出图片大小
Select Case mobjPicture.Type
Case vbPicTypeBitmap
GetObject mobjPicture, LenB(oBmp), oBmp
With oBmp
iPicWidth = .bmWidth
iPicHeight = .bmHeight
End With
Case vbPicTypeIcon
'// 省略
....
Case Else
End Select

End Sub

Follow Ups: