Mahlzeit! Mich stört an diesem Beispiel, dass zwei Pictureboxen benötigt werden. Mein Beispiel scrollt und zoomt mit -einer Picturebox, Name: "Picture1" -einer VScrollbar, Name: "VScroll1" -zwei HScrollBar, Namen: "HScroll1" und "HScroll2" HScroll1 und VScroll1 scrollen das Bild horizontal und vertikal, HScroll2 stellt den Zoomfaktor ein. Kennt jemand eine Möglichkeit, die echten Abmessungen (in Pixeln) eines Bildes zu finden ohne auf die WinAPI zurückzugreifen? 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
Private mBmp As BITMAP
Private Sub Form_Load() Dim temp As Long
With Picture1 .ScaleMode = 3 .Picture = LoadPicture("Test.bmp") temp = GetObject(.Picture, Len(mBmp), mBmp) .PaintPicture .Picture, 0, 0, _ .ScaleWidth, .ScaleHeight, _ 0, 0, _ .ScaleWidth, .ScaleHeight, _ vbSrcCopy HScroll1.Min = 0 HScroll1.Max = mBmp.bmWidth - .ScaleWidth HScroll2.Min = 1 HScroll2.Max = 8 VScroll1.Min = 0 VScroll1.Max = mBmp.bmHeight - .ScaleHeight End With End Sub
Private Sub HScroll1_Change() With Picture1 .PaintPicture .Picture, _ 0, 0, _ .ScaleWidth, .ScaleHeight, _ HScroll1.Value, VScroll1.Value, _ .ScaleWidth / HScroll2.Value, .ScaleHeight / HScroll2.Value, _ vbSrcCopy End With End Sub
Private Sub HScroll1_Scroll() HScroll1_Change End Sub
Private Sub HScroll2_Change() HScroll1_Change End Sub
Private Sub VScroll1_Change() HScroll1_Change End Sub
Private Sub VScroll1_Scroll() HScroll1_Change End Sub |