Print Page | Close Window

Context Menu images with CXTPCommandBars problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=11771
Printed Date: 21 May 2024 at 9:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Context Menu images with CXTPCommandBars problem
Posted By: KJM-18
Subject: Context Menu images with CXTPCommandBars problem
Date 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



Replies:
Posted By: Oleg
Date 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


Posted By: KJM-18
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net