Hi,
ich habe mir folgenden Code zusammen gebastelt:
Private Sub B772_MFD_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
Dim path As String = "MFD_Cursor.ico"
Dim bmp As New Bitmap(path)
Dim cur As New Cursor(bmp.GetHicon)
Me.Cursor = cur
End Sub
Protected Overrides Sub OnPaint(ByVal e As _
System.Windows.Forms.PaintEventArgs)
Dim rect As New MFD_Comm()
rect.CommDrw(10, 10, 130, 28, 2, True, Color.Gray, "ATC", Nothing, _
e.Graphics)
rect.CommDrw(145, 10, 130, 28, 2, False, Color.Gray, "FLIGHT", _
"INFORMATION", e.Graphics)
rect.CommDrw(280, 10, 130, 28, 2, True, Color.LimeGreen, "COMPANY", _
Nothing, e.Graphics)
rect.CommDrw(10, 43, 130, 28, 2, False, Color.Gray, "REVIEW", Nothing, _
e.Graphics)
rect.CommDrw(145, 43, 130, 28, 2, True, Color.Gray, "MANAGER", Nothing, _
e.Graphics)
rect.CommDrw(280, 43, 130, 28, 2, False, Color.Aquamarine, "NEW" & _
"MESSAGES", Nothing, e.Graphics)
End Sub Public Class MFD_Comm
Public Sub CommDrw(ByVal a As Single, _
ByVal b As Single, _
ByVal c As Single, _
ByVal d As Single, _
ByVal thk As Integer, _
ByVal fill As Boolean, _
ByVal col As Color, _
ByVal txt1 As String, _
ByVal txt2 As String, _
ByVal g As Graphics)
Dim x As Single
Dim y As Single
x = c
y = d
x = x / 2
y = y / 2
Dim r As New Rectangle(a, b, c, d)
Dim fnt As New Font("Arial Narrow", 11)
If txt2 = Nothing Then
Dim siz As SizeF = g.MeasureString(txt1, fnt)
If fill = False Then
Dim mypen As New Pen(Color.DeepSkyBlue, thk)
g.DrawRectangle(mypen, r)
mypen.Dispose()
g.DrawString(txt1, fnt, Brushes.DeepSkyBlue, x + a - siz.Width _
/ 2, y + b - siz.Height / 2)
fnt.Dispose()
Else
Dim mypen As New Pen(col, thk)
Dim mybrush As Brush
mybrush = New SolidBrush(col)
g.DrawRectangle(mypen, r)
g.FillRectangle(mybrush, r)
mypen.Dispose()
g.DrawString(txt1, fnt, Brushes.White, x + a - siz.Width / 2, y _
+ b - siz.Height / 2)
fnt.Dispose()
End If
Else
Dim siz1 As SizeF = g.MeasureString(txt1, fnt)
Dim siz2 As SizeF = g.MeasureString(txt2, fnt)
If fill = False Then
Dim mypen As New Pen(Color.DeepSkyBlue, thk)
g.DrawRectangle(mypen, r)
mypen.Dispose()
g.DrawString(txt1, fnt, Brushes.DeepSkyBlue, x + a - siz1.Width _
/ 2, y + b - 7.8 - siz1.Height / 2)
g.DrawString(txt2, fnt, Brushes.DeepSkyBlue, x + a - siz2.Width _
/ 2, y + b + 6.2 - siz2.Height / 2)
fnt.Dispose()
Else
Dim mypen As New Pen(col, thk)
Dim mybrush As Brush
mybrush = New SolidBrush(col)
g.DrawRectangle(mypen, r)
g.FillRectangle(mybrush, r)
mypen.Dispose()
g.DrawString(txt1, fnt, Brushes.White, x + a - siz1.Width / 2, _
y + b - 7.8 - siz1.Height / 2)
g.DrawString(txt2, fnt, Brushes.White, x + a - siz2.Width / 2, _
y + b + 6.2 - siz2.Height / 2)
fnt.Dispose()
End If
End If
End Sub
End Class Soweit tut das Programm auch was ICH will *gg*. Nun möchte ich aber das wenn die Maus über eines der gezeichneten Rechtecke fährt ein neues weißes Rechteck um das bereits gezeichnete Recheck erscheint und bei verlassen des Rechtecks(bereichs) wieder verschwindet. Ich habe aber keine Ahnung wie ich feststellen kann wann die Maus sich über einem Rechteck befindet und wann nicht. Weiterhin möchte ich das bei einem Click auf ein Recheck sich z.B. das angeklickte Rechteck und auch andere Rechtecke in ihrer Farbe ändern. Es läuft also immer wieder auf das Problem hinaus wie ich festellen kann ob sich die Maus über einem Rechteck befindet oder nicht. Kann mir da wohl jemand weiterhelfen???
Vielen Dank schon mal im Voraus
Fred |