Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CExtPopupMenuWnd width Collapse All
Subject Author Date
Krustys Donuts Jan 25, 2010 - 11:41 AM

Dear Support,


I have a CExtPopupMenuWnd that consists of a menu caption and 0-5 menu items. The problem arises when the horizontal extent of the menu caption exceeds the extent of the widest menu item. In this case, the menu caption is truncated. Is there some way to adjust the width of the CExtPopupMenuWnd object such that the entire menu caption is always visible?


Gil

Krustys Donuts Feb 11, 2010 - 12:14 PM

Support,


Will this change be encorporated in future versions, or will I need to make this change every time I upgrade to the latest version of Prof-uis.


Thanks,


Gil

Technical Support Feb 13, 2010 - 11:28 AM

Yes, of course this improvement is part of nearest and all the future Prof-UIS versions.

Krustys Donuts Jan 25, 2010 - 3:02 PM


Here is the code. I will send the image in a separate email.


 


In initialize routine:



 


//!Create the context menu shown when user right-clicks on a teachpoint.

HMENU oMenu;


 


m_contextMenu.Attach(oMenu);


if((oMenu = LoadMenu(GlobalInstance,MAKEINTRESOURCE(IDR_menuTpContextMenu)))!=NULL)

 


Used when left click is detected:



void


{


 


VR3dRobot::ShowContextMenu(const CPoint& point, int tpId)CExtPopupMenuWnd* pPopup =


new CExtPopupMenuWnd;this->m_hWnd, &m_contextMenu, true, true, true);//!Get the current user selections for red and blue TPs.

string strTpRed = m_pDiags->GetSelTpRed();


string strTpBlue = m_pDiags->GetSelTpBlue();


 


//!Get the TP that the user clicked on. We store these two TPs

 


//!in member variables because the command handlers for this

 


//!context menu need this information.

VRTeachpointList& tpList = m_pDiags->GetTeachpointList();


m_tp1 = tpList.GetTeachpoint(strTpRed);


m_tp2 = tpList.GetTeachpoint(strTpBlue);


 


//!If the user is clicking on the blue TP.

VRTeachpoint tp = tpList.GetTeachpoint(tpId);


 


{


 


if (tp.GetName() == strTpBlue)//This is a bit of a kludge. Because the user is clicking

 


//on blue teachpoint, we want all commands to execute as if

 


//the blue teachpoint is the red teachpoint.

strTpRed = m_pDiags->GetSelTpBlue();


strTpBlue = m_pDiags->GetSelTpRed();


m_tp1 = tpList.GetTeachpoint(m_pDiags->GetSelTpBlue());


m_tp2 = tpList.GetTeachpoint(m_pDiags->GetSelTpRed());


}


 


//!Use the name of the red TP for the header of this context menu.

pPopup->MenuCaptionTextSet(strTpRed.c_str());


 


//!Put the name of the blue TP into the ’Transfer from’ and ’Transfer to’ commands.

string str = (boost::format(m_st.GetString( IDS_strTransferTo)) % strTpBlue).str();


pPopup->ItemSetPopupText(pPopup->ItemFindPosForCmdID(ID_TransferTp1toTp2), str.c_str());


str = (boost::format(m_st.GetString( IDS_strTransferFrom)) % strTpBlue).str();


pPopup->ItemSetPopupText(pPopup->ItemFindPosForCmdID(ID_TransferTp2toTp1), str.c_str());


 


//!If labware not selected, or the robot is busy, or the arm is disabled, or

 


//!all the AOs for this TP have errors.

 


m_oldStatus.GetRobotBusy() || (!m_oldStatus.GetArmPowerEnabled()) ||


(m_tp1.GetNumApproOrientations() <= m_tp1.GetNumAoErrors()))


{


 


if ((!m_pDiags->IsLabwareSelected()) ||//!Remove the following choices from the context menu.

pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_MoveToTp));


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_PickFromTp));


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_PlaceAtTp));


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_TransferTp1toTp2));


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_TransferTp2toTp1));


}


 


