// Add to WndProc
case WM_CONTEXTMENU:
if (lParam != -1 &&
SendMessage(hwnd, WM_NCHITTEST,
0, lParam) == HTSYSMENU) {
HMENU hmenu = CreatePopupMenu();
if (hmenu) {
AppendMenu(hmenu, MF_STRING, 1,
TEXT("Custom menu"));
TrackPopupMenu(hmenu, TPM_LEFTALIGN | TPM_TOPALIGN |
TPM_RIGHTBUTTON,
GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam), 0, hwnd, NULL);
DestroyMenu(hmenu);
}
return 0;
}
break;