Hi
Egal ob ich die PictureBox (PB) oder das Controll benutze es klappt nicht. Erst wenn ich eine eigene Anwendung mache und das Controll einbinde, dann kann ich auf das Controll ein Mousewheel-Event bekommen.
Die Frage ist eben wie ich innerhalb von meinem UserControll das MouseWheel-Event bekommen.
Ich möchte das Controll in verschiedenen Anwendungen einsetzen und nicht immer in der Anwendung das Event abfangen und an das Controll weiter geben.
Public Class Form1
Private Sub ZoomingPictureBox1_MouseWheel(sender As Object, e As _
System.Windows.Forms.MouseEventArgs) Handles ZoomingPictureBox1.MouseWheel
' Hier gehts
Debug.Print(e.Delta)
End Sub
End Class Das ist mein UserControll. Leider geht hier das MouseWheel nicht.
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Public Class ZoomingPictureBox
Friend oBitmap As Bitmap
Friend tBitmap As Bitmap
Friend tBitmap_width As Single = 0
Friend tBitmap_height As Single = 0
Friend tBitmap_zoom As Single = 1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
oBitmap = Image.FromFile("demopic.jpg")
show_PicSector()
End Sub
Friend Sub show_PicSector()
If tBitmap Is Nothing Then
tBitmap = New Bitmap(PB.Width, PB.Height, _
Imaging.PixelFormat.Format24bppRgb)
tBitmap_width = tBitmap.Width
tBitmap_height = tBitmap.Height
Else
If tBitmap.Width = tBitmap_width Or tBitmap.Height = tBitmap_height _
Then
tBitmap.Dispose()
tBitmap = New Bitmap(PB.Width, PB.Height, _
Imaging.PixelFormat.Format24bppRgb)
End If
End If
Dim bmGraphics As Graphics = Graphics.FromImage(tBitmap)
bmGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic
bmGraphics.DrawImage(oBitmap, New Rectangle(0, 0, PB.Width, PB.Height), _
New Rectangle(0, 0, oBitmap.Width / tBitmap_zoom, oBitmap.Height / _
tBitmap_zoom), GraphicsUnit.Pixel)
bmGraphics.Dispose()
PB.Image = tBitmap
PB.Refresh()
End Sub
Private Sub PB_MouseWheel(sender As Object, e As _
System.Windows.Forms.MouseEventArgs) Handles PB.MouseWheel
' Das geht nicht! Es kommt nie zu einem Event.
' Auch das UserControll (ZoomingPictureBox) selbst kommt kein Event
Debug.Print(e.Delta)
PB.Refresh()
End Sub
End Class befficient - consulting & programming
Tracability Know-How seit über 5 Jahren
itac (MES.Suite) Client Programmierung
|