Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Hanging when using OnInitCommandsPopup
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Hanging when using OnInitCommandsPopup

 Post Reply Post Reply
Author
Message
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Topic: Hanging when using OnInitCommandsPopup
    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.
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: 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
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.205 seconds.