Here is some C++ code pieces from my program, which will popup
a menu while user click the tray icon of the program.
Hope it will also help in Delphi Programming.
POINT pt;
CMenu menu;
CMenu *pPopupMenu;
// Popup Menu
::GetCursorPos((LPPOINT)&pt);
if (menu.LoadMenu(IDR_MENU_COLLECTION)) {
pPopupMenu = menu.GetSubMenu(0);
if (pPopupMenu!=NULL) {
SetForegroundWindow(); // This is learned from Books online,
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, pt.x, pt.y, this, NULL);
PostMessage(WM_USER, 0, 0); // d.o. "This is the problem of design" -- Microsoft PSS said
}
menu.DestroyMenu();
}