also ich habs jetzt doch noch hinbekommen *freudensprung mach*
jetzt würd ich noch gern wissen wie man die farben so hinbekommt(Farbenname oder so) wie bei winxp menus.
und die wichtigere Frage:
wie kann ich die schriftart des formtitels ändern (da es mit der font eigenschaft bei mir nicht klappt)
und vielleicht kann ja einer mein Testcode für das menu brauchen:
Private Const FONT_NAME As String = "Arial Unicode MS"
Private Const FONT_SIZE As Single = 12
Private Const FONT_STYLE As FontStyle = FontStyle.Regular
Dim MENU_CAPTION As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
' Create an empty MainMenu.
Dim mainMenu1 As New MainMenu
Dim menuItem1 As New MenuItem("&File")
Dim menuItem2 As New MenuItem
Dim menuitem3 As New MenuItem
Dim menuItem5 As New MenuItem("&Help")
Dim menuitem6 As New MenuItem
' Set the caption for the first submenu.
menuItem2.Text = "&Open"
menuitem3.Text = "E&xit"
' set the caption for second submenu
menuitem6.Text = "&About"
' Add menuItem2 and menuItem3 to menuItem1's list of menu items.
menuItem1.MenuItems.Add(menuItem2)
menuItem1.MenuItems.Add(menuitem3)
' Add menuItem6 to menuItem5's list of menu items.
menuItem5.MenuItems.Add(menuitem6)
' Add two MenuItem objects to the MainMenu for displaying.
mainMenu1.MenuItems.Add(menuItem1)
mainMenu1.MenuItems.Add(menuItem5)
'AddHandler menuItem2.Click, AddressOf Me.Item1_Click 'handles the _
menuitem2 click
menuItem1.OwnerDraw = True
menuItem2.OwnerDraw = True
menuitem3.OwnerDraw = True
menuItem5.OwnerDraw = True
menuitem6.OwnerDraw = True
MENU_CAPTION = "test"
AddHandler menuItem1.MeasureItem, New MeasureItemEventHandler(AddressOf _
MeasureItem)
AddHandler menuItem2.MeasureItem, New MeasureItemEventHandler(AddressOf _
MeasureItem)
AddHandler menuitem3.MeasureItem, New MeasureItemEventHandler(AddressOf _
MeasureItem)
AddHandler menuItem5.MeasureItem, New MeasureItemEventHandler(AddressOf _
MeasureItem)
AddHandler menuitem6.MeasureItem, New MeasureItemEventHandler(AddressOf _
MeasureItem)
AddHandler menuItem1.DrawItem, New DrawItemEventHandler(AddressOf _
DrawItem)
AddHandler menuItem2.DrawItem, New DrawItemEventHandler(AddressOf _
DrawItem)
AddHandler menuitem3.DrawItem, New DrawItemEventHandler(AddressOf _
DrawItem)
AddHandler menuItem5.DrawItem, New DrawItemEventHandler(AddressOf _
DrawItem)
AddHandler menuitem6.DrawItem, New DrawItemEventHandler(AddressOf _
DrawItem)
Me.Menu = mainMenu1
End Sub
Private Sub Item1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("You clicked the open menu.")
End Sub
' Tell Windows how big to make the menu item.
Private Sub MeasureItem(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.MeasureItemEventArgs)
' Create the font we will use to draw the text.
Dim menu_font As New Font( _
FONT_NAME, FONT_SIZE, FONT_STYLE)
' See how big the text will be.
Dim text_size As SizeF = _
e.Graphics.MeasureString(MENU_CAPTION, menu_font)
' Set the necessary size.
e.ItemHeight = text_size.Height
e.ItemWidth = text_size.Width
End Sub
' Draw the menu item.
Private Sub DrawItem(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.DrawItemEventArgs)
' Create the font we will use to draw the text.
Dim menu_font As New Font( _
FONT_NAME, FONT_SIZE, FONT_STYLE)
' See if the mouse is over the menu item.
If e.State And DrawItemState.Selected Then
' The mouse is over the item.
' Draw a shaded background.
e.Graphics.FillRectangle( _
System.Drawing.Brushes.Tan, _
e.Bounds.X, e.Bounds.Y, _
e.Bounds.Width, e.Bounds.Height)
' Draw the text.
e.Graphics.DrawString(MENU_CAPTION, menu_font, _
System.Drawing.Brushes.Black, _
e.Bounds.X, e.Bounds.Y)
Else
' The mouse is not over the item.
' Erase the background.
e.Graphics.FillRectangle( _
System.Drawing.Brushes.Beige, _
e.Bounds.X, e.Bounds.Y, _
e.Bounds.Width, e.Bounds.Height)
' Draw the text.
e.Graphics.DrawString(MENU_CAPTION, menu_font, _
System.Drawing.Brushes.Black, _
e.Bounds.X, e.Bounds.Y)
End If
End Sub |