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/
|