![]() |
MenuBarMDIMenus Item takes what? |
Post Reply ![]() |
Author | |
cradke ![]() Groupie ![]() Joined: 14 August 2007 Status: Offline Points: 17 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello,
Thanks, you are right. Item propety doesn't work :( Fixed for 11.2 release.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
cradke ![]() Groupie ![]() Joined: 14 August 2007 Status: Offline Points: 17 |
![]() ![]() ![]() ![]() ![]() |
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++) { |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |