Here's what I'm trying, but the menu is displayed well outside my application border.
Expand|Select|Wrap|Line Numbers
- int index = SendMessage(hndLV, LVM_GETNEXTITEM, -1, (LPARAM)LVNI_SELECTED);
- if(index != -1) {
- ZeroMemory(&cRect, sizeof(RECT));
- cRect.left = LVIR_BOUNDS;
- SendMessage(hndLV, LVM_GETITEMRECT, (WPARAM)index, (LPARAM)&cRect);
- // create menu bits
- SetForegroundWindow(hwnd);
- TrackPopupMenu(hMenu, TPM_VCENTERALIGN, cRect.right / 2, cRect.bottom / 2, 0, hwnd, NULL);
- // bits of code
- }
The index and item rect *appear* to be right when their values were printed out; however, the placement of the menu is way off. It seems more relative to the screen than the application.
How would I accomplish getting the menu within the bounds of the control?