Post

Windows Forms + Vista

Now that I’m running Vista (Beta 2), I’m obviously doing development in that environment as well. A couple of things that I’ve noticed (and, honestly, haven’t dug too deeply just yet… so these are initial impressions) is the following:

  1. To get the cool “glowing” active command button effect, you need to set the FlatStyle of the button to System.

  2. I’m working inside of XboxFriends tonight and decided to mimic the menu effect of Vista type applications; meaning they are hidden until you press the Alt key. Upon selecting an item or pressing Esc, Alt, or moving focus away from the menu the menu becomes hidden again. The following code is my initial pass at this and works pretty well except for the Alt key being pressed again. I’ll have to dig into this further and dissect the event order or find a better event to hook to get the exact behavior down. For now, here’s the code:

1
2
3
4
5
6
7
8
9
Private Sub Form1_KeyDown(Byval sender As Object, Byval e As KeyEventArgs) Handles Me.KeyDown
  If e.KeyCode = Keys.Menu AndAlso Not MenuStrip1.Visible Then
    MenuStrip1.Show()
  End If
End Sub

Private Sub MenuStrip1_MenuDeactivate(Byval sender As Object, Byval e As EventArgs) Handles MenuStrip1.MenuDeactivate
  MenuStrip1.Hide()
End Sub

Note: This assumes that MenuStrip1 is set to Visible=False at startup.

Disclaimer: This entry is mainly to remind me to dig further into this; however, I figured it was interesting enough to share and possibly get others involved in the process. ;-)

This post is licensed under CC BY 4.0 by the author.