Hi, I’m new to C++ and to using Xtreme ToolkitPro (ver. 11.2.2). I’ve been trying to display bitmap images before the text of a dynamically created context menu popup. I can get it to work using just the standard Menu class, but can not get the images to display when using the CXTPCommandBars::TrackPopupMenu code (see below). I’ve looked at all the samples but none of them use dynamically created menus where the images are assigned at run-time. I must be missing a step or something and would appreciate any suggestions.
//// TEST CODE FOLLOWS //
void CTreeFormView::PopupEmptyPosition(CSingleOrg* DestSingleOrg, CPoint point, CString SourcePosnNbr, CString SourcePosnID, CString SourceSN, CString SourceMemId, CString SourcePosnOrgId, CString SourcePosnUIC, CString SourceFutureInd) {
CMenu popup; bool ShowPopup = false; CBitmap FirstBitmap, SecondBitmap; int i,x,y; CString string,prompt,title; CRect rect; // 2 different bitmap images FirstBitmap.LoadBitmap(IDB_BITMAP_1); SecondBitmap.LoadBitmap(IDB_BITMAP_2);
popup.CreatePopupMenu();
// Simple loop that creates 4 menu items // with the first 2 having the IDB_BITMAP_1 image // and the last 2 displaying the IDB_BITMAP_2 image before the text for (i = 0; i<4; i++) { if(i < 2){ prompt = _T("Empty"); popup.AppendMenu(MF_ENABLED|MF_STRING, ID_POPUP_MOVE_MEMBER1+i+1, prompt); popup.SetMenuItemBitmaps(i+1, MF_BYPOSITION, &FirstBitmap, &FirstBitmap); } else { prompt = _T("Full"); popup.AppendMenu(MF_ENABLED|MF_STRING, ID_POPUP_MOVE_MEMBER1+i+1, prompt); popup.SetMenuItemBitmaps(i+1, MF_BYPOSITION, &SecondBitmap, &SecondBitmap); } }
GetWindowRect(&rect); x = rect.left+point.x; y = rect.top+point.y;
// This is the original code that displays the images // before the text, but it does not have the look // of the CXTPCommandBars and we want to update it // popup.TrackPopupMenu (TPM_NONOTIFY| TPM_LEFTALIGN |TPM_RETURNCMD, x, y, this, NULL); // This is the new code that shows the context menu popup, // but does not show the bitmap images before the text CXTPCommandBars::TrackPopupMenu(&popup, TPM_NONOTIFY| TPM_LEFTALIGN |TPM_RETURNCMD, x, y, this, NULL);
popup.DestroyMenu();
::DeleteObject(FirstBitmap); ::DeleteObject(SecondBitmap); }
------------- Smile and the whole world smiles with you - Chaplin
|