case WM_CONTEXTMENU:
{
m_hMenu = CreatePopupMenu();
g_BitMap = (HBITMAP)LoadImage(NULL, L"1.bmp", IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
InsertMenu(m_hMenu, 1, MF_BYPOSITION | MF_POPUP, NULL, L"Windows");
MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
mii.fMask = MIIM_BITMAP;
mii.hbmpItem = g_BitMap;
SetMenuItemInfo(m_hMenu, 0, true, &mii);
TrackPopupMenu(m_hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_HORPOSANIMATION, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, hWnd, NULL);
}
break;
注意在LoadImage中添加 LR_CREATEDIBSECTION ,这是实现背景透明的关键