Print Page | Close Window

Hanging when using OnInitCommandsPopup

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=3968
Printed Date: 06 October 2024 at 5:20am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Hanging when using OnInitCommandsPopup
Posted By: BruceW
Subject: Hanging when using OnInitCommandsPopup
Date Posted: 10 April 2006 at 6:13am

Hi,

I have a very simple MDI example that I have been using to test ideas before incorporating them into my real application. I have been working on dynamic menus from the main menubar, using OnInitCommandsPopup.

The routine gets called OK and some initial tests indicate that in principle I can do what I want.  However the simple application hangs on the following code.

void CMainFrame::OnInitCommandsPopup(CXTPPopupBar* pPopupBar)
{
      // get the list of commands for the popup.
    CXTPControls* pControls = pPopupBar->GetControls();

        // Iterate through the list looking for the entries with the
      // extension markers.
    CXTPControl* pFirst = pControls->GetFirst();
    CXTPControl* pEntry = pFirst;

    long nIndex;   
    CString caption;

    while (pEntry != NULL)
    {
       caption = pEntry->GetCaption();
       nIndex  = pEntry->GetIndex();

         // If caption has extension marker, then include extended menus.
         // ...

       pEntry = pControls->GetAt( pControls->GetNext( nIndex, 1 ) );

         // GetNext cycles to beginning, so check for end of list.
       if (pEntry == pFirst)
       {
           pEntry = NULL;
       }
    }
}

This is simple to reproduce in a basic MFC MDI program (mine has a couple of other examples in such as child window tabs, etc. so I have not tried taking all of the other code out), as follows:

1. Run application.
2. Select the standard 'Window' menu option, its menu should appear.
3. Drag mouse right to the 'View' menu option and its menu should appear.
4. Drag the mouse back to the 'Window' menu option, its menu should appear.
5. Drag the mouse back to the 'View' menu option.  This will result in the application hanging.

Any advice or help here would be much appreciated.

Thanks,

Bruce.



Replies:
Posted By: Oleg
Date Posted: 10 April 2006 at 4:09pm

change loop to

 

for (int i = 0; i < pControls->GetCount(); i++)
{

CXTPControl* pControl = pControls->GetAt(i);
}



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net