Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 384
Viewed: 2848
Added: Aug 19, 2002
Snippet uploaded by: snippet
Written By: Megatron
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Purpose: Create a Popup Menu
Version: VB5+

Highlight all by clicking in box
Private Declare Function AppendMenu Lib "user32" _ 
Alias "AppendMenuA" (ByVal hMenu As Long, ByVal _
wFlags As Long, ByVal wIDNewItem As Long, ByVal _
lpNewItem As Any) As Long

Private Declare Function CreatePopupMenu Lib "user32" _
() 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 TrackPopupMenu Lib "user32" _
(ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As _
Long, ByVal y As Long, ByVal nReserved As Long, ByVal _
hwnd As Long, ByVal lprc As Any) As Long

Const MF_STRING = &H0&

Private Type POINTAPI
x As Long
y As Long
End Type

Private hMenu As Long

Highlight All
Private Sub Form_Load() 
hMenu = CreatePopupMenu()
AppendMenu hMenu, MF_STRING, 0, "New Menu"
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call GetCursorPos(PT)
If Button = 2 Then
TrackPopupMenu hMenu, 0, PT.x, PT.y, 0, hwnd, 0&
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
DestroyMenu hMenu
End Sub

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions