Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Context Menu images with CXTPCommandBars problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Context Menu images with CXTPCommandBars problem

 Post Reply Post Reply
Author
Message
KJM-18 View Drop Down
Newbie
Newbie
Avatar

Joined: 08 August 2008
Location: Canada
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote KJM-18 Quote  Post ReplyReply Direct Link To This Post Topic: Context Menu images with CXTPCommandBars problem
    Posted: 08 August 2008 at 5:24pm

 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 11 August 2008 at 2:34am
Hello,
 
Instead of SetMenuItemBitmaps  add Images to ImageManager. See our CommandBarIcons .
 
XTPImageManager()->SetIcons(...);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
KJM-18 View Drop Down
Newbie
Newbie
Avatar

Joined: 08 August 2008
Location: Canada
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote KJM-18 Quote  Post ReplyReply Direct Link To This Post Posted: 11 August 2008 at 11:24am

Thanks for your response.

 

I looked at that sample code however I still could not get my code to work.  The SetIcons() function takes a toolbar resource ID and an image list, neither of which my example has. I need to assign different images to menu items at runtime and the images are bitmaps stored in the resource file.

 

I'm new to working in C++ and would really appreciate it if you could modify the sample code I provided or show me a longer code snippet.

 

Many thanks in advance.

Smile and the whole world smiles with you - Chaplin
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.