Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - MenuBarMDIMenus  Item takes what?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MenuBarMDIMenus Item takes what?

 Post Reply Post Reply
Author
Message
cradke View Drop Down
Groupie
Groupie


Joined: 14 August 2007
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote cradke Quote  Post ReplyReply Direct Link To This Post Topic: MenuBarMDIMenus Item takes what?
    Posted: 05 September 2007 at 2:02pm
What should be passed to the Item property of the MenuBarMDIMenus collection.  Nothing seems to work.  Using the CommandBars\VB\MDISample none of the following attempts work.
 
    Dim MDIMenus As MenuBarMDIMenus
    Set MDIMenus = CommandBars.ActiveMenuBar.MDIMenus
    Dim MDIMenu As MenuBarMDIMenu
    Set MDIMenu = MDIMenus.Add(100, "Document", "Document")
    Set MDIMenu = MDIMenus.Add(101, "Image", "Image")

    Set MDIMenu = MDIMenus.Item(100)
    Set MDIMenu = MDIMenus.Item(1)
    Set MDIMenu = MDIMenus.Item(0)
    Set MDIMenu = MDIMenus.Item("Document")

In fact the following code never displays a message box
 
    Set MDIMenu = Nothing
    On Error Resume Next
    Dim Index As Long
    For Index = 0 To 65535
        Set MDIMenu = MDIMenus.Item(Index)
        If Not MDIMenu Is Nothing Then
            MsgBox MDIMenu.Caption + " " + CStr(Index)
        End If
    Next Index
 
The documentation says it should be the Id of the MDIMenu but the Id does not work.  This in and of itself is strange since the other collections take the standard 1 based index.   Using the Id makes it difficult to enumerate the list using the Item property since every part of the application must know in advance what the Id's are.
 
Chris Radke
 
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2007 at 2:34pm
Hello,
 
Thanks, you are right. Item propety doesn't work :( Fixed for 11.2 release.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
cradke View Drop Down
Groupie
Groupie


Joined: 14 August 2007
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote cradke Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2007 at 2:54pm
I look forward to the fix, in the mean time I have an acceptable work-around by getting the IEnumVARIANT interface...
 
inline IEnumVARIANT* GetNewEnum(IDispatch* pIDispatch)
{
    IUnknown* pUnk = NULL;
    _com_dispatch_method(pIDispatch, DISPID_NEWENUM, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&pUnk, NULL);
    return CComQIPtr<IEnumVARIANT>(pUnk).Detach();
}
 
 
XtremeCommandBars::ICommandBar* GetMenuBarById(long MenuBarId)
{
    CComPtr<IMenuBarMDIMenus> pIMDIMenus = m_spCommandBars->GetActiveMenuBar()->GetMDIMenus();
    CComPtr<IEnumVARIANT> pIEnum(GetNewEnum(pIMDIMenus));
    if(pIEnum)
    {
        long nCount = pIMDIMenus->GetCount();
        CComVariant* pVariants = new CComVariant[nCount];
        ULONG Fetched = 0;
        HRESULT hr = pIEnum->Next(nCount, pVariants, &Fetched);
        if(SUCCEEDED(hr))
        {
            for(long Index = 0; Index < nCount; Index++)
            {
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.