//!If the blue teachpoint is not defined or is <NoWhere>.

string strNoWhere = m_st.GetString( IDS_strNowhere);


 


(m_tp2.GetNumApproOrientations() <= m_tp2.GetNumAoErrors()))


{


 


if (strTpBlue.empty() || (strTpBlue == _T("")) || (strTpBlue == strNoWhere) ||//!If not already removed, remove the following choices from the context menu.

 


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_TransferTp1toTp2));


 


pPopup->ItemRemove(pPopup->ItemFindPosForCmdID(ID_TransferTp2toTp1));


}


 


if (pPopup->ItemFindPosForCmdID(ID_TransferTp1toTp2) >= 0)if (pPopup->ItemFindPosForCmdID(ID_TransferTp2toTp1) >= 0)//!Show the menu

pPopup->_SyncItems();


pPopup->TrackPopupMenu( TPMX_CENTERALIGN, point.x, point.y);


}



pPopup->UpdateFromMenu(


 

Technical Support Jan 26, 2010 - 1:53 PM

To make the menu caption completely displaying its text, please update the source code for the following method:

CSize CExtPopupMenuWnd::_CalcTrackSize()
{
            ASSERT_VALID( this );

int nMenuShadowSize = OnQueryMenuShadowSize();
CRect rcMB = OnQueryMenuBorderMetrics();
int nXtraSzX = rcMB.left + rcMB.right + nMenuShadowSize;
int nXtraSzY = rcMB.top + rcMB.bottom + nMenuShadowSize;
CSize _size( m_sizeFullItems );
            if( m_bExpandAvailable )
                        _size.cy += _GetSpecBtnHeight(); // expand button
            _size += CSize( nXtraSzX + m_nLeftAreaWidth, nXtraSzY );
            if( _size.cx < (nMenuShadowSize*2 + 10) )
                        _size.cx = nMenuShadowSize*2 + 10;
            if( _size.cy < (nMenuShadowSize*2 + 10) )
                        _size.cy = nMenuShadowSize*2 + 10;

            _size.cy += 1; // +/- 2.28

bool bFoundVisibleItem = false;
            for( int nIndex = 0; nIndex != m_items_all.GetSize(); nIndex++ )
            {
                        MENUITEMDATA & mi = ItemGetInfo( nIndex );
                        if( mi.IsDisplayed() )
                        {
                                    bFoundVisibleItem = true;
                                    break;
                        }
            }
            if( ! bFoundVisibleItem )
                        _size.cy += 1; // + 2.31

#if (!defined __EXT_MFC_NO_RIBBON_BAR)
CExtPopupMenuWnd * pParent = GetParentMenuWnd();
            if(                     pParent != NULL
                        &&        pParent->_IsTopLevelPopup()
                        &&        (pParent->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
                        )
            {
                        CExtRibbonGalleryPopupMenuWnd * pGalleryMenu =
                                    DYNAMIC_DOWNCAST( CExtRibbonGalleryPopupMenuWnd, pParent );
                        if( pGalleryMenu != NULL )
                        {
                                    CSize _sizeAdjust = pGalleryMenu->m_sizeChildControl;
                                    _sizeAdjust.cx -= nMenuShadowSize;
                                    _sizeAdjust.cy -= nMenuShadowSize;
                                    _size.cx = max( _size.cx, _sizeAdjust.cx );
                                    _size.cy = max( _size.cy, _sizeAdjust.cy );
                        }
            }
#endif // (!defined __EXT_MFC_NO_RIBBON_BAR)

CSize _sizeCaption = MenuCaptionMeasure();
INT nCaptionMetric = _sizeCaption.cx + rcMB.left + rcMB.right;
            _size.cx = max( _size.cx, nCaptionMetric ); // + 2.89

            return _size;
}


Technical Support Jan 25, 2010 - 1:48 PM

Could you provide a screen shot and code snippet initializing your popup menu?