1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| void GE_AppendMenu ( CMenu * pMenu, CMenu * pNewMenu )
{
ASSERT ( pMenu && pNewMenu );
if ( pMenu == NULL || pNewMenu == NULL )
return;
UINT uPos = pMenu->GetMenuItemCount ( );
CMenu subMenu;
char sText [ 128 ];
MENUITEMINFO info = {0};
info.cbSize = sizeof (MENUITEMINFO); // must fill up this field
info.fMask = MIIM_STATE | MIIM_STRING | MIIM_ID | MIIM_SUBMENU;
info.dwTypeData = sText;
info.cch = sizeof ( sText );
for ( UINT i = 0; i < pNewMenu->GetMenuItemCount ( ); i++ )
{
// Initialisation de la structure
memset ( sText, '\0', sizeof ( sText ) );
info.cch = sizeof ( sText );
if ( pNewMenu->GetMenuItemInfo ( i, &info, TRUE ) == FALSE )
{
DWORD dwError = GetLastError ( );
ASSERT ( FALSE );
continue;
}
if ( info.hSubMenu != NULL )
{
ASSERT ( FALSE );
}
InsertMenuItem ( pMenu->m_hMenu, uPos++, TRUE, &info );
}
} |