Posts Windows Forms + Vista
Post
Cancel

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 disect the event order or find a better event to hook to get the exact behavior down.  For now, here's the code:

<FONT color=#0000ff>Private Sub</FONT> Form1_KeyDown(<FONT color=#0000ff>Byval</FONT> sender <FONT color=#0000ff>As Object</FONT>, <FONT color=#0000ff>Byval</FONT> e <FONT color=#0000ff>As </FONT>KeyEventArgs) <FONT color=#0000ff>Handles</FONT> Me.KeyDown
 <FONT color=#0000ff> If</FONT> e.KeyCode = Keys.Menu <FONT color=#0000ff>AndAlso Not</FONT> MenuStrip1.Visible<FONT color=#0000ff> Then
</FONT>    MenuStrip1.Show()
  <FONT color=#0000ff>End If
End Sub</FONT>

<FONT color=#0000ff>Private Sub </FONT>MenuStrip1_MenuDeactivate(<FONT color=#0000ff>Byval</FONT> sender <FONT color=#0000ff>As Object</FONT>, <FONT color=#0000ff>Byval</FONT> e <FONT color=#0000ff>As</FONT> EventArgs) <FONT color=#0000ff>Handles </FONT>MenuStrip1.MenuDeactivate
  MenuStrip1.Hide()
<FONT color=#0000ff>End Sub</FONT>

<FONT color=#000000>Note: This assumes that MenuStrip1 is set to Visible=False at startup.</FONT>

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.