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 items always disabled Collapse All
Subject Author Date
pascal bosquet Jul 26, 2006 - 5:03 AM

hello again, thanks for your previous help, it worked like a charm, you rules :)

i’ve come to another small problem, i’ve my object which is a resizabledialog insible a dockabletoolbar. i added a CExtPopupMenuWnd, but every time it popup, my items a disabled even i specify the ON_COMMAND and ON_UPDATE_COMMAND_UI. I registered the command in the global command manager but still not better. any clues ?

thanks in advance

pascal


BEGIN_MESSAGE_MAP(frmMemoryViewer, CExtResizableDialog)
    //{{AFX_MSG_MAP(frmMemoryViewer)
...
    ON_COMMAND(ID_FILE_VIEWBYTE, OnByte)
    ON_UPDATE_COMMAND_UI(ID_FILE_VIEWBYTE, OnUpdateFileViewbyte)

    //}}AFX_MSG_MAP
END_MESSAGE_MAP()


void frmMemoryViewer::OnByte()
{
    // TODO: Add your control notification handler code here
    AfxMessageBox("Tutu");
}

void frmMemoryViewer::OnUpdateFileViewbyte(CCmdUI* pCmdUI)
{
    // TODO: Add your command update UI handler code here
    pCmdUI->Enable(TRUE);
    
}

BOOL frmMemoryViewer::OnInitDialog()
{
    CExtResizableDialog::OnInitDialog();

...
    LPCTSTR strProfileName =g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() );
    ASSERT( strProfileName != NULL );
    CExtCmdItem *p= g_CmdManager->CmdAllocPtr(strProfileName, ID_FILE_VIEWBYTE );

    CExtCmdItem * pCmdItem =g_CmdManager->CmdGetPtr( strProfileName, ID_FILE_VIEWBYTE );
    ASSERT( pCmdItem != NULL );
    pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;

    if(!pCmdItem->StateIsEnable())
        pCmdItem->StateEnable(TRUE);

    return TRUE;
}




void frmMemoryViewer::OnContextMenu(CWnd* pWnd, CPoint point)
{
    
    CMenu menu;
    if( !menu.LoadMenu(IDR_MEMORY_POPUP) )
    {    ASSERT( FALSE );
        return;
    }

    HWND hWnd = AfxGetMainWnd()->GetSafeHwnd();
    ASSERT( hWnd != NULL );
    ASSERT( ::IsWindow( hWnd ) );

    m_Popup = new CExtPopupMenuWnd;
    VERIFY( m_Popup->UpdateFromMenu( hWnd, &menu ) );

    VERIFY(    m_Popup->TrackPopupMenu( TPMX_OWNERDRAW_FIXED, point.x, point.y )    );    

}

Technical Support Jul 26, 2006 - 9:34 AM

Please look at this code:

HWND hWnd = AfxGetMainWnd()->GetSafeHwnd();
...
VERIFY( m_Popup->UpdateFromMenu( hWnd, &menu ) );
It creates a menu which sends all the messages to the hWnd window, which is the main application window in your case. So you will not receive any ON_COMMAND and ON_UPDATE_COMMAND_UI messages in the frmMemoryViewer class. You need either to change the owner window to frmMemoryViewer or handle all the menu messages in the CMainFrame class.