Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - how to popup menu when right click
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to popup menu when right click

 Post Reply Post Reply
Author
Message
Raj.krishnan View Drop Down
Groupie
Groupie
Avatar

Joined: 16 January 2006
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Raj.krishnan Quote  Post ReplyReply Direct Link To This Post Topic: how to popup menu when right click
    Posted: 29 March 2006 at 5:34am

Hello All ,

     I need a help . How to popup a menu when right click on a menu item of existing menu like IE browser Favorites menu .

    Attached a zip file that shows IE browser right click menu on Favorites menu . 

    When we click IE browser Favorites menu it is poping up a menu in that we can delete a favorite item by right clicking on that item and select delete i need the same thing . In my application i will popup a menu on click of a button i need to popup a menu whenever user right clicks on the particular menu item .2006-03-29_053238_popup_menu.zip . Please help on this critical issue

 

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: 29 March 2006 at 7:42am

Hello,

here code (Works only in 9.81)

ON_MESSAGE(WM_XTP_CONTROLRBUTTONUP, OnControlRButtonUp)

 

LRESULT CMainFrame::OnControlRButtonUp(WPARAM, LPARAM lParam)
{
 CXTPControl* pControl = (CXTPControl*)lParam;
 if (pControl->GetID() == ID_FAVORITE_LINK)
 {
  CControlFavoriteLink* pLink = DYNAMIC_DOWNCAST(CControlFavoriteLink, pControl);
  if (!pLink)
   return FALSE;

  CMenu menu;
  menu.LoadMenu(IDR_MENU_FAVORITE_LINK);
  
  CPoint pt;
  GetCursorPos(&pt);

  UINT nReturn = CXTPCommandBars::TrackPopupMenu(menu.GetSubMenu(0), TPM_NONOTIFY|TPM_RECURSE|TPM_RETURNCMD, pt.x, pt.y, this);

  switch (nReturn)
  {
   case ID_LINK_OPEN:
    XTPMouseManager()->SendTrackLost( );
    pControl->OnExecute();
    break;

   case ID_LINK_PROPERTIES:
    XTPMouseManager()->SendTrackLost( );
    ShellExecute(m_hWnd, _T("properties"), pLink->m_strFileName, NULL, NULL, SW_SHOWNORMAL);
    
    break;
  }
  return TRUE;

 }

 return FALSE;
}

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Raj.krishnan View Drop Down
Groupie
Groupie
Avatar

Joined: 16 January 2006
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Raj.krishnan Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2006 at 12:30pm

Hello Oleg

    iam having delete popup menu over another menu if i click delete it should reload the another menu without that delete item but it is crashing when iam trying to delete and set the refresh menu to the control. Help me to sort out this issue

code as follows:

LRESULT CToolDlg::OnControlRButtonUp( WPARAM wParam , LPARAM lParam )
{
 CXTPControl* pControl = (CXTPControl*)lParam;
 CList<CHistoryList , CHistoryList&>  cBuddyList;
 CHistoryList        cList;


 // -- modified by Rajkumar Apr 25 2006
 // -- previously it was logical && so the delete menu hasnt come changed it to logical ||

 if ( pControl->GetID() == ID_BUDDYMENUITEM || pControl->GetID() <= ID_BUDDYMENUITEM + 19 )
 {
  CMenu menu , cMenu;
  cMenu.LoadMenu(IDR_BUDDYBTN_MENU);
  
  CPoint pt;
  GetCursorPos(&pt);
  
  UINT nReturn = CXTPCommandBars::TrackPopupMenu(cMenu.GetSubMenu(1), TPM_NONOTIFY|TPM_RECURSE|TPM_RETURNCMD, pt.x, pt.y, this);
  
  switch (nReturn)
  {
  case ID_BUDDYMENU_DELETE:
   {
    if( egAGProInterface()->GetDatafromHistoryDB( eBuddyList ) )
    {
     egAGProInterface()->GetList FromDB( eBuddyList , cBuddyList );
      
     if( cBuddyList.GetCount() > 0 )
     {
      int nIndex = pControl->GetID() - ID_BUDDYMENUITEM;
      
      POSITION pos = cBuddyList.FindIndex( nIndex );
      
      if( pos )
      {
       cBuddyList.RemoveA t( pos );
       
       egAGProInterface() ->SetListToDB( eBuddyList , cBuddyList , false );
       
       egAGProInterface() ->SetDataInHistoryDB( eBuddyList );

       AddNAppendRecordsT oBuddy(true);   -> from here calling another function where i wil be setting the menu to the control
       break;
      }
     }
    }
   }
  default:
   break;
  }
  return TRUE;
 }
 return FALSE;
}

 

