does anybody know how can i show popupmenu when specifed item is right-clicked in my listview???
what i want to do is to show a popup-menu using TrackPopupMenu when i'll click on an item that has specifed name, and if that names doesnt match the menu will not pupup.

thanx for any reply

Posted on 2002-01-30 15:45:40 by NEMO
You have to subclass the listview and handle the WM_CONTEXTMENU message. You can also send to the listview a LVM_HITTEST message in order to get the clicked element and show different context menus.
Posted on 2002-01-30 16:15:01 by LuHa
thanx man!!!:grin:
now it works!!

Posted on 2002-01-31 09:33:48 by NEMO
Since you have already subclassed your listview procedure, maybe it is nice to show a message like "Right click to show menu" if the listview is empty, like outlook express does. It is simple: handle also WM_PAINT message, call the default listview procedure, check for the number of items and if it is 0 get the listview rect, resize it in order to avoid painting over the header control and finally draw your text.
Posted on 2002-01-31 12:06:04 by LuHa

I'm doing the same thing!! But instead of subclassing I just used the WM_NOTIFY message and the use of the NMHDR structure...

It works and all but trying to get my edit menu to popup in the place the user clicked is giving me tons of trouble... I can't seem to extract the proper X, Y values from the lParam :eek:

Anyways laterz,
Posted on 2002-01-31 22:39:38 by JamesE
I used subclassing method because I also did some other stuff, and when NEMO asked his question subclassing was the first thing I thought. I have tried also your way, using WM_NOTIFY, but my popup menu now react only to left clicks. How do you handle the right clicking? About your problem showing context menu in the right place, are you using the ClientToScreen API to map a listview point to screen one before calling TrackPopupMenu?

Hem... I didn't see NM_RCLICK, I used NM_CLICK. Now it works perfectly :grin:.
Posted on 2002-02-01 08:06:07 by LuHa