|
|
|
|
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 |
|
Bacsó Gergely
|
Jan 19, 2007 - 7:01 PM
|
Hi,
I wanted to have a custom control bars popup menu everywhere, so I added the following message handler to CMainFrame (as shown in the FAQ):
LRESULT CMainFrame::OnConstructPopupMenuCB( WPARAM wParam, LPARAM lParam ) { ASSERT_VALID( this ); lParam; CExtControlBar::POPUP_MENU_EVENT_DATA * p_pmed = CExtControlBar::POPUP_MENU_EVENT_DATA::FromWParam( wParam ); ASSERT( p_pmed != NULL ); ASSERT_VALID( p_pmed->m_pPopupMenuWnd ); ASSERT_VALID( p_pmed->m_pWndEventSrc ); ASSERT( p_pmed->m_pWndEventSrc->GetSafeHwnd() != NULL ); ASSERT( ::IsWindow(p_pmed->m_pWndEventSrc->GetSafeHwnd()) ); switch(p_pmed->m_nHelperNotificationType) { case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_DOCKBAR_CTX: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_STATUSBAR_CTX: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NCBTNMENU_BARS: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CTXEXPBTN_BARS: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NCBTNMENU_DYNSTATE: case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MDICLIAREA_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CTXEXPBTN_BARS: /* this case does not work */
if( !p_pmed->m_bPostNotification ) { p_pmed->m_pPopupMenuWnd->LoadMenu(m_hWnd, IDR_TEST_POPUP, true); } return (!0);
default: return 0; } }
Everything worked, except the __PMED_CTXEXPBTN_BARS (for the content expand button’s control bars list). I tested the above function on the samples as well, and it caused a runtime-error there too.
Is my code missing something for the content expand button’s control bars list, or there is a bug?
Thank You for your help in advance, Gergely BacsA?
|
|
Bacsó Gergely
|
Jan 23, 2007 - 12:01 PM
|
Thank You, it works this way. I don’t know what the problem could be, the Prof-UIS samples have the same problem.
Best regards, Gergely Bacsó
|
|
Technical Support
|
Jan 23, 2007 - 12:30 PM
|
We are still learning this dark side of DHTML dialog supported by MFC 8.0. We hope we will find a more universal solution.
|
|
Bacsó Gergely
|
Jan 22, 2007 - 8:13 PM
|
Thank You, the CDHtmlDialog problem is solved, the context menu works now absolutely fine on all title bars, but the content-expand buttons of the toolbars are still throwing errors for me: the CExtPopupMenuWnd::LoadMenu()<code> method fails loading the menu with <code>g_ResourceManager->LoadMenu( menu, nIDResource ) in this case, though I use the same menu loading code for all cases in CMainFrame::OnConstructPopupMenuCB() .
|
|
Technical Support
|
Jan 23, 2007 - 11:13 AM
|
We guess there is some conflict in managing the MFC state in your project. Please add the following property to the CMainFrame class: CMenu m_menu; Then load a menu in the constructor of CMainFrame : VERIFY(
m_menu.LoadMenu(
IDR_TEST_POPUP
)
); Finally, update the source code for the following method: LRESULT CMainFrame::OnConstructPopupMenuCB( WPARAM wParam, LPARAM lParam )
{
ASSERT_VALID( this );
lParam;
CExtControlBar::POPUP_MENU_EVENT_DATA * p_pmed =
CExtControlBar::POPUP_MENU_EVENT_DATA::FromWParam( wParam );
ASSERT( p_pmed != NULL );
ASSERT_VALID( p_pmed->m_pPopupMenuWnd );
ASSERT_VALID( p_pmed->m_pWndEventSrc );
ASSERT( p_pmed->m_pWndEventSrc->GetSafeHwnd() != NULL );
ASSERT( ::IsWindow(p_pmed->m_pWndEventSrc->GetSafeHwnd()) );
switch(p_pmed->m_nHelperNotificationType)
{
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_DOCKBAR_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_STATUSBAR_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NCBTNMENU_BARS:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NCBTNMENU_DYNSTATE:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MDICLIAREA_CTX:
case CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CTXEXPBTN_BARS:
if( ! p_pmed->m_bPostNotification )
{
VERIFY(
p_pmed->m_pPopupMenuWnd->UpdateFromMenu(
m_hWnd,
&m_menu,
true,
false
)
);
}
return (!0);
default:
return 0;
}
}
|
|
Bacsó Gergely
|
Jan 21, 2007 - 7:40 AM
|
Yes, I have called
VERIFY( g_CmdManager->UpdateFromMenu( pApp->m_pszProfileName, IDR_TEST_POPUP ) );
in the CMainFrame::OnCreate() method.
I’ve updated the sample MDI, as I am developing an MDI app - you can download the updated sample project from: http://users.hszk.bme.hu/˜bg198/MDI.zip
Gergely BacsA?
PS: Another bug is that sometimes when I close an MDI child window (derived from CExtNCW<CMDIChildWnd> ) I get a runtime error in DEBUG mode. And the <b>Tile<b> and <b>Cascade<b> menu items don’t work for me.
|
|
Technical Support
|
Jan 22, 2007 - 12:26 PM
|
Thank you for reporting the bug. To fix it, please replace the return PreTranslateInput(pMsg); code with the return FALSE; code in the last line of the CExtControlBar::PreTranslateMessage() method and add the CExtDockBar::PreTranslateMessage() method which simply performs return FALSE;. The CExtNCW template class is not fully compatible with MDI child frames. That is why you may have problems with it.
|
|
Bacsó Gergely
|
Jan 19, 2007 - 9:51 PM
|
When I use the above method to have custom popup menus, I get a runtime error if I right-click on the title bar of a CExtControlBar class, which has a CDHtmlDialog as its child. And this case is very common I think.
Gergely BacsA?
|
|
Technical Support
|
Jan 21, 2007 - 3:38 AM
|
Please let us know if you updated the command manager with the IDR_TEST_POPUP menu resource?
|
|