'Code by 魑 魑 魍魉
'Mailto: DemonStudio@hotmail.com
Private Declare Function SetMenu Lib "User32" _
(Byval Hwnd As Long, _
BYVAL HMENU As Long)
As long
Private Declare Function GetMenu Lib "User32" _
(Byval HWND As Long) _
As long
Private Declare Function DrawMenuBar lib "user32" _
(Byval HWND As Long) _
As long
Private Declare Function DestroyMenu Lib "User32" _
(Byval HMenu as long)
As long
Private Declare Function GetCursorpos LIB "User32" _
(LPPOINT AS POINTAPI)
As long
Private Declare Function WindowFromPoint Lib "User32" _
(Byval Xpoint As Long, _
BYVAL YPOINT AS Long)
As long
Private Type PointApi
X as long
Y as long
End Type
DIM HMENU, MHWND As Long
DIM CUR As PointApi
Private Sub Form_MouseUp (Button As Integer, Shift As Integer, x as single, y as single)
GetCursorpos Cur
MHWND = WINDOWFROMPOINT (Cur.x, Cur.y)
Me.caption = MHWND
IF MHWND <> me.hwnd kilnu = getMenu (MHWND)
IF HMENU <> 0 THEN SEMENU ME.HWND, HMENU
DrawmenUBar me.hwnd
End Sub
Private Sub Form_Unload (Cancel AS Integer)
DestroyMenu Hmenu
End Sub
The effect is as follows: