Dear FireFly users,
I would like to display a specific menu when the end-user click on the right mousse button over a ListView control.
I think I have to deal with the WM_RBUTTONDOWN; until now this function works pretty well but I don't know how to display the menu ?
'--------------------------------------------------------------------------------
Function PROJECT1_LISTVIEW1_WM_RBUTTONDOWN ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
MouseFlags As Long, _ ' virtual keys that are pressed
xPos As Long, _ ' x-coordinate of cursor
yPos As Long _ ' y-coordinate of cursor
) As Long
' right mouse button was clicked
ZTrace("right mouse button was clicked, how to display a menu ?")
End Function
So I have some questions:
Q1. Can I use the "Menu Editor" from the tools menu to create a popup menu ? until now I have used the "Menu Editor" only to display menus that appear on the top of a FORM.
Q2. If the answer is "Yes", how can I use this popup menu in my FF.
Q3. If the answer if "No", how can I create and use a Popup menu in FF.
Thanks for your help.
I think something like the following will work for you. It displays the same menu wherever you right-click int he control. You would need to do some hit testing in case you want special options in your menu customized to the specific row/col that you are over.
%IDC_POPUPMENU_OPTION1 = %WM_USER + 100
%IDC_POPUPMENU_OPTION2 = %WM_USER + 101
%IDC_POPUPMENU_OPTION3 = %WM_USER + 102
'--------------------------------------------------------------------------------
Function FORM1_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Static hPopupMenu As Dword
Select Case wMsg
Case %WM_CONTEXTMENU
If wParam = HWND_FORM1_LISTVIEW1 Then
If hPopupMenu Then DestroyMenu hPopupMenu
hPopupMenu = CreatePopupMenu()
AppendMenu hPopupMenu, %MF_STRING, %IDC_POPUPMENU_OPTION1, "Option1"
AppendMenu hPopupMenu, %MF_STRING, %IDC_POPUPMENU_OPTION2, "Option2"
AppendMenu hPopupMenu, %MF_SEPARATOR, 0, ""
AppendMenu hPopupMenu, %MF_STRING, %IDC_POPUPMENU_OPTION3, "Option3"
TrackPopupMenu hPopupMenu, %TPM_LEFTALIGN Or %TPM_LEFTBUTTON, _
LoWrd(lParam), HiWrd(lParam), 0, hWndForm, ByVal %Null
End If
End Select
End Function
'--------------------------------------------------------------------------------
Function FORM1_WM_COMMAND ( _
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wNotifyCode As Long, _ ' notification code
wID As Long _ ' item, control, or accelerator identifer
) As Long
Select Case wID
Case %IDC_POPUPMENU_OPTION1
MsgBox "option 1 selected"
Case %IDC_POPUPMENU_OPTION2
MsgBox "option 2 selected"
Case %IDC_POPUPMENU_OPTION3
MsgBox "option 3 selected"
End Select
End Function
Oh and, no, you can't design that popup menu in FF's Menu Editor. Sorry.
Thank you Paul, I'll try this snippet.
Do you think it will be possible to design this sort of popup menu in a future version of FF3 ? ;)
Jean-Pierre
It is on the FF3 Wishlist/Roadmap..... maybe, maybe not. ;)