|
|
|
|
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.
Subject |
Author |
Date |
|
JAVIER SUAREZ
|
Feb 27, 2006 - 2:33 PM
|
If I am using a CExtButton with the attached m_menu as the context menu, is it possible to get notification when the different menu items are highlighted as the mouse moves over the different menu items?
I need to update some information (other than tool/status tip) based on what item the mouse is over in the context menu. but i cant seem to find anyway that prof-uis notifies any window on this.
thanks!
|
|
Technical Support
|
Feb 28, 2006 - 3:58 AM
|
Both menu items and toolbar buttons provides a notification about a change in the hovered/selected state. This notification is handled in the HelpNotes sample which demonstrates a custom tooltip based on an OLE-enabled rich editor window. You need to handle the CExtPopupMenuWnd::g_nMsgItemCoveringNotification registered windows message in the button’s parent window: afx_msg LRESULT OnItemCoveringNotification( WPARAM wParam, LPARAM lParam );
ON_REGISTERED_MESSAGE( CExtPopupMenuWnd::g_nMsgItemCoveringNotification, OnItemCoveringNotification )
LRESULT CMainFrame::OnItemCoveringNotification( WPARAM wParam, LPARAM lParam )
{
lParam;
CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON * pICN =
CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::FromWPARAM( wParam );
ASSERT( pICN != NULL );
if( pICN->m_eICN == CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::__EICN_DELAY
|| pICN->m_eICN == CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::__EICN_CANCEL
)
{
pICN->m_bSuspendTips = false; // DO NOT CANCEL DEFAULT TIP WINDOWS IF NOT NEEDED
// IF DELAYED ACTIVATION OF POPUP MENU OR CANCELED SELECTION
// WE GUESS, THESE CASES ARE NOT INTERESTING
return 0;
}
// HOVER/SELECTION CHANGED, THAT IS WHAT WE NEED
ASSERT( pICN->m_eICN == CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::__EICN_SET );
pICN->m_bSuspendTips = true; // CANCEL DEFAULT TIP WINDOWS IN THIS CASE
UINT nCmdID = 0;
CRect rcItem( 0, 0, 0, 0 );
if( pICN->m_pPopup != NULL )
{
// IF NOTIFICATION FROM MENU ITEM
ASSERT( pICN->m_pTBB == NULL );
ASSERT_VALID( pICN->m_pPopup );
CExtPopupMenuWnd::MENUITEMDATA & _mii =
pICN->m_pPopup->ItemGetInfo( pICN->m_nPopupItemIndex );
if( _mii.IsSeparator() || _mii.IsPopup() )
return 0; // NOT AN INTERESTING CASES
nCmdID = _mii.GetCmdID(); // GET THE COMMAND IDENTIFIER IF NEEDED
pICN->m_pPopup->_GetItemRect( pICN->m_nPopupItemIndex, rcItem );
pICN->m_pPopup->ClientToScreen( &rcItem ); // GET THE ITEM RECTANGLE IF NEEDED
} // if( pICN->m_pPopup != NULL )
else
{
// IF NOTIFICATION FROM TOOLBAR BUTTON
ASSERT_VALID( pICN->m_pTBB );
ASSERT_VALID( pICN->m_pTBB->GetBar() );
if( pICN->m_pTBB->IsAbleToTrackMenu() || pICN->m_pTBB->IsSeparator() )
return 0; // NOT AN INTERESTING CASES
nCmdID = pICN->m_pTBB->GetCmdID( false ); // GET THE COMMAND IDENTIFIER IF NEEDED
rcItem = pICN->m_pTBB->Rect(); // GET THE ITEM RECTANGLE IF NEEDED
pICN->m_pTBB->GetBar()->ClientToScreen( &rcItem );
} // else from if( pICN->m_pPopup != NULL )
// NOW WE HAVE nCmdID AND rcItem IN SCREEN COORDINATES
. . .
return 0;
}
|
|