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 » How to change status tips on-the-fly Collapse All
Subject Author Date
Mofei Abudura Jan 28, 2007 - 8:36 PM

I want to change the tooltips and status bar tips. i do it as following, but it doesn’t works:



    CString strMenuText = "MENU_TEXT";
    
    CExtCmdManager::cmd_t * p_cmd;
    p_cmd = g_CmdManager->CmdGetPtr( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, nMenuID );
    ASSERT( p_cmd != NULL );
    p_cmd->m_sMenuText = strMenuText;
    CString strTipText = "NEW_TIP";
    p_cmd->m_sTipTool = strTipText;
    CString strTipStatus = "NEW_STATUS_TIP";
    p_cmd->m_sTipStatus = strTipStatus;
}

Mofei Abudura Jan 29, 2007 - 6:45 PM

Thanks for your reply Suhai, i have found the reason, that’s because i misuse the g_CmdManager->UpdateFromMenu.
Such as following.


void CMainFrame::OnUpdateViewLanguage(CCmdUI* pCmdUI)
{
    CMenu* pMenu = m_wndMenuBar.GetMenu();
ASSERT( pMenu != NULL);

    // after i remarked the code snippet, it works fine
/*
    pCmdUI->m_bEnableChanged = TRUE; // all the added items are enabled
    VERIFY(g_CmdManager->UpdateFromMenu(
            __PROF_UIS_PROJECT_CMD_PROFILE_NAME,
            pMenu->m_hMenu ,
            true,
            true
            )
        );
*/
}
.

Mofei Abudura Jan 29, 2007 - 2:57 AM

nMenuID is a menu id
the problem i face the same as http://www.prof-uis.com/Forum_View.aspx?CID=29&M=736&s=tooltip
after switch to other menu, the modify have no effect

Suhai Gyorgy Jan 29, 2007 - 5:13 AM

The thread you are referring to was posted in 2003 and as you can see in the last post of the thread, Support solved the problem.

There are 3 things I think you could try:
1.) If you are not using latest version of Prof-UIS, try upgrading to it.
2.) Try to make a sample application, or modify one of the Prof-UIS samples so that it represents the problem, and let us test that application.
3.) If the command you are trying to change is on the top level of the menu (meaning it is not a menu entry, but one of the menubar’s buttons represents the command), you can try the following:
Make a CExtMenuControlBar-derived class and override virtual BOOL _UpdateMenuBar(BOOL bDoRecalcLayout = TRUE); method with the following code:

BOOL CYourMenuControlBar::_UpdateMenuBar(BOOL bDoRecalcLayout)
{
	BOOL bRet = CExtMenuControlBar::_UpdateMenuBar(bDoRecalcLayout);
	UINT nCmdId = GetButton(nPositionOfYourCmd)->GetCmdID();
	CExtCmdItem *pCmdItem =
		g_CmdManager->CmdGetPtr(
			g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),
			nCmdId
			);
	ASSERT( pCmdItem != NULL );
	pCmdItem->m_sTipStatus = "Text";
	if( bDoRecalcLayout )
	{
		Invalidate();
		_RecalcLayoutImpl();
		UpdateWindow();
	}
	return bRet;
}
Call m_wndMenuBar.UpdateMenuBar(); instead of your tip-changing code before (and of course use the derived class as the menubar in your application)

Suhai Gyorgy Jan 29, 2007 - 2:28 AM

I’m using around the same code and it works for me. Only difference I can think of:

	CExtCmdItem * pCmdItem =
		g_CmdManager->CmdGetPtr(
			__PROF_UIS_PROJECT_CMD_PROFILE_NAME,
			nCmdId
			);
	pCmdItem->m_sTipStatus = "Text";
Another thing that needs to be clarified: nMenuID in your code defines a command identifier or a menu?