|
|
|
|
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 |
|
Adrian M
|
Mar 1, 2005 - 7:10 PM
|
I have these lines of code: CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd; VERIFY( pPopup -> ItemInsert( (UINT)CExtPopupMenuWnd::TYPE_POPUP, -1, _T( "test" ), 0, m_hWnd ) ); VERIFY( pPopup->TrackPopupMenu( 0, point.x, point.y ) );
This code is called on a right click on a tree control, and the m_hWnd is the tree control window handle.
I get an assert in the file extpopupmenuwnd.cpp at line 12153: ASSERT( m_hWndCmdReceiver != NULL ); If I load a menu resource it works. Any idea why this is happening? Thanks, Adrian
|
|
Technical Support
|
Mar 2, 2005 - 1:49 AM
|
Before inserting items into a pop-up menu, don’t forget to create it first:CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
pPopup->CreatePopupMenu( m_hWnd );
VERIFY( pPopup->ItemInsert(
(UINT)CExtPopupMenuWnd::TYPE_POPUP,
-1,
_T( "test" ),
0,
m_hWnd
)
);
ScreenToClient( &point );
VERIFY( pPopup->TrackPopupMenu( 0, point.x, point.y ) );
|
|
Adrian M
|
Mar 2, 2005 - 4:05 AM
|
This works. Thanks for your reply! As a side note, I based my code on the help topic "How to use popup menus in your application", which is missing the information that the method CreatePopupMenu must be called. Adrian
|
|
Technical Support
|
Mar 2, 2005 - 6:31 AM
|
The CExtPopupMenuWnd::CreatePopupMenu method works similar to CMenu::CreatePopupMenu . When you dynamically create an MFC pop-up menu, you also need to call CreatePopupMenu() before adding any item to the menu.
|
|