/// Recurse into a menu listing, looking for sub menus
Recurse into a menu listing, looking for sub menus
Recurse into a menu listing looking for sub menus
fn recurse_menu(&self, menu_ids: &mut BTreeSet<u32>, menu_handle: usize)
            -> io::Result<()> {
        unsafe {
            // Get the number of menu items
            let menu_count = GetMenuItemCount(menu_handle);
            if menu_count == -1 {
                // GetMenuItemCount() failed
                return Err(io::Error::last_os_error());
            }
            // Go through each item in the menu
            for menu_index in 0..menu_count {
                // Get the menu ID
                let menu_id = GetMenuItemID(menu_handle, menu_index);
                if menu_id == !0 {
                    // Menu is a sub menu, get the sub menu handle
                    let sub_menu = GetSubMenu(menu_handle, menu_index);
                    if sub_menu == 0 {
                        // GetSubMenu() failed
                        return Err(io::Error::last_os_error());
                    }
                    // Recurse into the sub-menu
                    self.recurse_menu(menu_ids, sub_menu)?;
                } else {
                    // This is a menu identifier, add it to the set
                    menu_ids.insert(menu_id);
                }
            }
            Ok(())
        }
    }
fn recurse_menu ( & self , menu_ids : & mut BTreeSet < u32 > , menu_handle : usize ) -> io :: Result < ( ) > { unsafe { // Get the number of menu items let menu_count = GetMenuItemCount ( menu_handle ) ; if menu_count == - 1 { // GetMenuItemCount() failed return Err ( io :: Error :: last_os_error ( ) ) ; } // Go through each item in the menu for menu_index in 0 .. menu_count { // Get the menu ID let menu_id = GetMenuItemID ( menu_handle , menu_index ) ; if menu_id == ! 0 { // Menu is a sub menu, get the sub menu handle let sub_menu = GetSubMenu ( menu_handle , menu_index ) ; if sub_menu == 0 { // GetSubMenu() failed return Err ( io :: Error :: last_os_error ( ) ) ; } // Recurse into the sub-menu self . recurse_menu ( menu_ids , sub_menu ) ? ; } else { // This is a menu identifier, add it to the set menu_ids . insert ( menu_id ) ; } } Ok ( ( ) ) } }
Recurse into a menu listing, looking for sub menus
Recurse into a menu listing looking for sub menus
&self
menu_ids
&mut BTreeSet<u32>
menu_handle
usize