A while ago I got this tree view working just fine, but now I want to add a popup menu to it, and there's a problem. At first, I though handling the WM_RBUTTONDOWN message would work, but the tree view, not the parent window, receives mouse input, so I don't ever receive this message.
Then I thought, oh yeah I'll handle the NM_RCLICK notification, which works fine except I also need to somehow position the popup menu right next to the mouse, and NM_RCLICK apparently doesn't include the cursor position. So I've got:
Code:
case WM_NOTIFY: //handle treeview messages
{
if(wParam==ID_BROWSE_TREE)
{
LPNMHDR nm = (LPNMHDR)lParam;
switch (nm->code)
{
case NM_RCLICK:
{
static HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU2));
if (!hMenu)
{
MessageBox(NULL,"Unable to load popup menu!","Error",MB_OK);
return;
}
TrackPopupMenuEx(GetSubMenu(hMenu,0),TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON,0,0,hTree,NULL); //how do I get these two args?
}
break;
Any ideas on how I should/can do popup menus for a tree view?