int CToolDlg::AddNAppendRecordsToBuddy( bool bStartup )
{
 CList<CHistoryList , CHistoryList&>  cBuddyList;
 CHistoryList        cList;
 CMenu        & nbsp;cMenu , *pSubMenu = NULL;
 POSITION       &nbs p;pos = NULL;
 int        &nb sp; nMenuID;

 
 if( bStartup )
 {
  egAGProInterface()->GetDatafromHistoryDB( eBuddyList );
 }
 else
 { //Rajkumar Apr 18 2006
  egAGProInterface()->GetDatafromHistoryDB( eBuddyList );
  egAGProInterface()->AddSelectedRecordsToBuddy List( );
 }

 egAGProInterface()->GetListFromDB( eBuddyList , cBuddyList );
 
 if( !cMenu.LoadMenu( IDR_BUDDYBTN_MENU ) ) { return FALSE;}
 
 pSubMenu = cMenu.GetSubMenu( 0 );

 pSubMenu->AppendMenu( MF_SEPARATOR );
 
 nMenuID = ID_BUDDYMENUITEM;

 pos = cBuddyList.GetHeadPosition( );

 int ncount = cBuddyList.GetCount();

 while( pos && pSubMenu )
 {
  cList = (CHistoryList)cBuddyList.GetAt( pos );
  
  CString csText = cList.stBuddy.stContact.csContactName + HIPHEN + cList.stBuddy.stContact.csCompName;
  
  // -- implemented by Rajkumar Apr 27 2006 to remove the hiphen from both sides
  csText.TrimRight(HIPHEN);
  csText.TrimLeft(HIPHEN);

  if (csText.IsEmpty()) { return FALSE;} // -- implemented May 5 2006 to check the
               // -- data before append to menu
 
  pSubMenu->AppendMenu( MF_STRING , nMenuID++ , csText );

  cBuddyList.GetNext( pos );
 }
 
 CXTPControlPopup *pCtrl = (CXTPControlPopup*)m_wndBuddyBtnToolbar.GetControls()->Fi ndControl( ID_LEFTBUDDYLISTBTN );
 
 if( pCtrl && pSubMenu )
 {
  pCtrl->SetCommandBar( pSubMenu );
 }
 
 return TRUE;
}


 

 

 

 

Raj
Software Engineer
eGrabber Inc
http://vcfreax.blogspot.com/
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: 05 May 2006 at 4:15pm

Raj, you scare me.

You show me 130 lines of code and asking to find error. 

I must debug it. Create new issue in issuetrack and attach your project or small application  and I will show where you have error.

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Raj.krishnan View Drop Down
Groupie
Groupie
Avatar

Joined: 16 January 2006
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Raj.krishnan Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2006 at 8:34am

Hello Oleg,

   Thanks for the Reply . I will explain what iam doing in those functions .

  Second function is the one can use for adding items dynamically so that when ever i click the it should so the items that are set to the menu .

  If the user doesnt want the item in the menu he can right click on that item so that it will popup another menu called delete if i click it is going to the OnControlRButtonUp function then i will be calling the second function to set all the items other than the deleted item in the database and the remaining items i am loading it in the menu and it to popupbuttoncontrol Setcommandbar function . I had checked whether if there are any probs with set and get in database but no probs in that. So when i debug after the setcommandbar it is calling some functions XT and at it is going to CXTPCommandBar::IsSelected or something and it is crashing there it seems . Can you explain me how handle this situation.

 

 

 

Raj
Software Engineer
eGrabber Inc
http://vcfreax.blogspot.com/
Back to Top
Raj.krishnan View Drop Down
Groupie
Groupie
Avatar

Joined: 16 January 2006
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Raj.krishnan Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 12:06pm

Hello Oleg,

    I will be sending you the sample source code attched with this reply 2006-05-19_114836_XTToolBarNDlg.zip . Can you help me out to solve this issue .

If you execute the exe it will show a toolbar on the dialog if you click the first popup button it will popup a menu and then if you right click the menu items after the Separtor it will popup a delete menu . If you click on that that item has to deleted . It is deleteing for 1 or 2 items if I do it for all the items it is crashing the same thing what i hgad explained before. Can you help me to solve this issue. 

 

Raj
Software Engineer
eGrabber Inc
http://vcfreax.blogspot.com/
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: 19 May 2006 at 12:38pm
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Raj.krishnan View Drop Down
Groupie
Groupie
Avatar

Joined: 16 January 2006
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Raj.krishnan Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 4:40pm

Hello Oleg,

    We are not using

CXTPCommandBars* pCommandBars = GetCommandBars();
 pCommandBars->GetCommandBarsOptions()->bShowExpa ndButtonAlways = FALSE;

 m_pToolBar = NULL;
// CXTPToolBar* pToolBar =
 m_pToolBar = pCommandBars->Add(_T("Standard"), xtpBarTop);

this code to create the toolbar instead of this thing we are using

CXTPToolBar   m_wndBuddyBtnToolbar;

m_wndBuddyBtnToolbar.CreateToolBar(WS_VISIBLE|WS_CHILD|CBRS_ TOOLTIPS, this, AFX_IDW_TOOLBAR + 5 ); 
 m_wndBuddyBtnToolbar.LoadToolBar(IDR_TOOLBAR_BUDDYBTN) ;

Here we cant get the CXTPCommandBars how should i do if iam using this way. Can you help me out its really important.

 

 

Raj
Software Engineer
eGrabber Inc
http://vcfreax.blogspot.com/
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: 19 May 2006 at 4:52pm

You just need create simple CommandBars object

m_pCommandBars = (CXTPCommandBars*)CXTPCommandBars::CreateObject()

assign it

m_wndBuddyBtnToolbar.SetCommandBars(m_pCommandBars);

 

and destory in destuctor

m_pCommandBars->InternalRelease();

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.437 seconds.