|
|
Title | Display a menu when the mouse is near the top of the form |
Keywords | menu, hide, show, top |
Categories | Controls |
|
|
In the Form's MouseMove event handler, see if the mouse is near the top of the form. Use the SetMenu API function to show or hide the menu as appropriate.
|
|
Private Sub Form_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Y < 120 Then SwitchMenu
End Sub
Private Sub SwitchMenu()
If hMenu = 0 Then
HideMenu
Else
ShowMenu
End If
End Sub
Private Sub HideMenu()
If hMenu <> 0 Then Exit Sub
' Get the menu handle and hide the menu.
hMenu = GetMenu(hwnd)
SetMenu hwnd, 0
End Sub
Private Sub ShowMenu()
If hMenu = 0 Then Exit Sub
' Restore the old menu.
SetMenu hwnd, hMenu
hMenu = 0
End Sub
|
|
Note that a program doesn't receieve MouseMove events if the mouse moves off the form. In particular, if it moves off the top of the form, you might want to hide the menu. This program doesn't worry about it but you could use a Timer and the GetCursorPos API function to handle this.
|
|
|
|
|
|