|
|
|
|
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 |
|
Mathias Berchtold
|
Mar 18, 2004 - 6:15 AM
|
Please add the following messages to the CExtMenuControlBar class. They are required for dynamic menus. WM_INITMENUPOPUP => OnInitMenuPopup and WM_INITMENU => OnInitMenu Thank you. -Mat SmartFTP.com
|
|
Technical Support
|
Mar 18, 2004 - 10:54 AM
|
Dear Mathias,
Prof-UIS menus are not based on the standard owner-draw Windows menus. They are dynamically activated popup windows. Each popup menu is the instance of the CExtPopupMenu object. This object sends its own notification messages to allow the menu to be modified on-the-fly. You can handle the CExtPopupMenuWnd::g_nMsgPrepareMenu registered Windows message that is sent once for each activated menu tree. Here is a sample code snippet for the dialog window:
ON_REGISTERED_MESSAGE(
CExtPopupMenuWnd::g_nMsgPrepareMenu,
OnExtMenuPrepare
)
. . .
LRESULT CYourDialog::OnExtMenuPrepare(
WPARAM wParam, LPARAM lParam)
{
lParam;
CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
reinterpret_cast
< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
( wParam );
ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
ASSERT( pPopup != NULL );
// insert your pPopup menu modificaion code here.
. . .
// sample 1: find and remove a command
INT nPos =
pPopup->ItemFindPosForCmdID(ID_SOME_COMMAND);
if( nPos >= 0 )
{
VERIFY( pPopup->ItemRemove(nPos) );
}
// sample 2: insert "about" command
// into the same position
VERIFY( pPopup->ItemInsert( ID_APP_ABOUT, nPos ) );
}
To handle the CExtPopupMenuWnd::g_nMsgPrepareMenu registered Windows message in the frame window based applications with a menu bar inside, you should use your own menu bar class derived from CExtMenuControlBar and override the OnHookWndMsg() virtual method:
class CMyMenuBar : public CExtMenuControlBar
{
public:
bool CMyMenuBar::OnHookWndMsg(
LRESULT &lResult,
HWND hWndHooked,
UINT nMessage,
WPARAM &wParam,
LPARAM &lParam )
{
bool bRetVal =
CExtMenuControlBar::OnHookWndMsg(
lResult,
hWndHooked,
nMessage,
wParam,
lParam
);
if( nMessage ==
CExtPopupMenuWnd::g_nMsgPrepareMenu )
{
CExtPopupMenuWnd *pPopupWnd =
reinterpret_cast< CExtPopupMenuWnd * >
( lParam );
ASSERT_VALID(pPopupWnd);
// insert your pPopup menu modificaion code here
. . .
}
return bRetVal;
}
}; // class CMyMenuBar
You may also take a look at the CMainDlg class of the ProfUIS_Controls sample. It handles the CExtPopupMenuWnd::g_nMsgPopupDrawItem registered Windows message which allows to repaint particular items in the popup menu. It also handles the CExtPopupMenuWnd::g_nMsgPopupDrawLeftArea registered message to paint the gradient in the left area of the CMainDlg dialog’s context menu.
|
|