1,451
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command3_Click()
Dim p As Picture
Set p = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\2009112209300545.jpg")
Picture1.PaintPicture p, (Picture1.Width - ScaleX(p.Width) * Picture1.Height / ScaleY(p.Height)) / 2, 0, _
ScaleX(p.Width) * (Picture1.Height / ScaleY(p.Height)), Picture1.Height, , , ScaleX(p.Width), ScaleY(p.Height)
Set p = Nothing
End Sub
Option Explicit
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
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
Dim bm As BITMAP
Dim hBmp As Long
Public Sub SameToPicture(ByRef pic As PictureBox, ByVal Ifilename As String)
pic.Picture = LoadPicture(Ifilename)
hBmp = pic.Picture.Handle
GetObject hBmp, LenB(bm), bm
pic.Width = bm.bmWidth * Screen.TwipsPerPixelX
pic.Height = bm.bmHeight * Screen.TwipsPerPixelY
End Sub
Private Sub Command1_Click()
SameToPicture Picture1, App.Path & "\" & "124.jpg"
Picture1.Move 0, 0
End Sub
Private Sub Command2_Click()
Image1.Visible = False
Image1.Stretch = False
Image1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\2009112209293733.gif")
Picture1.PaintPicture Image1, (Picture1.Width - Image1.Width * (Picture1.Height / Image1.Height)) / 2, 0, Image1.Width * (Picture1.Height / Image1.Height), Picture1.Height, , , Image1.Width, Image1.Height
Image1.Picture = LoadPicture("")
End Sub
Private Sub Command1_Click()
Set Image1.Container = Picture1
Image1.Stretch = False
Image1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\77553_1261644150946r.jpg")
Image1.Stretch = True
Image1.Width = Image1.Width * (Picture1.Height / Image1.Height)
Image1.Height = Picture1.Height
Image1.Move (Picture1.Width - Image1.Width) / 2, 0
End Sub